node.js

node.js is a Javascript runtime based on an event-driven, non-blocking model, primarily used for server-side applications in Javascript.

It can call out to native Tcl using node-tcl.


A simple web-based hello world is done with a code as simple as shown on https://nodejs.org/en/about/

This runs on current version of node.js (at least 4.6.1, LTS).

This about page seems to be proud of a simple concurrent webserver code, something that Tcl can accomplish quite a very long time.

I think that a Tcl-equivalent code looks like this (where a simple counter is added):

proc accept {socket adr port} {
    fileevent $socket readable "echo $socket"
}

proc echo sock {
    incr ::count
    puts [gets $sock]  ;# consume and log input
    puts $sock "Hello world $::count"
    close $sock
}

set port 3000
socket -server accept $port
puts "Server running at http://127.0.0.1:$port/"
vwait forever