September 11, 2014

Future of JS – As Discussed in Barcelona

This past May the JavaScript community gathered at the FutureJS conference in Barcelona, Spain. After a few years of semi-stagnation JavaScript has been seeing renewed interest amongst developers. With browsers approaching the status of operating systems for the Web, JS as the principal browser language is getting a lot more attention.

FutureJS addressed contemporary issues of JS development. Speakers included Jeremy Ashkenas – creator of CoffeeScript language, Reginald Braithwaite – author of the book JavaScript Allongé, Patrick Dubroy – Google Chrome engineer, guys from Facebook and others.

I was keen to get a “vision of JS’s future” directly from the people who call the shots. And it’s always helpful to step away from  everyday work and broaden one’s understanding the current state of JS and Web technologies.

The event was well-executed with balanced time for talks and coffee breaks. Evening meetups in hip bars and, during the day, long lunches (yes, it’s Spain and they take their siestas seriously) provided ample opportunities for informal communication amongst participants, organizers and speakers, including a great wrap-up party in one of the best night clubs in Barcelona.

Overall there were fifteen talks over two conference days. Some were dedicated to the JavaScript language itself: its history and possible future evolution, including the newest features of the just-emerging ES6 standard. Summing up the highlights for me:

Reginald Braithwaite on Functional Programming and OOP

Reginald’s talk emphasized JS’s inherent minimalism. The language doesn’t contain ready functional constructs or concepts and doesn’t force us to use a functional approach, but has enough tools for developers to code in a functional style if they prefer (functions as first-class entities). The same with OOP – JS doesn’t support all the concepts of classical OOP, but Reginald showed how we can emulate them using objects and prototypal inheritance.

Reginald also explained the idea of creating modular programs based on functions, thereby making code more reliable and reusable. According to this approach a program consists of two groups of functions: ones that implement business logic, main building blocks of an application; and service functions (composers, transformers) – general-purpose routines applied to the business logic blocks or to another service functions (they are going to be the same for different applications). For this approach to be successfully implemented the business logic functions have to be properly isolated and encapsulated.

Jeremy Ashkenas on Using JS in Commercial Projects

Jeremy, author of the CoffeeScript language, the Backbone.js JavaScript framework, and the Underscore.js JavaScript library described lessons learned using JavaScript in big commercial projects. He listed the main evils of JS: incorrect polyfill implementations, prototypes hell, different types of functions, scoping of var and others. Also Jeremy explained how CoffeeScript allows developers to avoid all those issues. And CoffeeScript being very similar to JS (in syntax and main concepts) makes it a relatively easy step towards more reliable, intuitive and comfortable programming (the caveat being the additional step of compilation).

Patrick Dubroy on ES6

Patrick toured us through its new features with an emphasis on how to use all these goodies just now when most browsers don’t fully support them. While such features as new methods of API can be easily polyfilled, the new language syntax and constructions require more cunning approaches. Enter the compiler Traceur. It takes code containing new ES6 features and transforms it to ES5 (or even ES3) compatible code. Patrick also demonstrated, through examples, exactly how transformations from ES6 to ES5 are done, from  elementary ones like the => (lambda) operator to more complex stuff like generators.

Jaume Sanchez on the new Web Audio API

Jaume explained its main idea and constituent concepts. Web Audio (http://www.w3.org/TR/webaudio) enables the mixing, processing, and filtering tasks that are found in modern desktop audio production applications. The model of Audio Nodes – audio processing nodes connected into the processing net (or graph) – is the key concept of the Web Audio API.

Martin Naumann on Web Components 

Martin described the use of Web components to build modular Web applications. The coolest thing about Web components is that developers no longer need specialized frameworks and tools (like angular directives) or components built with other languages and technologies (for instance, Java applets) to create reusable, well-isolated, reliable widgets for Web applications. Standardized technologies like Shadow DOM and custom HTML elements can be used instead.

Pete Hunt on the Virtual DOM

Peter presented the virtual DOM as an alternative approach of organizing data binding in situations where current approaches were not ideal from a performance perspective. The classical implementation of data binding is based on the key/value collections observation (Ember, Knockout). The main competitor of this approach is dirty checking (Angular). The virtual DOM bumps performance while working effectively with the data binding update history: the current state of bound UI elements is determined as a collection of changesets applied to their initial state.

Matthew Podwysocki on Event-based Programming

In Matthew’s memorable talk on reactive JavaScript programming he explained the idea of streaming and event-based programming using FRP (Functional reactive programming) and RXJS. He described the main principles of reactive programming: observable and observers, query operations and schedulers. Through vivid examples Matthew demonstrated how RX (reactive extensions) works in practice. The API for reactive programming in JavaScript is offered in the RXJS library. The idea of reactive programming is not new (I first came across it two years ago when I worked with MS .NET technologies), but there are interesting trends in its development, like using it in conjunction with JS generators (ES6).

All in all, attending the FutureJS conference gave me a clearer understanding of which aspects of JS and Web programming I should learn in depth and start using in real life. High on my list is functional programming implemented in languages other than JavaScript – Haskell, Scala, Closure.

I came away feeling that the future of JS is filled with promise, excited to get back to work!