Hacker News new | past | comments | ask | show | jobs | submit login

I love CoffeeScript. The only thing that seems unintuitive about it is how functions get defined, and perhaps the meaningful whitespace (no 'end' on blocks).

I've always wondered why they made coffee-script syntax so close to ruby without going all the way. "Write javascript in ruby" would have been a killer feature and tagline, but instead we're 80% of the way there with occasional expectations still being broken and new quirks to learn. Anyway...still a huge improvement overall so don't want to sound negative. Just something I was curious about.




As someone who learned coffeescript last weekend, it took me literally minutes to figure out enough to translate some javascript I'd written. And I've never even used a significant-whitespace language before.

That someone who knows javascript can so trivially pick up coffeescript says a lot about why they chose the syntax they did.


>The only thing that seems unintuitive about it is how functions get defined

http://en.wikipedia.org/wiki/Function_(mathematics)#Notation

I think that's probably the source (perhaps indirect) of CS's function notation. Personally I think it's far more intuitive than JavaScript's, if you start out knowing neither language.


I don't think a direct translation of Ruby -> Javascript would have made much sense, though. It makes much more sense to custom mould a new language to the needs of Javascript, than to try and fit Ruby into a whole new context.

I started looking into making a parser that took CoffeeScript and parsed it into PHP, and the farther I got spec'ing things out, the less the CoffeeScript syntax made sense for the context of PHP. So it would make more sense to start new, and create a new syntax that fits better. I'm assuming the same process may have occurred for CoffeeScript.

Anyways, as someone who greatly prefers Python over Ruby, I love using whitespace for blocks.


Ruby has a 6000 LOC yacc parser for the grammar. I would bet that Coffee's grammar is smaller, tighter, and less full of perlisms.



Perhaps it is also influenced by Python? Come on, not everyone on Earth loves Ruby's syntax. I was turned off by the endless 'end's.


Because there are already a ton of projects out there that attempt to implement Ruby in JavaScript. See the "Ruby" section on this page:

https://github.com/jashkenas/coffee-script/wiki/List-of-lang...

The point of CoffeeScript is something quite different. It's an attempt to tidy up JS semantics, while finding a minimalist syntax to express the "good parts" of JavaScript. Any similarities to Ruby, Python, Haskell, Perl, Potion, etc. are hopefully only present in places where they make sense on the merits, and not just to be similar for familiarity's sake.




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: