One more cup of CoffeeScript for the road

Posted on May 27, 2013

 

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.

Steven is Engage Web’s go-to man for all things web-related, bringing his knowledge of current trends in web design and development to the team.
Latest posts by Steven (see all)
Call Now Button
>

Who Engage Web has helped:

Ice Lolly Minuteman Press BUNZLGS1 UK The Underfloor Heating Store West Cheshire Athletic Club Thomas Cook MWB Business ExchangeWeb Media 360 D2 Architects Beacon Financial Training Steely ProductsBurlydam Garden Centre Asentiv BodyHQ Clever Vine Endeavour Mortgages Pro Networks Comm-Tech Wickers World Ascot Mortgages Top Teks
TEL: 0345 621 4321