Something quite interesting arrived today on my virtual desk. Its name is CoffeeScript. The basic functionality is that it will take some simple syntax and compile it into Javascript. One of the many issues people have with javascript is its syntax and formatting as it tends to be quite unforgiving when you miss a ; or a )}.
Don’t think twice…
CoffeeScript offers a huge advantage in being able to write more human friendly syntax, and then have it converted into the mess of braces that javascript can be. For instance:
if (test > 10 && test2 < 4) {
function1();
} else {
Function2();
}
Can be written with Coffeescript as:
if test > 10 and test 2< 4 function1() else function2()
Note the lack of braces and semi colons. A new line marker is sufficient to tell it that this is the end of the line. The big question is whether systems and libraries like this make for lazy programmers. As you no longer have to consider opening and closing braces, ending lines or other standard essentials to coding, you may fall into bad habits and feel your brain come to a screeching halt when presented with raw Javascript.
We have all experienced this when using autocomplete regularly. The day you don’t have it to hand your brain hits a blank spot… was it font-size or text-size? What are the five types of positioning in CSS?
Although this system is a great step forward in trying to untangle the mess that a long and nested Javascript file can be, sometimes the easy route is not always beneficial in the long run.
- Making colours count - February 22, 2014
- Facebook opens up origami offering - February 15, 2014
- Hello Ruby - February 8, 2014