JSConf Asia 2015 Updates

Last week I was lucky enough to make it to the annual JSConf Asia event in Singapore. The conference saw a broad range of both local JavaScript developers as well as international attendees coming from the Asia-Pacific region and beyond. The conference, which was part of the broader DevFest Asia event, was focused towards showcasing some of the newest technological offerings based around the JavaScript language and also spreading knowledge throughout the community to assist both short and long term JS developers in producing efficient and architecturally sound JS apps.

A focal point of the talks was the emergence of the EMCA 2015 (ES6) standard and the increasing prevalence of Node.JS as an efficient environment for developing and hosting modern cross-platform apps. The strong technical focus was fantastically complemented by a collection of talks discussing more creative uses for JavaScript centered round Audio-Visual projects.

Alexandre Strzelewicz’s presentation on the Process Manager 2 (PM2) open source project gave listeners on day one a new tool to assist in the management and hosting of enterprise-level Node.JS applications. This tool enables an administrator to configure load balancing and resource optimization in production environments, something offered by very few existing products available today.

The project, which was first released in June 2013, has a substantial GitHub following and an extensive list of contributors. Alex, one of the primary contributors, explained how the framework can ensure concurrent use of all of the CPUs of the underlying machine hosting the Node.JS app. This dramatically increases the processing power offered by the hosting machine. He went on to explain that one limitation of running the machine in this “cluster mode” is that the web application must be stateless, a common restriction with the increasing adaptation of web app deployments to cloud-based environments.

Stateless server mode dictates that a developer cannot reliably store client related data within the server process for longer than the duration of a web request. The issue is that when multiple processors are available, the process which handles a request from a user the first time may not be the same process that handles subsequent requests from the same user. The typical solution to this restriction is to store user-related data within a persistence layer on the server i.e. a database. Each request to the server will be accompanied by a user identifier and this identifier will then be used to retrieve that user’s information from the persistence layer, per request.

This solution is a fundamental concept in the RESTful architecture style and also provides the added bonus of loosening the coupling between the client and server – a well known good practice in most coding scenarios. However, the new web sockets protocol, which developers often use to enable bidirectional communication between client and server, is a stateful protocol out-of-the-box. This can add another degree of complexity when working under a stateless server configuration. That being said, the solution presented for introducing statelessness to standard HTTP requests can also be used by web sockets when using a command/response pattern.

Alex went on to explain other advantages of running a Node.JS application on the PM2 framework. These include the ability to configure Watch & Restart mode, this instructs the server to restart whenever it notices a change to a file located within the application.

Following the introduction, Mathieu began a live coding session. The starting point was a blank canvas consisting of an HTML page and an underlying JavaScript file. From here a timer was added which would sequentially call a block of code to update the content in the visual display. Within this block of code, Mathieu added a script to generate a horizontal line spanning around 200 pixels from the center on the view. The code was updated to cause this line to rotate and waver continuously. Then, more code was added to have additional lines break off from the original and proceed to fly outwards from the page center and eventually off the page.Day two kicked off with Mathieu Henri’s crowd-pleasing talk on creative coding and the demoscene. Using only JavaScript and a splash of Geometry and Trigonometry, coders can express their artistic talent by creating small self-contained scripts which render Audio-Visual displays. Mathieu started off with an introduction to the computer art subculture, having not heard of it before, it was enlightening to hear that art could be fused with coding so elegantly.

At this point, the visual display portrayed a flowing set of vine-like lines which in itself looked fascinating. Mathieu then proceeded to factor in other elements such as color, synthesized audio and even an animated gif of a little walking man who was placed above the initial vine. The end result was a captivating and charismatic audio-visual display which was even more impressive knowing it was crafted purely using JavaScript, CSS, and HTML. With a great showcase of the latest JS tech and a flawless level of organization, my first JSConf was educational, entertaining and inspiring. Thank you to all involved in making the event a great success!