i lose time worrying about style, e.g. spacing, line indentation, etc.
i lose time adapting to different styles between projects.
why are languages made flexible in this regard? why not just demand very strict formatting?
Well, a good instructive example would be to look at what happened with Pascal and the ;
command separator.
The rule Nicklaus Wirth (the designer of Pascal) came up with was that the ;
was to be used to separate statements within a block. This is sensible from the compiler's perspective, because that's the only situation where a syntactic element is strictly required to resolve ambiguity. Plus, it is commonly done with the comma already, so the code to handle it is there.
The problem is that it is a weird rule, and a tough one for human coders to wrap their heads around. It is also not stable in the face of changes; if you add or delete a line at the end of the block, you have to change which line gets no semicolon. Most Pascal users ended up with a whole phase in every coding/debug cycle that boiled down to their compiler spitting errors at them till they got their semicolons right. They'd get to hate it, and by extension they hated Pascal.
Combine this with the relatively new concept of strong typing that Pascal and its descendents introduced, and you had some very cranky developers. They started calling Pascal and its ilk bondage and discipline languages, and gravitated to more permissive languages like C. This had the effect of retarding the growth of a lot of better languages, all because someone with a good theoretical concept made his language a PITA to use.
For later designed languages, Nicklaus Wirth learned his lesson and defined semicolons to be command terminators, not separators. The C designers of course took it a step further and allowed extra semicolons to be legal (but ignored) syntax elements.
Presumably the option for a user to define their own style ( whether this is enforced by some editor rules ) is preferable to a language forcing a certain style as part of its syntax. However some languages are slightly stricter when it comes to particular rules. For example, there is a 'feature' in Haskell whereby a given line must be indented further than some related preceding line to work properly ( I've forgotten the name of this particular language feature but I'm sure someone knows ).
精彩评论