Learning Javascript: week 5 at Makers Academy

After four weeks of learning Ruby, web development and databases, we moved onto Javascript week; the sole purpose being to learn the language in the space of a few days. The week itself went by incredibly quickly, and we all felt by the end of it that we had raced through a number of techniques that are incredibly powerful, and that we could have spent months investigating each. Here I will briefly cover what we learned, as well as some realisations I have made in my ongoing study on object oriented design.

Challenge number one was to rewrite one of our previous Ruby challenges in Javascript. The task itself involved writing the basic logic of an airport that could land and take-off planes, with some additional constraints such as factoring in the weather when landing planes. Once we had got to grips with the basics of Javascript, this was not too difficult, although it did involve wrapping our heads around some of the key differences. In Ruby, my understanding of object instantiation had revolved around classes, and the ability to create instances of those classes. In Javascript, it seems, everything is nominally a function, including the analogues of the ‘classes’ we used in Ruby, and the methods contained in them. This was not too difficult to cope with. The context in which they are used makes clear the intention behind the functions, but it has been conceptually tricky to adjust to the change in language.

A similar example to this is the difference between public and private functions, and how they are expressed. It took me a little while to work out that there could be private functions at all in Javascript, as every example I had seen and tried had involved defining functions outside a class constructor. From what I currently understand, private functions are defined inside the constructor of a class, while public ones are defined outside it, and are usually defined on ‘prototypes’ of the class in question. This makes intuitive sense, and I can see a nice parallel between Ruby and Javascript in the defining of ‘class’ methods vs ‘instance’ methods, made clear by whether a function is defined on a class or a prototype.

After exploring some of these differences and similarities, the feeling I am left with is that there is still a huge amount to learn here. I started the week approaching Javascript with the intention of keeping in mind what I might want to do in Ruby, then finding the parallel in Javascript that would allow me to do the same thing. This is probably not the best method to employ. Ruby as a language is very user-friendly, and has equipped me with an understanding of object oriented design that is tied to a specific structure and terminology. When I try to rewrite my Ruby programs in Javascript, it would be a mistake to expect Javascript’s ontology to conform perfectly to that I am accustomed to using. The ‘classes’ I am accustomed to dealing with in Ruby are not the same thing as the ‘functions’ I have used in Javascript, though it might appear this way, and it would be wise now to build up an appreciation for each language as its own entity, whilst also understanding the implications this has for the depth and abstraction of my understanding of object oriented design.

In this vein, one of the concepts I have encountered in the last week is ‘spiral learning’, the teaching method based on the idea that students learn more about a certain subject each time they revisit the same topic. In this case, I learned a great deal about good programming practice in my first two weeks of my course, but I feel that revisiting these fundamental principles from the perspective of a new language is deepening and expanding my knowledge and skill-set, and will continue to do so in the weeks to come.

In the last two days of this week, we built a thermostat that managed the imaginary temperature of a house, whilst also pulling in the temperature from a range of potential cities, using the OpenWeatherMap API. It felt good to be given the freedom to style and customise this independently once we had set up the basics, and I enjoyed seeing the range of beautiful and creative designs that people came up with using their newfound jQuery skills. Hitting a blocker on AJAX taught me a lot about debugging by the end of the last day, the most important aspect being how to use the browser console to investigate the elements and data you are using. This helped us troubleshoot and fix our issues incredibly quickly, as well as helping us understand the nature and structure of the data we were dealing with.

As things currently stand, I am looking forward to getting started on my next weekend challenge (the bowling challenge - I hear it’s a toughie). I have spent a lot of time dancing around a range of new and old concepts this week, and feel like I need the time to solidly work at building something myself to show myself the degree to which I have absorbed these skills, and what I can do with them. I look forward to reflecting again on what I managed to achieve, and identifying the gaps in my knowledge I need to fill.