5 ms·
>Next time we have a conflict with a colleague on what is “readable”, let’s ask ourselves “Am I talking about understandability or I am talking about aesthetics
by Rainymood 7y ago
>Next time we have a conflict with a colleague on what is “readable”, let’s ask ourselves “Am I talking about understandability or I am talking about aesthetics?”
This is why I'm in favor of auto-formatters like Black for Python. Nobody really likes it, but nobody really hates it either and you get used to it. What this does is that it completely removes the style component of the discussion, leading to better and more content-wise discussions of the code written.
- cartlidge 7y agoI think it's more productive to not care about the formatting. Allow redundant, pointless spaces that serve only to keep things out of alignment. Once it doesn't matter if the code is pretty - or if the autoformatter has been run - you just read the content.
- deleted 7y ago[deleted]
- stereolambda 7y agoI'd say the main reason for strict formatting is the organizational one: when you really need for the same file to be edited by many people and not turn into a mess. Otherwise, it may be convenience, as I don't have to maintain consistency manually. May be, because in languages where there are multiple syntactic ways to do things (Python, JS), I want flexibility in emphasizing things. (Even if I don't overuse it.) It's hard for people who came up with formatting to predict everything what can be done in the language. People may use more imperative, more functional syntax, mix things etc. This may be even warranted in the context. Of course, you can force a particular set of idioms, but this again becomes shifted to the context of a project or organization. In languages where the syntax is more uniform, it's easier to standardize formatting throughout the whole ecosystem. And indeed it is standardized in Lisp and Go for example - not in the C family for probably historical reasons.
- makapuf 7y agolanguages where there are multiple syntactic ways to do things Python zen says: the should be one (and preferably only one) obvious way to do it. Perl might fit your description better.
- Avamander 7y agoUnfortunately we have many ways to do format strings now :P
- makapuf 7y agoNo, we only have fstrings now :) - I know -too well- backwards compatibility...
- EForEndeavour 7y agolist(map(f, iterable)) versus [f(x) for x in iterable] also comes to mind!
- makapuf 7y agoIf I remember correctly, it is recommended to use list comprehension (see stackoverflow)
- niix 7y agoAgreed, the same applies in JS w/ Prettier.
- strokirk 7y agoOh, there are many that hate it, we just get voted down fairly fast.