4 ms·
Personally, I think gofmt made the right call -- let the editor soft-wrap long lines. This is much nicer because you can then dynamically pick whatever window w
by dilap 8y ago
Personally, I think gofmt made the right call -- let the editor soft-wrap long lines. This is much nicer because you can then dynamically pick whatever window width you want. Hard wrapping defeats this.
(But of course there are downsides, because if you're in a context where the editor/viewer isn't soft wrapping, it's worse. Still, on balance, I think not manually wrapping lines is the way to go.)
- deleted 8y ago[deleted]
- kibwen 8y agoA lot of it depends on the properties of the language itself. Traditional C-style imperative code involves many short statements each doing one small thing, one expression per statement, one statement per line; this makes it simple to punt on wrapping long lines (which is 90% of the difficulty of writing an automatic code formatter). Go inherits this "tall-and-narrow" idiomatic style. But other languages, especially ones that try to encourage fluent APIs, will often have several expressions within each logical statement, leading to fewer lines of code overall but more action on each line. In these languages it tends to be idiomatic to break the statement across multiple lines (usually at method calls), in which case an automatic code formatter's job is to do this operation manually.
- dilap 8y agoSeems like you're talking about splitting statements over multiple lines because it aids comprehension and makes sense semantically. Code-formatters are concerned with splitting lines that exceed some arbitrary line limit, no? The former it seems like it makes sense for me to do as the human authoring the code for readability (it seems a very similar decision to, "do I assign this value to a variable or include it inline"), the latter makes sense to do dynamically, given the line-length-limit of the moment. That said, no experience with these languages, so maybe I'm way off base. I'd be curious to see code samples, if you really feel like digging deep. :-)