3 ms·
There has been a development of hate towards CoffeeScript in most JavaScript communities. This is FUD. CoffeeScript is JavaScript, and if you come into CoffeeS
by vectorpush 13y ago
There has been a development of hate towards CoffeeScript in most JavaScript communities.
This is FUD. CoffeeScript is JavaScript, and if you come into CoffeeScript thinking it works like ruby just because it looks like ruby then you're in for a rude awakening.
Personally, I'm a fan of CoffeeScript's streamlined syntax compared to JavaScript.
For example:
describe 'when the universe exists', ->
it 'should be active', ->
expect(universe.active).toBe true
vs
describe('when the universe exists', function(){
it('should be active', function(){
expect(universe.active).toBe(true);
});
});
It's no surprise that newcomers are sometimes inclined towards CoffeeScript since one the biggest obstacles for a budding javascript programmer is the seemingly incomprehensible labyrinth of brackets, parenthesis and semicolons (not to mention the confusion that ASI adds to the picture) that one must endure to grok the language. Of course, it's not really that hard to understand, but CoffeeScript filters out a lot of "syntax" making it easier for a newcomer to tackle the meat of the application. Less is more.
- nickfargo 13y agoAnd moreover, describe 'syntax after upgrading', -> it 'should be even meatier', -> expect parentheses.required .toBe false Very tidy.
- andreypopp 13y agoYou can get even nicer and more useful (due to generated assertion messages) with Sweet.js macros (https://github.com/andreypopp/sweet-assertions https://github.com/andreypopp/sweet-assertions) describe 'when the universe exists' { it 'should be active' { universe.active should be true } } The pre-generated assertion messages means you get `universe.active should be true` in case of error which includes actual source of the expression.