[erlang-questions] node.js vs erlang
Ivan Carmenates García
co7eb@REDACTED
Mon Jun 16 18:21:33 CEST 2014
Hi Joe,
I did try nodejs some time ago and I can tell from that experience that regards to development performance and confortable programming, nodejs is very nice, it is very intelligent way to program, it is faster too, but I have to tell you this, nodejs as a program language is very close or even more nicely than Erlang, but as a technology it is the biggest crap I ever taste, sorry about that, everything there explode and you have no control at all of the explodes, if the stack ran out; and it does quickly and easily, it just ran out without any possible solution and the system goes down inevitably, I came out to think that you cannot program a serious thing over that! Despite of that simple fact, all other is fine, nicely coding programming I think.
Best regards,
Ivan.
De: erlang-questions-bounces@REDACTED [mailto:erlang-questions-bounces@REDACTED] En nombre de Joe Armstrong
Enviado el: lunes, 16 de junio de 2014 10:22 a.m.
Para: Erlang
Asunto: [erlang-questions] node.js vs erlang
I'm trying to compare node.js with erlang. I'm a total node.js novice BTW - but I've written some JS.
Program 1 is just fibonacci - I want a web server to compute fib(N)
So requesting http://127.0.0.1:8124/fib?n=2 should compute and return fib(2)
My node.js attempt crashes
Here's the code in fib.js
--- fib.js
var http = require('http');
var url = require('url');
function fib(n) {
if (n < 2) {
return 1;
} else {
return fib(n - 2) + fib(n - 1);
}
}
http.createServer(function (req, res) {
var q = url.parse(req.url, true).query;
var n = q.n;
var result = fib(n);
console.log('fib('+ n + ')= '+result);
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end(result.toString());
}).listen(8124, "127.0.0.1");
console.log('Server running at http://127.0.0.1:8124/');
-- end
-- now we run it
$ node fib.js
Server running at http://127.0.0.1:8124/
fib(2)= 2
/home/ejoearm/Dropbox/experiments/hello_world/fib.js:5
function fib(n) {
^
RangeError: Maximum call stack size exceeded
fib(2) has run out of stack space????
$ node --version
v0.8.21
Any ideas what I'm doing wrong
Cheers
/Joe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20140616/b63b5159/attachment.htm>
More information about the erlang-questions
mailing list