8 ms·
Put another way... if the proponent of a particular (serious) syntax style guide can't be bothered to automate it, then they are pissing in the wind. I laugh w
by frou_dh 8y ago
Put another way... if the proponent of a particular (serious) syntax style guide can't be bothered to automate it, then they are pissing in the wind.
I laugh when I see those 50-page English-language documents describing how some institution wants code to be formatted. Ain't nobody got time for that.
- emodendroket 8y agoThere are some limits to what you can automate but stuff like spacing should definitely be enforced by a tool.
- jeremy_wiebe 8y agoI feel like Prettier does a really good job with JavaScript. What situations have you found where automated formatting doesn’t suffice or has these limits?
- paulddraper 8y agoOrdering code. Some tools order/deduplicate imports. Prettier does not. [1] And no tool that I've seen orders fields/constructor/method, etc. [1] https://github.com/prettier/prettier/issues/949 https://github.com/prettier/prettier/issues/949
- jeremy_wiebe 8y agoInteresting, yeah, that’s definitely missing. ESLint has rules for ordering, feels like it’d be a relatively simple addition to prettier.
- eropple 8y agoIn JavaScript, imports sometimes (too often, really) have side effects. I don't know if it makes sense for prettier to do that, at least by default.
- paulddraper 8y agoIn my experience, side-effecting imports are fairly uncommon. But in any cases, all formatters allow you to selectively disable it for certain liners.
- dvlsg 8y agoHopefully uncommon, anyways. Imports with side effects sounds like a nightmare to debug.
- michaelmior 8y agoI don't have a problem with anything that discourages imports with side effects. You can always ignore[0] any cases where this happens. [0] https://prettier.io/docs/en/ignore.html https://prettier.io/docs/en/ignore.html
- chrisweekly 8y agoeslint and prettier are not mutually exclusive
- jeremy_wiebe 8y agoI didn’t mean to imply that. In fact we use eslint + prettier where I work.
- paulddraper 8y ago> it’d be a relatively simple addition to prettier. It would be, but as you can see in the linked issue, it was closed for being a non-goal. So, it's not likely to change. (Prettier generally keeps the AST identical; i.e. whitespace and parentheses changes only.)
- eberkund 8y agoI don't know if it supports JavaScript but Resharper does this for .Net
- reitanqild 8y agoI think all three major Java IDEs do this as well.
- edflsafoiewq 8y agoHumans format with rules that take into account semantic information, symmetry, and aesthetics. They know that a function call that gives the entries of a matrix is formatted as a grid for a reason even when the auto-formatter could fit it on one line. They know that that arm of the match that would be formatted weird if it were on its own is actually formatted well because it exhibits that case's consistency with the other cases in the match. Probably the most important formatting decision they make is to, rather than format a long line, break it into intermediate results and store them in local variables given human-meaningful names.
- seanmcdirmid 8y agoMany programmers are still committed to manual formatting, or fixed width fonts would have been obsolete already.
- dxhdr 8y agoFixed width fonts let you quickly parse syntax. Syntax and semantics are equally important when reading code, whereas semantics are generally the only thing you need for understanding the written language. That said, I haven't seriously tried programming using variable width fonts; maybe it's a well-kept secret to digesting code. Or maybe it's like Hemp Milk, there's a reason it hasn't caught on.
- diegoperini 8y agoI don't know if variable width fonts are a help or a disaster but I've been using multiple fonts in a single editor window for quite a while and the productivity boost is huge. My choices are Operator Mono (to typeset keywords and math stuff) and Firecode (to typeset ligatures). You can find my custom Atom stylesheet here if you want to try. PS: The idea is not mine but I can't remember where I read the instructions about this editor setup, so Google is your friend. https://gist.githubusercontent.com/diegoperini/853d54c8873e7b068947587429770fa1/raw/21f83feced50ff281cc30bdc6ad71b5afde01841/styles.less https://gist.githubusercontent.com/diegoperini/853d54c8873e7...
- seanmcdirmid 8y agoThere is actually no evidence for that. Programmers in general seem to be faster with whatever they are used to. I personally have trouble parsing code in fixed width fonts versus proportional ones* because I’m used to the latter and the kerning of fixed width formatting annoys me. Keywords pop out easily with syntax highlighting in any case, making syntax pretty obvious. * to be fair, I’d have trouble with a bad proportional font like Times New Roman, but I’m sure many would have trouble with Courier New on the other side, the specific font matters.
- arama471 8y agowait are you saying fixed width fonts are only useful for manual formatting? because I find they make it much easier to read code.
- bryanrasmussen 8y agoI worked at a place recently where someone (who left before me) argued seriously that automated syntax fixing shouldn't be brought into the millions of lines multi-project codebase with approximately a dozen developers with a 40% retention rate over any two year period because it would encourage bad habits by not properly punishing people for being bad.