Paulo Lopes wrote in with the news that Vert.x 3.0 is out (License: Eclipse/Apache 2.0). Vert.x is a JVM-based toolkit for building applications that supports multiple languages, including JavaScript. It’s event driven and non-blocking, so it originally received interest from Node programmers, but it currently seems more popular in the Java community.

Here’s an example of a Vert.x web server:

vertx.createHttpServer()  
  .requestHandler(function (req) {
    req.response()
      .putHeader('content-type', 'text/plain')
      .end('Hello from Vert.x!');
}).listen(8080);

Version 3 has a new API designed specifically for building web applications. It’s called Vert.x-Web, and it supports routing, body and cookie parsing, authentication, static files, and it has an event bus bridge.

The routing API looks like many other server-side JavaScript web frameworks:

var route = router.route('POST', '/catalogue/products/:productype/:productid/');

route.handler(function(routingContext) {  
  var productType = routingContext.request().getParam('producttype');
  var productID = routingContext.request().getParam('productid');

  // Do something with them...
});

Vert.x 3 has support for MongoDB, Redis, and JDBC. It also supports reactive streams, and it has RxJava style APIs if you want to avoid using too many nested callbacks. The reactive API supports things like converting readable streams to observables (Rx.Observable.fromReadStream), and asynchronous future objects (Rx.observableFuture). Vert.x pushes reactive programming pretty hard, so if reactive programming is your thing then you might want to try it out.

Vert.x’s JavaScript engine is Oracle’s Nashorn. As far as I know, most of the ES6 features that you’d actually want (like classes) are not yet supported. Nashorn gets updated when the JDK gets updated, so it might be a while before several key ES6 features are ready. I couldn’t get Babel working with it, but it seems likely that it could be adapted to work. Someone in the Vert.x community may have already ported an ES6 transpiler.

If you want to read more about Vert.x 3 and Nashorn, I found a recent interview with Tim Fox, the creator of Vert.x, and there’s an official Nashorn blog.

Source: DailyJS