5 ms·
My own personal opinion is that whatever language you're using (or, indeed, in mathematics) using redundant brackets is generally the best idea anyway. Removes
by halo 18y ago
My own personal opinion is that whatever language you're using (or, indeed, in mathematics) using redundant brackets is generally the best idea anyway.
Removes any ambiguity, easier to read, doesn't need you to remember precedence rules and there's negligible difference in execution speed.
- eru 18y agoTry using redundant brackets in Lisp.
- ajross 18y agoIsn't python (no brackets at all) an existence proof that you're wrong, though? The eye learns rapidly to ignore brackets. What it reads is indentation. And most editors will try to enforce indentation levels even without brackets present. Or maybe you're just talking about parentheses in precedence grammars? I guess I have no objections there, but still: the fact that "multiplication has higher precedence than addition" is taught in grade schools and is used everywhere, in every language I know that supports precedence at all. What conceivable purpose could one have to buck this trend? All you gain is maybe a few lines of complexity in the parser (I mean, it's not like these things are hard to write) at the cost of a lifetime of newbie syntax errors.
- stcredzero 18y agoIf the newbie programmers are professionals worthy of the name, those errors won't make it into production. A less complex parser will have tremendous leverage by making it easier to craft syntax-aware programming tools. Smalltalk has a history of amazing ground-breaking programmer tools written by single individuals years ahead of their appearance in other languages. Contrast this with Ruby. I like Ruby a lot. It's a great language. The syntax is a bit hairy, however. Teams of people worked for a couple of years to produce an ANTLR parser which is independent of the Ruby VM's parser and could be used for programming tools. A good programmer can just crank out a top-down Smalltalk parser in one day. If you make your language easy to work with, you get a more powerful toolset sooner. On top of that, the lowered barrier to entry gets you more real innovation in that toolset.
- aristus 18y agoWell, order of precedence rules are much more complex in programming languages, and are not the same across languages. Mixing math with logic and bitwise operators without explicit parens is a classic "newbie" mistake.