UPDATE! 3rdEden has pointed out that it’s possible to get harmony in node 0.6
You can get it by using a flag when invoking node through the command line
node --harmony_typeof --harmony_block_scoping --harmony_proxies --harmony_weakmaps file.js
Or if you’re using node 0.7.x
node --harmony file.js
Harmony!!!!1
Enable ECMAScript’s new features and syntax in node point javascript.
Node unstable has just been released and with that V8 has been upgraded to 3.8.6 which contains flags for experimental language features.
By default those flags are turned off, but you can always turn them on. Here’s how:
Download node 0.7.0.
If you’ve got it cloned on git run a git fetch and then git checkout v0.7.0 otherwise read the release notes for instructions on where to download.
Set harmony flag to true in V8
Once you’ve got the source code, open up deps/v8/src/flag-definitions.h and look for Line 115
Change the flag from false to true.
DEFINE_bool(harmony, true, "enable all harmony features")
Compile Node
./configure && make && make install
Have fun!
function foo() {
"use strict";
let i = -1;
for (let i = 0; i < 10; i += 1) {
console.log(i); // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
}
console.log(i); // -1
}
foo();
NOTE: you’ll need to use "use strict"; otherwise the code above will not run.
By doing this you’ll get:
Learn more about ES harmony
Recently I’ve been using this vim plugin called vim-powerline which has plenty of nice features like
I highly recommend it.
Anyways, vim-powerline wasn’t working properly on my laptop though. Some files like .gitignore would work whereas others like sample.coffee wouldn’t. If I removed my ~/.vim/ftdetect folder most files would work but that wasn’t the solution.
I finally narrowed it down to my custom syntax highlighting colour scheme mango.vim. The offending line was this:
highlight clear
After looking into it I found out that highlight clear was clearing all of vim-powerline's styles so for files where syntax highlighting was turned on, the plugin wasn’t working as expected.
So if you’re having difficulties installing vim-powerline, check to make sure your color scheme isn’t clearing highlights. Dark color schemes commonly have this set.
Installing vim-powerline is fairly easy. You’ll need to be on an 88 || 256 color terminal — so if you’re on OSX I definitely recommend iTerm2.
In your .vimrc file you’ll set the following
set nocompatible
set t_Co=256
Make sure Powerline.vim is in ~/.vim/plugin/ and Pl folder and Pl.vim is in ~/.vim/autoload/ and you should be all set.
On case against coffeescript... -
There are basically a few arguments against using CoffeeScript and at the end of the article Ryan Florence suggests one to not use it. It basically boils down to these cases:
So yes, debugging is an issue. Hopefully this can be solved soon by SourceMap.
I agree, in fact I comprehend Verbally Readable !== Quicker Comprehension quicker than I do the title. But the nice thing about CoffeeScript is that it’s just JavaScript so the lengthy wordy operators are optional.
You could always write in CoffeeScript:
one && two && three
instead of
one and two and three
Here’s an example from the blog:
scores = (student["assignment_#{@assignment.id}"].score for own idx, student of @gradebook.students when student["assignment_#{@assignment.id}"]?.score?)
Right, that’s not easy to comprehend. In this particular case I don’t blame the language but the author.
Sure the CoffeeScript documentation touts how it turns verbose JavaScript into “nice” and “sexy” one-liners but that doesn’t mean one should abuse it.
So does every other language. I think the good parts of the language outweigh the bad parts.
Spaghetti code itself is bad. I don’t care what language you write it in. It’ll always look like shit.
It seems like now we’re talking about preferring one type of spaghetti over another type of spaghetti — it’s still spaghetti.
Is that really a bad thing?
I still believe the expressiveness and useful features that CoffeeScript provides outweighs the biggest problem which is debugging.