Monday, October 13, 2014

my CoffeeScript intro

Always Be Learning

Let's learn CoffeeScript today.

What is CoffeeScript?  Well it is a front end script language that gets compiled down to Javascript.  It was developed with the goal of making Javascript more readable and understandable.

So Code School here we come... (course)


The fact that it has a command line compiler that compiles into Javascript is very interesting.  I like the feature of being able to set up a service to watch your code and auto compile it.

The Code School course initially does not seem as well developed as the one for AngularJS in terms of the challenges.  You can tell the CoffeeScript was made earlier.

Not a fan of:

  • @ symbol used in the place of 'this' keyword.
    • although it is slick when getting this.properties
      • @name
  • Optional brackets ( )  for function arguments; arguments are one of those things I like being explicit about.
  • Intenting aka whitespace is very important since it takes the place of brackets, commas, semicolons, and more.  This concerns me cause I know how character encoding can vary between operating systems and editors.  I can foresee this being a very tricky thing to get to the bottom of when trying to debug unexpected behavior. 

A fan of:

  • automatic creation of variables, no need to declare them explicitly
  • the code around conditionals seems human readable.
    • Examples:
      • if paid() and coffee() is on then pour()
      • addCaffeine() if not Decaf()
      • addCaffeine() unless Decaf()
    • This is something I like in my unit test code but not sure how I will feel about it later in my production code.
  • they way object orientation and inheritance is written in CoffeeScript in my opinion is more intuitive
  • "the fat arrow"... google it

Overall I think CoffeeScript is nice but I am not sure I see more value in it than I do just knowing JavaScript very well.  I would have to see it in an enterprise setting most likely to really see its value.





No comments:

Post a Comment