Why I have given up on JavaScript

I think I’m not the only one who think that JavaScript is very ungentle in its syntax. Complex code is true challenge to maintain. Lots of braces, overlapping variables and control over the scope has already brought thousands of programmers to madness. Also understanding proper patterns of programming and prototype-based inheritance doesn’t come easily for most of people. But JavaScript is evolving, after years of stagnation, dimmed by Flash and its object and event driven paradigms.

 

The wind of change

As you probably know last years brought a lot of changes for JavaScript. Many open-source projects which were developed on Google Code and GitHub had broken almost monopolistic prime of jQuery-oriented plugins and a bit less popular MooTools framework. JavaScript has started to shaping it’s maturity by creating front-end frameworks and finally changing the point of view on MVC model, as a single inseparable unit. Currently, many start-up projects in Silicon Valley relays on MV* or MVVM frameworks. If that happens – it’s decided – that’s the future model of web-development. So more and more single-page websites appear basing on templates build on client side, containing hundreds of asynchronously download assets and moving parts of business logic to the client side. With effect in growth of JS code to thousands of lines. And at that moment of glory of JavaScript I gave it up. Why? Because I wanted to be ready for future changes.

coffescript logo - javascript development language

Say hi to CoffeeScript

I decided to gave up JavaScript for CoffeeScript – programmer-friendly language, created to bring relief to most of current JavaScript’s problems. His success can be proven by 11th position on GitHub’s language popularity list and sugar python-like syntax that makes code much cleaner and human-readable by making radical changes in syntax structure:

  • Objectivity ECMA 6 ready

    Unlike classic JavaScript that primarily emphases prototype inheritance, CoffeeScript focuses on it’s objective aspects. That makes it worth to learn, due to announced changes in EcmaScript 6 [currently draft] standard, that will add objective paradigms to JavaScript such as: objectivity, inheritance, constants or truly limited scope variables. These changes are very similar to what Coffescript currently offers, so learning it is preparing for new, that will surely come.

          class example extended by superClass
            # property
            @property
    
            constructor: ->
              # call function
              @method()
    
            # function
            method: (parameter) ->
              alert(parameter)
        

    If your looking for more information about ECMA6, Nicholas C. Zakas has shared his thoughts about new JavaScript syntax in his post on NCZOnline.

  • Brace-less code

    CoffeeScript let you optionally omit most of the braces in your code, making the code less enigmatic and almost brace-less. From my experience, applying all the brace-removal features makes more mess in code than not using them at all, but there is always good balance-point that works smoothly.

    Learn how to write readable and clean CoffeeScript code.

  • String interpolation

    With CoffeeScript you can forget about the concatenation of the strings that can be cleanly placed into the strings.

            name = 'John'
            alert("hello #{name}")
          
  • Managing the scope

    Due to fact that var keyword is forbidden in CoffeeScript, the control over the scope of the variables is gently hidden and prevents overriding. Explicitly, your whole code inside one file will be wrapped inside anonymous function to create inviolable namespace for JavaScript.

  • Type coercion in comparison operators

    Inexperienced programmes often forget about the difference between == and === operators. The effect is quirky code, that unexpectedly stop working, because the interpreter implicitly tries to convert the values before comparing of values. Example below shows it precisely:

            # true
            true == 1
            # true
            '2' == 2
    
            # false
            true === 1
            # false
            '2' === 2
          

    CoffeeScript prevent coercion errors happen by forcing usage of === in comparison operations. It lowers the code efficiency a bit, because == is faster than === in execution, but by forcing that, prevents substantial errors in the code.

  • @ shortcut

    To make writing this faster, really smart alias @ was added. It stands out of the code and it’s very easily cached by eye. For me it’s meaningless syntactic sugar, but yet very helpful.

  • Control over this handler

    The most gorgeous thing I love in CoffeeScript is definitely fat-arrow operator that allows to decide on handling scope of this handler when changing scope in code.

          class clickClass
            $(elem).on('click', @clicked)
    
            # This === clickClass
            clicked: (e) ->
              alert(@)
    
            # This === clicked element
            clicked: (e) =>
              alert(@)
          
  • Comprehensions

    Looping over arrays and hashes is very crucial in every language. The more we can enhance the experience, the better language is. CoffeeScript’s juice is made form that particular feature, allowing programmer to nicely and very efficiently iterate over the value+index of an array, or the key+value of a hash, hiding beneath nasty code.

            results = ( book.name for book in bookstore when book.rating > 3)[0...10]
          

    Learn more about CoffeeScript comprehension from post on OpenMind.

[bra_border_divider]

Criticism of CofffeScript

CoffeeScript is a language that constantly evolve and already has created huge society around. Yet it is still far from perfection. When you’ll google CoffeeScript you’ll probably meet with strong words of criticism about this language from other people, complaining about it’s non-JS, sugar syntax and lack of efficiency. Being honest makes me tell the truth. Some, if not most, of them are right in their complains. CoffeeScript is not language for you if you begin your journey with web-development. To take 100% efficient code from time to time you have to optimize it manually after compilation by CS, because the generated code is not always the fastest one. So, only if you fully understand the basics of JavaScript that lies behind this gentle language, you should consider learning it.

On the other hand I can say that CoffeeScript outputs heavily optimized code to the ground. It puts the quality of avarage JavaScript code to much higher level and allows to prevent very substantial errors. So, when I meet people who think that CoffeeScript is bad ‘just because’, I can only say that they are perfect example of Python Paradox – people being afraid of changes – and cut my discussion with them.

[bra_blockquote]CoffeeScript is like putting lipstick on a pig, but it is damn good lipstick.[/bra_blockquote]

[bra_border_divider]

Final words

