4 ms·
Not 'less intuitive', it is 'less familiar'. These sorts of comments are largely subjective. See also C family programmers looking at Lisp or ML family language
by brehaut 17y ago
Not 'less intuitive', it is 'less familiar'. These sorts of comments are largely subjective. See also C family programmers looking at Lisp or ML family languages.
- fnid2 17y agoYou are going to have a very hard time convincing me that anyone who doesn't know Coffeescript syntax is going to undertand what this means: number: -42 if opposite_day however, almost anyone, even non-programmers can understand this: if (opposite_day) { number = -42; }
- grandalf 17y agoThat may be true, but what about when opposite_day is null vs undefined ... there are a lot more improvements than just inline conditionals.
- jashkenas 17y agoYou can also do this, if you prefer equals signs: number = -42 if opposite_day Or this, if you prefer your conditions first: if opposite_day then number = -42
- brehaut 17y agoPersonally i don't care what someone who doesn't understand language X can make of a piece of code written in language X. What I care about from a languages syntax is that it makes programs clear to someone familiar with the language. Like i mention previously C family programmers often cannot make head or tail of a Lisp or ML family program, yet both those languages have excellent syntax where the choices made allow the programmer to express their intentions very clearly. Contrast this with the popular view of Perl; One persons perl code can be impenetrable to another experienced perl programmer. Syntax matters, but the familiarity with that syntax for outsides only matters from a purely political perspective. If you want to make a successful language, make it C flavored and baroque. If you want to make a truly great language, make the syntax that is best suited to what you are doing.
- endtime 17y agoAdmittedly, I wrote something in Perl three years ago, but that line is perfectly intuitive to me.
- rbxbx 17y agomakes sense when you use ruby the bulk of your day :)
- chromatic 17y agoeven non-programmers can understand this Isn't that the Python fallacy? (Take away the curly braces, anyhow.) Programming is a lot more than syntax. How many non-programmers do you know who understand the semantics of mutable assignment without having it explained?
- jashkenas 17y agoI'm glad you brought up mutable assignment. The reason for allowing colons as an alternative to equals signs in CoffeeScript is two-fold, the lesser reason is to make regular assignment consistent with JSON assignment, eg, both of these are legal CoffeeScript: obj: {prop: val} obj.prop: val obj = {prop = val} obj.prop = val But the main reason is to avoid the equals sign as a symbol for assignment, because it has such a different meaning that you would expect in its use in math (unless immutable), where it implies the equivalence of the expressions on the left and right side for the entire duration of your proof. Using colons, like JSON does to great effect, looks more like tagging a value with a label, which is much closer to the meaning of what you're actually doing in JS.