Ah Python, you have spoiled me for all other languages

Steven D'Aprano steve at pearwood.info
Fri May 22 10:58:17 EDT 2015


It's good to have at least a passing familiarity in more than one
programming language, so for I've re-written a small Python script (56
lines, including blanks and comments) into Lua (67 lines), Ruby (73 lines)
and Javascript (102 lines).

Re-writing the code in Lua and Ruby was actually quite simple. There are
some syntactic differences and semantic differences, and Ruby lacks a
standard "assert" function or statement, but that only required seven lines
of code. (Three of them "end" statements.) I think Python is a prettier
language visually than either Lua or Ruby, but they're in the ball-park.
Both languages have their warts and quirks, but if Python were declared
illegal overnight[1] I'd probably have no trouble adapting to Ruby or Lua.
Python would still be my first love, but these two languages make a
reasonable rebound language.

But Javascript... 

Javascript also lacks a standard assert mechanism, but that wasn't too hard
to fix. It also has two different equality operators, each of which are so
complicated and confusing that apparently there are two-year Masters
degrees on them[2], and yet with neither of these operators does the array
[1, 2] equal the array [1, 2].

It's visually an ugly language, requiring braces and semi-colons.
Technically, some of the semi-colons are optional, and some of them aren't
optional but change the meaning of the code if you leave them out, so it's
just best to stick semi-colons after; everything; you; can; just; to; be;
sure.

I know that first impressions aren't necessarily to be trusted, but the
impression I get after a couple of hours is that Javascript tries really
hard to do everything it can for you except what you actually want. If it
were a remote control for a DVD player, there would be a button to turn the
volume up, skip to the next chapter, and turn subtitles off; and another
button to change the language to French and return to the menus; but no way
to just mute the sound.




[1] Anything that good has got to be either illegal, immoral, or fattening.

[2] If there aren't, there ought to be. 


-- 
Steven




More information about the Python-list mailing list