CoffeeScript is the very successful successor of JavaScript and creatof of the way JavaScript currently evolves. Moreover it has shown how strongly the society can influence the shape of the programming language. So, if you’re not newbie to JS, take deep breath and enjoy the world that the JavaScript will be within few years, after release of ECMAScript 6. CoffeeScript will allow you to write clean JavaScript, and delivers business value by helping you to write maintainable JavaScript faster that it otherwise would.

[bra_border_divider]

Further lecture - relative links to interesting articles

Further lecture

If you feel that you want to go deeper into CoffeeScript see the links below:

If you read it, you should share it:

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

  1. CoffeScript Homepage is broken. Also there seems to be a problem with xml special characters in code ;) or the CoffeScript is so strange :D but according to my experience it’s not ;>

    Regards,
    Damian

  2. Thank you for another informative site. Where else could I get that kind of information written in such an ideal way? I’ve a project that I am just now working on, and I’ve been on the look out for such information.

  3. Thank you for sharing superb informations. Your site is so cool. I am impressed by the details that you’ve on this website. It reveals how nicely you understand this subject. Bookmarked this website page, will come back for extra articles. You, my pal, ROCK! I found just the information I already searched everywhere and just could not come across. What a great site.

  4. I discovered your blog site on google and check a few of your early posts. Continue to keep up the very good operate. I just additional up your RSS feed to my MSN News Reader. Seeking forward to reading more from you later on!…

  5. I just want to mention I am just all new to blogging and definitely enjoyed this web-site. Almost certainly I’m likely to bookmark your blog . You amazingly come with terrific writings. Thanks for revealing your website page.

  6. I’m impressed, I must say. Really rarely do I encounter a blog that’s both educative and entertaining, and let me tell you, you have hit the nail on the head. Your idea is outstanding; the issue is something that not enough people are speaking intelligently about. I am very happy that I stumbled across this in my search for something relating to this.

  7. Very cool Mr. Elliot. I’m starved for missives from the mailbox. I’ll admit it, I even open junk mail. (Hey, maybe it’s a check with a lot of zeros at the end.) Such a sad existence for me when my one a small rush of importance is ripping open junk mail. Bills can wait, so a real letter sounds excellent. Will subscribe.
    Cheers, Iris

  8. Oh my goodness! an amazing article dude. Thank you However I am experiencing issue with ur rss . Don’t know why Unable to subscribe to it. Is there anyone getting identical rss problem? Anyone who knows kindly respond. Thnkx

  9. Thanks a lot for posting this, I added a link to your blog on my site! Hope thats ok!

  10. magnificent post, very informative. I wonder why the other specialists of this sector don’t realize this. You must continue your writing. I am sure, you’ve a great readers’ base already!

  11. Keep up the superb piece of work, I read few blog posts on this web site and I conceive that your weblog is real interesting and holds lots of great information.

  12. Marvelous, what a webpage it is! This website presents helpful
    information to us, keep it up.

  13. I do not even know how I ended up here, but I thought this post was good. I do not know who you are but certainly you’re going to a famous blogger if you aren’t already ;) Cheers!

  14. Pingback: Why I have given up on JavaScript | Philip Bignell : Digital Technology

  15. Pingback: Recommended Read: Why I have given up on JavaScript | Philip Bignell : Digital Technology

  16. excellent points altogether, you just won a logo new reader.
    What could you recommend about your publish that you simply made some days
    in the past? Any certain?

  17. Howdy! This is my 1st comment here so I just wanted to give a quick shout out
    and tell you I genuinely enjoy reading through your blog
    posts. Can you recommend any other blogs/websites/forums that go over the same subjects?
    Thank you so much!

  18. Pretty component of content. I just stumbled upon your site and in accession capital to assert that I acquire in fact enjoyed account your weblog posts.
    Any way I will be subscribing on your feeds or even I fulfillment you
    access persistently quickly.

  19. Have you ever thought about publishing an e-book or guest authoring on other
    sites? I have a blog based upon on the same information you discuss
    and would love to have you share some stories/information. I know my audience would enjoy your
    work. If you’re even remotely interested, feel free to send me an e-mail.

  20. A country is what the countrymen make it and countrymen of Bhutan are the most peace loving beings one can ever come across thus making every
    tourist feel welcome in their land. There are several destinations in Turkey,
    which are attractive, surprising and beautiful. Seasons in India The country has four chief climatic seasons – winters, summers, spring
    and autumn.

  21. I would like to thank you for the efforts you’ve put in penning this blog.
    I really hope to see the same high-grade blog posts from
    you later on as well. In fact, your creative writing abilities has inspired me
    to get my own, personal site now ;)

  22. HGH is approved by the Federal Drug Administration to treat advancement complications in youngsters and substance deficiencies
    in older individuals. An HGH shot is equipped with genuine somatotropin. Taking HGH medications possesses
    its own variety effects. page on best places attain hgh online Also if you
    desire an awesome hosting company please browse Because of
    this HGH treatments to some extent riskier than other
    HGH units available today like Sytropin HGH and GenF20 HGH.
    torso fit for Intramuscular libido injections are a lot
    good value in comparison with substantial androgenic hormone or testosterone gels
    or creams. logically original imagination sanctioned the man to investigate developing many other aspects of There can nonetheless be adverse effects, though; sufferers report
    an assortment of side effects, from inflammation and pain in the neck in bones and
    structure to really serious problems with lots
    of internal organs, such as the mind as well the liver.
    HGH manufactured by way of a quite cutting-edge methods given the name
    arrival genetical engineering. The result ended up being put into men and women that suffered from a HGH
    deficit. HGH used for a variety of things like in youngsters who will be HGH lacking.