Hacker News new | ask | show | jobs
by alexvoda 2022 days ago
> It forces you into breaking your code in more digestible bits rather than a 500 char single-line monster statement. Honestly it's very similar to the argument against very deep indentation (forcing you to break your code in subfunctions) so I wonder why you feel differently about this.

Breaking code into digestible bits is only a solution when you can use it. I believe it is good if you take it as a guideline not as a rule.

Having extensively programmed in SQL, I've had to deal with monstruous pieces if code. And sometimes there is no way to refactor them. Sometimes because of quirky performance, sometimes because of legacy, sometimes because higher-ups decide to incur tech debt. Views, functions, CTEs and temporary tables help but are no panacea.

In SQL, you can quite easily enforce a line length limmit (though you might want to break it at times for table style readability) but enforcing a line count limmit is unphesable.

I imagine enforcing a line length limmit on a language with line breaks as instruction separators to be a cripling rule. Yes, you can store things in variables, you can split code into functions, and all of these might help readability but they might also hinder readability.

Anytime you work with things resembling wide two dimensional arrays (arrays, consecutive assignments of functions with the same signature, members of a structure, etc.), linebreaks in any other place other than between rows of the array are a hindrance to readability. You can break the line at predetermined points (e.g.: after the fifth, ninth and twelveth parameter for a particular function) and if there is code between the "rows" or if you need comments this approach is preferable. But if the "rows" are consecutive and there is nothing to explain in comments and the languages does not allow you to colapse "columns" and you need to do this often enough, then enforcing a line length limmit is harmful to readability.

Rather than blindly following a rule like 80 char limmit, I prefer to try to stick to the prefferd conventions of each language. If there are none appliable, find what works for the project. Line length limmit is helpful, but not paramount.