2013.0321 - Experience with nodejs and why Tcl is better

The node.js javascript interpreter is probably really great. It has the newly-discovered event-driven programming model built in!

At SAO we have been delivering image display and analysis programs to the astronomical community for over 35 years (since the dawn of computing). Maybe a little late in coming to the Web, but we are now prototyping a version of our code as a distributed image display running in the browser with a back end helper. The first beta of the back end is written in nodejs.

Here is my experience in installing it on my CentOS5.5 vps.


Node.js is not a simple install on Hopper:

Get the binary:

wget http://nodejs.org/dist/v0.10.0/node-v0.10.0-linux-x64.tar.gz
cd node-v0.10.0-linux-x64
cp bin/* ~/bin
cp -r lib/* ~/lib/.

-bash-3.2$ node js9Helper.js
node: /lib64/libc.so.6: version `GLIBC_2.7' not found (required by node)

My vps "hopper" is running CentOS 5.5. This means that there is no pre-built binary for nodejs. To build node you have to have python2.7, CentOS has python 2.4. I have to install python. Python 2.7 does not come with bzip2 source, but node.js is using the bzip2 source from the python tree!!. I have to install bzip2 source.

This is all explained here .

People just don't get the issues with buy-in.

Why is building node dependent on python at all?

Downloading the node source I see that ./configure for node is written in Python, and depends on crappy "conditional assignment" syntax nonsense because "of course every one has python 2.7".

./configure --prefix=/home/john   
  File "./configure", line 433
    fpu = 'vfpv3' if armv7 else 'vfpv2'
SyntaxError: invalid syntax

I was able to build and install node by explicitly running the node.js ./configure in with python2.7, which of course I do have installed, but for a completely different service running on hopper and not the default python:

wget http://nodejs.org/dist/v0.10.0/node-v0.10.0.tar.gz
python2.7 ./configure --prefix=/home/john
make install

But now I know way more than I want to. I also know that the node.js developers have made no attempt to be portable. They likely don't even know what that means. In the end its not that it's hard to get everything just so for node.js. It's that every little dependency is just one more thing. Every install has just one more thing.

Maybe you could rewrite the helper in Tcl and deliver it as a starkit? (Sorry, just couldn't help myself).



DKF: Be nice! Even if you feel like the other guys are being nasty and thoughtless, be nice anyway. It works better.

Tcl uses autoconf to do bootstrapping because that depends on the actual minimum that you can expect to be present. It's a shame that we can't use one of the Tcl-based configuration tools, but we assume that we're starting from scratch for good reason. And a starkit isn't exactly the easiest in one key sense: you can't deliver the same thing for all platforms unless you require a separate installation of tclkit, which defeats the point of a no-dependencies configure/install. A starpack is better, except then you need to supply a different version for each platform. It's all a trade-off.

AMG: Getting off topic, I know, but still I want to ask: Is anyone looking into using a mini-Tcl (e.g. Jim) in place of autoconf? It shouldn't be too hard to write a shell script that compiles a Tcl-like interpreter in a single portable C file, then runs the resulting binary on the configuration and build scripts in order to produce the full Tcl executable.

bll 2013-11-3: Looks like this is answered here: autosetup. I updated the list of alternatives.

JBR - Sorry if someone thought that I was being nasty. I'm usually very nice, even thoughtful. I frustrate easily. I vent frequently. This is an anecdotal way of venting about projects that thoughtlessly pile on unnecessary dependencies. I think that my screed makes a nice story about the reality of installing things. In the end nodejs isn't difficult to install, it just isn't trivial.

Its also an indirect way of expressing my thanks to the Tcl team.

Thank you for Tcl (there I said it).

RS 2013-11-01 - Why not have both? ;^) As a holiday hack, I extended tcl.js 0.4 with the following lines at the end, so it can run in a console with nodejs:

var itp = new TclInterp();

var readline = require('readline');
var rl = readline.createInterface(process.stdin, process.stdout);
rl.setPrompt('% ');
rl.on('line', function(line) {
    try {
        var res = itp.eval(line.trim());
    } catch(e) {res = e;}
    if(res.toString() != '') console.log(res.toString());

Example session:

[email protected]:~$ nodejs tcl04.js 
% proc f {a b} {expr $a*$b}
% f 6 7
% info commands
and append break continue clock eval exit expr for foreach gets if incr info jseval lappend lindex list llength lrange lset lsort not or puts proc regexp rename return set source string time unset while native + - * / % < > = == != f
% info procs