Maker Academy: JavaScript a new love-hate relationship

This week was our introduction to JavaScript (JS). JS is like Marmite, most people have a strong feeling about. Osnly in this case almost no one likes it. I have spent quite along time on this language before and thought this might be an easier week. That however would not be the makers way.


First I had never tested JS code before so development was fundamentally different right away. Jasmine is the testing framework we used and it tries its best to share format with rspec. It was never going to look as nice because of the parentheses and semi-colons that are needed in JS. I am going to admit now that I quite like javascript and I think all this brackets and explicit line end characters  mostly add to clarity and better explain what each bit of the code is.

This week I was most pleased with finally understanding what a closure is. I knew it was an important thing, there is a whole language called Clojure after all. In my own words it is the fact that functions remember the situation when they were created. They can use resources that were available at the time but no longer.

Closures cause problems with testing as there are private functions in the closure that are not visible to the rest of the program or testing framework. I found this good post explain one solution to this, and I have created a tested fizzbuzz kata to demonstrate this method. Despite the fact that extra code is added just to make the tests work I think it is quite an acceptable solution.

JavaScript is a prototypical language. It is by far and away the most popular prototypical language. For contrast, Ruby is object oriented and Clojure is functional. To make the most of any language means working with it and exploiting its core features. The prototype model still revolves around objects, to make a new object an existing object is cloned and functions can be added. These objects are also far more mutable than in class based languages, with closures being the only possible way of creating private methods. In JS a whole range of programming styles are possible. From very OOP to a very functional way of thinking. I found this great article on some of the many design patterns that can be used in JS.

So it turns out that JS is a bit of an ugly duckling. There are some bits that are unanimously considered awful. There are good reasons for some of this. It was rushed out under a unique set of constraints. The history of JavaScript itself is quite rich and tied to the history of the internet itself. I like quite a lot of the JS way of thinking and would agree that there are many good bits to it.

The rest of the week was spent immersed in the other front end technologies HTML and CSS. we weren’t taught more but the challenge was to recreate the look of twitter on a webpage. It was a more rewarding task than I thought when first given it but CSS can really test my patience.

So there are a million good resources on front end features far too many for me to share here apart from a few choice picks. 

CSS is far more of an art than science and this is a great selection of loading animations. and a wider set of examples here.

Wells its definitely cheating to link to top 20 lists so here is just one more.