6 ms·
I'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
by stereolambda 7y ago
I'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)