4 ms·
It's not an improvement though. I find it pointlessly verbose.
by FuzzyDunlop 14y ago
It's not an improvement though. I find it pointlessly verbose.
- jrajav 14y agoAs opposed to pointlessly terse and cryptic?
- kaoD 14y agoCryptic? Are you serious? I'm a CoffeeScript user because I find JavaScript too verbose and cluttered and I find Coffee's verbosity quite unnecessary too. Without syntax highlighting skimming over Coffee code is awful because you can't distinguish code from variables easy enough. This is easier to read: a && b && !c Than this: a and b and not c The form with symbols is easier to process because you can clearly distinguish its parts. What's cryptic about ?: ? You learn it just like you learn if ... then ... else and that's it, not cryptic anymore. Not to mention the yes/true/on thing. What a waste of reserved words. Text-like does not mean comprehensible. If that was true, then we'd write Coffee like this: function sum with arguments left and right means the result is left plus right That's a lot less cryptic, right ?
- darkchasma 14y agoWell, if I look at C/C++, I feel that since & means a bitwise operation and && means a boolean operation, and & in front is a reference operator, that & is "Having a meaning that is mysterious or obscure" since the symbol changes in context. I also feel your semantic example is overly obtuse. func SumOf left and right is left + right -- result is SumOf left and right --
- kaoD 14y ago> I also feel your semantic example is overly obtuse. Exactly what I think of if ... then ... else IMHO, your plus sign is "pointlessly terse and cryptic". See what I did there? Now seriously, why func? I prefer Coffee's (arg1, arg2, ...) -> syntax for functions. What strikes me as odd is the fact that such a slim language gets verbose in such aspects. Of course my example is overly obtuse: it's just an hyperbole! But anyways, I suspect the if ... then ... else syntax is just a side-effect of ? being used as an existential operator in CoffeeScript.
- darkchasma 14y ago> IMHO, your plus sign is "pointlessly terse and cryptic". See what I did there? No, I don't see what you did there because + has one and only one meaning, and that is add. Every child can identify what + means, the same cannot be said for (a,b) ->, even to developers who have developed their entire lives (unless they have experience with coffeescript). Hence, cryptic.
- klibertp 14y ago> This is easier to read [...] Than this > What's cryptic about [...] ? You learn it [...] and that's it, not cryptic anymore. It's hilarious how you state some fact explicitly with your own words and yet completely fail to realize this fact. Readability is not to be confused with familiarity - and you do exactly this. You say that if you learn something it becomes readable, which is not the point, and not true at all. Think of readability as a measure of how many things you need to learn to understand something. If you introduce a symbol which meaning is completely arbitrary and needs to be learned, you make your code less readable. While Wikipedia page[1] concentrates on the readability of texts written in natural language, it suggests that the more words the text uses, the harder it is to read. The second part of readability is text length, and so sometimes introducing a symbol to represent common concept, while making it harder to read by itself, makes the program more readable as a whole because it makes the program shorter. It's a trade-off that needs to be considered when designing a language. The 'class' keyword in CS is a good example: it codifies a useful idiom, that in JS takes 5 lines of code, into a single word. While you need to learn it's meaning, which on the one hand makes the program less readable, on the other hand it reduces the length of certain class of programs significantly and so it makes them much more readable than JS counterparts. The 'if ... then ... else' is a bad example. The ternary operator does not reduce the length of any program significantly, especially in the presence of the 'switch' statement. Every time you use a ternary operator you still need a test, true expression and false expression. Ternary operator introduces the infix syntax, and not one, but two symbols that you need to learn. It's bad, really bad for readability. The code written like this: if (alive and kicking or dead) then (something) else (something els) is much more readable than equivalent: (alive&&kicking||dead) ? (something) : (something els) because the latter is not significantly shorter and it introduces as many as 4 (!) symbols with arbitrary meaning. You may not recognize this, because you already know the meaning of all of these, but objectively the latter form is less readable. Your statement that boolean operators are more readable as symbols than as words is simply not true, at least if we use the definition of readability from wikipedia. You are much more comfortable with these operators as symbols, you're more familiar with them and used to them, but that is something entirely different than readability. You think that it's readable, while it's not. I wish more people actually knew what readability is. Relevant info is just a click away, yet everyone seems to have his own definition of readability, which makes any discussion highly subjective and useless in the long term. [EDIT] Forgot to mention, this is exactly why I find discussions on Lisp or Smalltalk syntax so infuriating. People are not interested how readable the syntax actually is, that is - how many symbols it introduces and how many of them are reused in different places. They say that the new syntax is "unreadable", while it is much more readable than alternatives, just unfamiliar. [1] http://en.wikipedia.org/wiki/Readability http://en.wikipedia.org/wiki/Readability
- FuzzyDunlop 14y agoHardly, considering its appearance in many programming languages. Although I would argue similarly that, if the ternary operator is terse and cryptic and needs to be changed to 'if ... then ... else ...'; then '->' and '=>' are equally terse and cryptic and should be kept as 'function'. It says what it does then, doesn't it?
- anon1385 14y agoI agree but we need to go further and replace as many of the terse and cryptic operators as possible with words. Something like this but for Javascript: http://minnie.tuhs.org/cgi-bin/utree.pl?file=V7/usr/src/cmd/sh/mac.h http://minnie.tuhs.org/cgi-bin/utree.pl?file=V7/usr/src/cmd/...