Skip to content

Comment on A Python programmer’s first impression of CoffeeScriptparent

Comments

Coffeescript does inherit its parentheses-are-optional attitude from Ruby, and as a Ruby programmer, it makes perfect sense to me. That said, just because they're optional doesn't mean it's required to be omitted; I'll often use parentheses when I feel that adding them improves code clarity.

Having been writing Ruby for a few years, I really dig that parentheses aren't required - you can write code that reads a lot more like English and a lot less like...well, code. It does take some mental re-training though. Once you've grown accustomed to it, it scans really nicely, and while it's very possible to write code that's difficult to visually parse, good programmers will use parentheses when they improve clarity, and omit them when they don't.

It helps a LOT to remember that in Coffeescript, you're more or less never naming functions - you're just passing around a bunch of lambdas. The function syntax tripped me up at first, as well, but once I got a handle on what it was doing, it makes a lot of sense.

I've described Coffeescript as "Javascript in drag as Ruby with a Python under her skirt", and I think it's a fairly apt description. :P

I think this a great attitude towards optional syntax. For example:

   xCoord(points[0]) - xCoord(points[1])
...is clear, but paren-ful, whereas:
   print object
...is also clear, but has no need of parens.
AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.