3 ms·
> 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 som
by 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
- dgreensp 14y agoNobody here is "introducing" the ternary operator or && for "and," they are standard punctuation in the world of programming. I agree that, in general, it misses the point of readability to say "just learn the terms first," but in this case I think one could certainly argue that the punctuation is more readable than the words, by making better use of word-vs-symbol cues to make the structure of the expression clear. Finally, drop the idea that your view is "objective" and there aren't different opinions on readability.
- klibertp 14y agoI'm sorry, I shouldn't have said "objectively". But it's not my idea. I'm merely working with definitions provided by wikipedia. If you are aware of better source on this matter, please refer me to it. EDIT: what I mean is that discussing readability is pointless if all the participants have different definitions. I agree that the wikipedia page I linked to does not provide the best possible definition because it talks about texts in natural languages and we're talking about source code. Still, using not-the-best definition is better than using many different definitions.
- FuzzyDunlop 14y agoIn spite of arguing about this 'objective' readability, it doesn't address the issue that CoffeeScript is no more readable than Javascript is, because it introduces its own plethora of quirks and crypticness. Given the choice between the two I would opt consistently for Javascript.
- klibertp 14y agoI can't edit my comment anymore, but if I could I would replace "objectively" with "measurably" - there are "formulas" on the wiki page that I'm sure are applicable to programming languages and program sources. And I don't disagree with you. Coffee is less readable than JavaScript: "->" is less readable than "function", for example, and "@" is less readable than "this". It's a matter of trade-offs, these shortcuts make the language harder to read, but easier to write; the assumption here is that people will be able to deal with this level of brevity when reading. I went and googled for a bit for articles talking about code readability, I found a few interesting discussions: http://queue.acm.org/detail.cfm?id=957782 http://queue.acm.org/detail.cfm?id=957782 http://www.perlmonks.org/?node_id=592616 http://www.perlmonks.org/?node_id=592616 http://www.joelonsoftware.com/articles/Wrong.html http://www.joelonsoftware.com/articles/Wrong.html Worth reading.