Fullstack 2014 - conference report

The Fullstack conference saw Douglas Crockford giving an overview of ES6 and his views on how to use the new features to write better JavaScript and Jamund Ferguson made abstract syntax trees exciting.

Robert Rees

Published on Thursday, 19 February 2015

Computing   JavaScript   Programming  

A stack of fruit and American pancakes
A stack of fruit and American pancakes Photograph: flickr

Last year I got to attend the Fullstack conference that was conveniently located in Kings Place, the same building as the Guardian.

Fullstack?

A number of colleagues commented before we even went to the conference that the title was a complete misnomer. So let’s get that out of the way first.

The conference was programmed by a Node conference organiser and the talks reflected that perspective. Most of the talks had a small diversion into microservices or mentioned fullstack responsibility to justify their inclusion but really this conference was about JavaScript and Node.

However, organisers Skillsmatter have promised that next year’s conference will be focussed squarely on fullstack concerns rather than particular technologies. In the interests of disclosure, I have also been invited to be part of the organising committee so if that doesn’t happen then I will only have myself to blame.

Douglas Crockford on ES6

The conference opened with a keynote by Douglas Crockford talking about how the ES6 standard is going to change the way that JavaScript is developed.

In an interesting parallel with Java, ES6 adds to the language but does not deprecate anything – in fact, a lot of the features are actually syntactic sugar. While retaining backwards compatibility can be useful it brings with it the problem that all the old ways of doing things remain valid and need to be understood on top of the new ways.

One of the things I think it would be good to break backwards-compatibility on is the definition of variables. The new let form has more intuitive scoping rules that would rule out a certain type of programming error for people unfamiliar with JavaScript. These kind of breaking changes would make it easier for general programmers to adopt server-side JavaScript.

One of the most interesting sections of the talk was when Crockford talked about the way he has changed his programming style. He said that he has stopped using this and null. For the latter he prefers to use the value undefined which makes the code more explicit_._

He also mentioned that he no longer uses imperative loops but instead sequence functions like forEach, map and filter. These are easier to understand and less error-prone than imperative loops. However in other talks we also heard that performance is worse for these constructs because the virtual machines don’t optimise the loops. Hopefully that is something that can change in future.

The final aspect of the way he writes code is finding a way between object-oriented and prototype inheritance (the review of why JavaScript uses prototypal inheritance in the talk is quite interesting).

Objects always take objects (spec) in their constructors rather than individual arguments and return a frozen Object. Methods on the object are either declared directly or generated by taking the parent’s spec and repeating the process on another object, which returns methods that are bound into the returned scope.

While the example code makes use of ES6 constructs, this blog post not only describes the pattern better than I do but also translates it into ES5. The pattern feels a lot better than the class syntax sugar that is also available in ES6.

The FullStack videos require a login to view but here’s pretty much the same talk (JavaScript: the Better Parts) from Nordic.js which is available on YouTube.

Highlight talk: JavaScript and AST

Apart from the keynote, the big standout talk for me was by Jamund Ferguson on the subject of abstract syntax trees (AST).

All computer languages can be compiled into an abstract syntax tree, a kind of intermediate representation that is usually turned into the binary code . One advantage of using an AST is that the representation is a full-blown tree data structure and therefore can read and manipulated programmatically. Scala’s macro system, for example, takes advantage of exactly this kind of functionality.

I hadn’t been aware of all the interesting libraries there are for generating and manipulating the AST syntax for JavaScript. Jamund used the example of using them to create better linting for code.

Instead of having to match the code as strings against regular expressions, a checker can scan through the tree and apply rules to syntactically correct sections of the code such as functions, parameter names and arithmetic expressions.

Libraries mentioned included Esprima (GitHub), which, inevitably, has a few forks of interest: Espree (for ES6) and Facebook’s version which is used in the translation of React’s JSX. Both are more actively maintained than the original project.

For transformers (things that take an AST, change it and return a updated tree) Falafel and Recast were mentioned. Falafel seems to focus on making the transforms simple whereas Recast seems more ambitious but also more low-level with the examples showing a lot of low-level AST tweaking which implies a good understanding of the API. The Recast use-case of generating source maps looks pretty interesting.

Jamund’s talk stood out for me in that it was about something a little niche, something that I wasn’t aware of, that he was personally very enthusiastic about and while grounded in the practical example of his own use case also took the time to review the broader subject and its implications. A great conference talk.

Continue reading

Compile-to-JavaScript languages Android Subtle Prompt library