"Vert.x is a lightweight, high performance application platform for the JVM that's designed for modern mobile, web, and enterprise applications..."
"What Makes Node.js Faster Than Java?"
http://strongloop.com/strongblog/node-js-is-faster-than-java/
- "Built almost twice as fast with fewer people
- Written in 33% fewer lines of code
- Constructed with 40% fewer files"
- Non-blocking I/O - every I/O call must take a callback, whether it is to retrieve information from disk, network or another process.
- Built-in support for the most important protocols (HTTP, DNS, TLS)
- Low-level. Do not remove functionality present at the POSIX layer. For example, support half-closed TCP connections.
- Stream everything; never force the buffering of data.
var vertx = require('vertx'); vertx.createHttpServer().requestHandler(function(req) {
var file = req.path() === '/' ? 'index.html' : req.path(); req.response.sendFile('webroot/' + file);
}).listen(8080)
public class Server extends Verticle {
public void start() {
vertx.createHttpServer()
.requestHandler(new Handler<HttpServerRequest>() {
public void handle(HttpServerRequest req) {
String file=req.path().equals("/")?"index.html":req.path();
req.response().sendFile("webroot/" + file);
}
})
.listen(8080);
}
}
vertx.createHttpServer().requestHandler { req ->
def file = req.uri == "/" ? "index.html" : req.uri
req.response.sendFile "webroot/$file"
}.listen(8080)
import vertx server = vertx.create_http_server() @server.request_handler def request_handler(req): file = "index.html" if req.uri == "/" else req.uri req.response.send_file("webroot/%s"%file)
server.listen(8080)
require "vertx"
Vertx::HttpServer.new.request_handler do |req|
file = req.uri == "/" ? "index.html" : req.uri
req.response.send_file "webroot/#{file}"
end.listen(8080)