Friday, 24 January 2014

Journey into JavaScript

This post is long overdue since I decided to get to grips with JavaScript at the beginning of last year but generally due to being busy at work and learning JavaScript I never got around to actually blogging about it.

Step back in time…

So its January 2013 and the current work I’m doing has a lot of existing JavaScript (JS), its a mature codebase so the work is more maintenance and extension rather than creating from scratch, so well within my existing skillset, but with interest in JS increasing I figure it would be a good idea to look deeper into the language.

Types of JavaScript

I know what you’re going to say “there is only one type of JS!” but bear with me a moment.

I decided that I was going to learn more about JS but when looking at how & where JS is used I categorised it as:

For me I wanted to focus on JS the language, in my mind once I understand the language itself using it either on the client or server should be just a case of understanding the functionality and limitations of each environment.

Where to begin

So with my focus on the language I looked around for resources to help me learn looking for books, videos & blogs that would help me.

Books

JavaScript: The Good Parts

This is the book that anybody who starts to work with JS is told to read, the book focus’ on what Douglas Crockford considers the good bits of the language, to help you avoid the parts of JS that people frequently complain about causing them problems.

Its only after learning more about JS that I can see whilst this book is good it does limit you to using only part of the language, which if you’re a beginner is a really good but as you progress you can see does tend to limit your use of the language as a whole.

JavaScript Enlightenment

From reading reviews about this book it seems to be like marmite, you either like it or hate.

The book focus’ on objects in JS, which you soon learn are the building blocks of the language and reading it after the good parts I found it helped me understand more about the mechanics of the language lifting the lid on how the runtime works when executing your code.

JavaScript: The Definitive Guide

There is a photo that I’ve seen several times that shows this book side by side with the good parts trying to say that the good parts are only a tiny part of the language.

This book is so much larger as it really does go into the details of exactly how the language works, if you want to understand why “false” == true this explains it.

Videos

In the end I primarily focused on pluralsight for training videos, partly because I had some free monthly passes, but also found them very easy to watch and learn from.

JavaScript for C# Developers

With C# being primary language I found this course excellent. It focus’ on JS the language and introduces you to it using familiar concepts from C# and shows you them in JS.

JavaScript Fundamentals

This course is really aimed at people completely new to JS so if you have some experience probably not the course for you but does have some good information for starting to test JS.

Structuring JavaScript Code

C# has structs, classes, assemblies and you can use them to structure your code but other than an object what is there in JS? This course shows you different ways you can structure your code such as closures, module, etc

I found the course really useful as it provided me with knowledge on some key concepts in JS and gave me options on how I could structure the code I was working with day to day.

JavaScript Design Patterns

This course isn’t related to the book of the same name, in fact it doesn’t deal with patterns like Singleton, Iterator, Facade, etc. instead it focus’ on some patterns of using JS usage such as promises.

Whilst the information in the course may not be immediately applicable in your development its good to have in your ‘toolbox’ so to speak.

Blogs & sites

I’ve followed many blogs but have a list of sites with various JS articles as long as my arm, here’s my list of the top few:

JavaScript promises – the best article I’ve come across describing promises in JS, what they are and how to use them

Idiomatic JavaScript – GitHub repo with guidance on how best to write what the various contributors believe is idiomatic JS.

What have I learnt

For me learning more about the language has helped me to understand the things that people often point to in JS and say its crazy behaviour.

So JS the language is based on objects and you can perform functional-like programming with it, but it isn’t either an object oriented or strictly functional language.

As with any language JS has its strengths and weaknesses and to get the most out of it you need to learn to leverage its strengths and how to mitigate some of the weaknesses often through best practices, patterns, etc.

I’m not going to list everything that I’ve picked up, that would be a long and probably tedious post, but I did make a few notes during the year (though not enough) which I posted on my tumblr. This year I’m trying to blog more so anything new and interesting I come across I’m hoping to post here.

Whilst it may seem that I didn’t cover a lot of ground I’ve left out all the stuff I did around Knockout.js and Angular.js which I was also learnt about during the year (perhaps more blog posts).

What’s next

Unsurprisingly my plan is to continue learning, and although I read a lot last year I didn’t practice outside of work so as well as reading books & blogs I’m going to be building applications to develop my “muscle memory” where JS is concerned. My plan is to not only practice the JS language but to work with other JS libraries such as Knockout.js, Angular.js, etc and to then extend the apps to the server and use Node.js as well.

I am also looking to attend JavaScript, and JavaScript related, conferences and user groups to meet other JavaScript developers and hopefully be able to learn from them as well.

Summary

Overall I have to say that I’m liking working with JavaScript and I’m looking forward to doing more with the language and will be interested to see what I can build during this year, but I’ll blog details about that another day