CUSTOMISED
Expert-led training for your team
Dismiss
Javascript training | 5 Reasons to Learn Javascript

1 November 2017

Javascript training | 5 Reasons to Learn Javascript

Javascript - In transition or in confusion? A Developer's take on things...

JavaScript is in a time of rapid transition. In the recent past it was often thought of as a toy language, lacking the capabilities of its more "enterprise" cousins. This is no longer the case. A sudden interest in "tooling" has meant that JavaScript can be adapted to fit into your business. If you have a large distributed team, you can use TypeScript to gain strong typing, classes, interfaces, and IDE based IntelliSense and refactoring. If you have a small, agile startup, you can use ES2015 to add more functional features, fat arrow lambdas, modules, and consistent 'this'. 

 

Use a tool like Babel to compile your source code into regular old fashioned JavaScript (ES5), suitable for deploying in older browsers. Compilation happens automatically as you type, so each time you save a file, your code is compiled and the browser reloads. You might also have your unit tests run automatically. You don't need to use the same language across your organisation. You can mix TypeScript and ES6 in the same project.

 

* ES5 - Regular old JavaScript, supported everywhere.

* ES6 - New JavaScript. Supported by the evergreen browsers. It has many developer-friendly features such as the new lambda syntax.

* ES2015 - Edge JavaScript. Not widely supported yet, but you can still use it with tooling.

* TypeScript - JavaScript with optional classes, interfaces and strong typing. It looks like C#. Very popular with large organisations.

 

Tooling

 

Tooling is a massive deal in JavaScript. When we talk about tooling, we mean scripts that monitor our files and run whenever they are modified. Tooling allows you to do simple things like linting or minification, or more complicated things like transpiling TypeScript.

 

* Grunt - The original JavaScript toolchain. No longer widely used because the syntax was awkward, and chaining tasks together meant creating temporary files.

* Gulp - An in-memory streaming build process. Create pipes and push your files through them to transform them. It suffers from occasional stability problems.

* Browserify - A JavaScript module packer, rendered obsolete by Webpack.

* Webkit - The new hotness. Blazing fast, highly stable, with a large ecosystem. It will take a wide variety of input types and convert them into JavaScript.

* Babel - a tool for automatically converting (transpiling) newer versions of JavaScript into ES5. This usually happens as you type.

 

Switching from one toolchain to another is generally not an onerous process. They share many commonalities. A single competent developer can usually migrate a good size application from one stack to another in a couple of days.


The speed of change of JavaScript can be frustrating if you are picking a tool to give your organisation long term stability. An appropriate toolchain can help mitigate against these problems.

 

Frameworks

 

Coupled with this is an explosion in the number and diversity of frameworks available. We have transitioned from simple JQuery monoliths, via MVC, into component based frameworks, Flux architectures and reactive coding.

 

* Backbone - The granddaddy MV* framework. Very lightweight. Gives you Models, Views, Collections and Events to help you wire an app together. Views listen to models and redraw themselves.

* Angular - Google's last generation tool of choice. It's essentially a DOM parser that lets you write web applications in HTML. Incredibly low barrier to entry.

* Angular 2 - Not really related to Angular 1. It allows you to construct your app from a tree of web components. Data flows down the tree and events bubble up. Built with TypeScript and made by Google. It's very enterprise and quite complex.

* React/Flux - React is a blazingly fast DOM manipulation tool. Flux is a design pattern that uses an immutable data store (typically Redux) to control a React enabled DOM.

* Vue.JS - A new component-based framework that is far less complicated than Angular 2. It's currently in a hocky stick growth curve, and is definitely worth checking out.

* Aurelia.JS - Another new component based contender with a beautiful and stable API. 

* RXjs - Reactive extensions for JavaScript. More a library than a framework. It gives you observables that can fire in response to async events, and combined and manipulated in complex and interesting ways. Event-driven programming taken to the next level.

 

This is just a sample. There are many others. 

 

How to Deal with Legacy

 

Picking a framework can be daunting. Whatever you pick, it is almost guaranteed to be legacy in about five years. Fortunately, there are very few bad options now. All the major frameworks will give you an enjoyable development experience going forward. Provided you maintain your code and write decent unit tests, even a Backbone app will likely still be OK ten years from now.

 

I have worked with developers who are sill supporting old Backbone apps. If the code is maintained and kept clean and tidy, there really is no problem. Pick something you and your people are comfortable with. Don't let anyone touch it that you don't trust. Run your unit tests regularly (ideally, each time a file is saved). Employ linting, and consider TypeScript.

 

Server Side JavaScript

 

JavaScript has traditionally always lived on the browser, but server-side JavaScript is increasingly popular. NodeJS lets you create a simple script, or a full restful API. Node is often used as glue between other systems, helping them to communicate with one another.

 

Many developers, upon hearing about Node, think: "Yuck, why would I want more JavaScript?" In fact, JavaScript's event based architecture is very appropriate for the server. A network connection is just an event, and you write event handlers to deal with it. Treating a server as an event-handler has significant advantages at scale. Most traditional clients will spawn a new thread to handle each connection. This requires a lot of memory. Because JavaScript is single threaded and event-driven, dealing with a new network connection just means adding a new session_id to an array. A single server can deal with a huge number of simultaneous connections.

 

Coupled with this is MongoDB, a highly scalable distributed database and data analysis tool that has been deployed by organisations such as Sky, Cisco, O2, and Niantic (for Pokemon Go). Data is stored and retrieved as JSON. You can use the same data in the database, the server, and the front end. This means you write no wiring code, which can save a very significant amount of time.

 

Mobile and Desktop JavaScript

 

JavaScript has also found a place in the mobile sphere. HTML5 and hybrid apps are built out of JavaScript and CSS, and compiled into archives that can be distributed via the App store and Play store, just like regular apps. We compose an app using a toolkit like Ionic, then use PhoneGap to compile distributable, platform specific versions. Deep hardware integration is achieved using platform specific adapters. Most users are not aware that the app they are using is actually a web page. 

 

Similarly, we can also build desktop applications in JavaScript. Toolkits like Electron can compile our JavaScript, producing versions for Mac, Windows and Linux from a single codebase. The apps created are self-contained, and unlike Adobe Air, they do not require a runtime.

To sum up

JavaScript is everywhere. It is the most widely deployed language on the planet by an order of magnitude, and, perhaps surprisingly, it has become rather good. If we need specific language features we can add them in with tooling. TypeScript is popular, as is ES6 with Babel. 

Frameworks come and go, and rapidly become legacy. However, even legacy code can be good code, provided it is well maintained and tested.

In addition to our Angular 2 training course JBI provide a full range of Javascript and Front End courses to help keep your Developers right up to date.

 

For more more information about our range of courses: 

     - Python Training

     - Python for Data Scientists

     - Business Intelligence Courses

 

About the author: Craig Hartzel
Craig is a self-confessed geek who loves to play with and write about technology. Craig's especially interested in systems relating to e-commerce, automation, AI and Analytics.

CONTACT
+44 (0)20 8446 7555

[email protected]

SHARE

 

Copyright © 2024 JBI Training. All Rights Reserved.
JB International Training Ltd  -  Company Registration Number: 08458005
Registered Address: Wohl Enterprise Hub, 2B Redbourne Avenue, London, N3 2BS

Modern Slavery Statement & Corporate Policies | Terms & Conditions | Contact Us

POPULAR

Rust training course                                                                          React training course

Threat modelling training course   Python for data analysts training course

Power BI training course                                   Machine Learning training course

Spring Boot Microservices training course              Terraform training course

Kubernetes training course                                                            C++ training course

Power Automate training course                               Clean Code training course