Node.kt

A web framework built in Kotlin inspired by Node.js

This project is maintained by jonninja

Node.kt is a web framework written in Kotlin inspired by many of the ideas in Node.JS and the Express framework.

Part of the appeal of Node.js is the ability to create web applications that are easy to understand and to do so extremely quickly. For example, here's a node.js 'Hello World' application:

var express = require('express'),
    app = express.createServer();
    app.get('/', function(req, res){
    res.send('Hello World');
    });
    app.listen(3000);

What makes this appealing isn't the few lines of code - a servlet based Hello World might not be that much more code. But the Express version is extremely easy to follow. There are no configuration files. There are no annotations. On larger scale applications, this might not matter much, but there is an enormous appeal to this kind of programming model, if the popularity of Node is any indication.

Here's a Node.kt version of the same application:

fun main(args: Array<String>) {
    val app = ExpressNetty()
    app.get("/", {
    res.send("Hello World")
    })
    app.listen(3000)
    }

So why not use Node.js? Well, despite some excellent ideas in its frameworks, Node.js is built on Javascript, and that imposes some serious limitations. First, Javascript is completely dynamic, which means no type-safety at compile time. I won't go through the entire debate - some prefer this - but my taste is for solid, development-time type checking. Second, Javascript is single-threaded, and imposes a callback-style of coding that, for some, can be quite confusing and difficult to parse. When working in Node.js, one seems to always be asking the question, 'Is this really making me more productive?'

Kotlin, on the other hand, is a more modern version of Java, built on the solid foundation of years of JVM engineering. While still in development, the combination of Kotlin and Node.kt makes web development far more pleasurable. Some of Java's verbosity is reduced, and as you can see in the above example, it's possible to express ideas with minimal code while still being very clear.

What's Included?

The Core framework

Based on Express, the framework provides the core functionality of Node.kt. This includes: