<div dir="ltr"><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Jun 17, 2014 at 12:10 PM, Greg Young <span dir="ltr"><<a href="mailto:gregoryyoung1@gmail.com" target="_blank">gregoryyoung1@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Can you really compare the two? :) </div></blockquote><div><br></div><div>Yes - there are many things we can measure. Performance, Latency, memory usage and so on.</div>
<div><br></div><div>Right now I'm measuring latency - </div><div><br></div><div>I set up a few thousand parallel processes which request fib(N) and measure the latency of the responses.</div><div><br></div><div>the results will be published when I understand them :-)</div>
<div><br></div><div>/Joe</div><div><br></div><div><br></div><div><br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_extra">
<br><br><div class="gmail_quote"><div><div class="h5">On Mon, Jun 16, 2014 at 5:55 PM, Juan Facorro <span dir="ltr"><<a href="mailto:juan.facorro@gmail.com" target="_blank">juan.facorro@gmail.com</a>></span> wrote:<br>

</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr">Hi Joe,<div><br></div><div>There's a semicolon missing after the declaration of fib(), which for some reason, causes the stack overflow. After adding it the error went away.</div>

<div><br></div><div>HTH,</div><div><br></div><div>J</div><div><br>On Monday, June 16, 2014 11:22:23 AM UTC-3, Joe Armstrong wrote:<blockquote class="gmail_quote" style="margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex">

<div dir="ltr"><div>I'm trying to compare node.js with erlang. I'm a total node.js novice BTW - but I've written some JS.</div><div><br></div><div>Program 1 is just fibonacci - I want a web server to compute fib(N)</div>


<div><br></div><div>So requesting <a href="http://127.0.0.1:8124/fib?n=2" target="_blank">http://127.0.0.1:8124/fib?n=2</a> should compute and return fib(2)</div><div><br></div><div>My node.js attempt crashes</div><div>Here's the code in fib.js</div>


<div><br></div><div>--- fib.js</div><div><br></div><div><div>var http = require('http');</div><div>var url  = require('url');</div><div><br></div><div>function fib(n) {</div><div>  if (n < 2) {</div><div>


    return 1;</div><div>  } else {</div><div>    return fib(n - 2) + fib(n - 1);</div><div>  }</div><div>}</div><div><br></div><div>http.createServer(function (req, res) {</div><div>    var q = url.parse(req.url, true).query;</div>


<div>    var n = q.n;</div><div>    var result = fib(n);</div><div>    console.log('fib('+ n + ')= '+result);</div><div>    res.writeHead(200, {'Content-Type': 'text/plain'});</div><div>    res.end(result.toString());</div>


<div>}).listen(8124, "127.0.0.1");</div><div><br></div><div>console.log('Server running at <a href="http://127.0.0.1:8124/'" target="_blank">http://127.0.0.1:8124/'</a>);</div></div><div><br></div><div>

-- end</div><div>
<br></div><div>-- now we run it</div><div><div><br></div><div>$ node fib.js</div><div>Server running at <a href="http://127.0.0.1:8124/" target="_blank">http://127.0.0.1:8124/</a></div><div>fib(2)= 2</div><div><br></div>

<div>/home/ejoearm/Dropbox/<u></u>experiments/hello_world/fib.<u></u>js:5</div>
<div>function fib(n) {</div><div>            ^</div><div>RangeError: Maximum call stack size exceeded</div></div><div><br></div><div>fib(2) has run out of stack space????</div><div><div><br></div><div>$ node --version</div>


<div>v0.8.21</div></div><div><br></div><div>Any ideas what I'm doing wrong</div><div><br></div><div>Cheers</div><div><br></div><div>/Joe</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div>


<div><br></div></div><span><font color="#888888">
</font></span></blockquote></div></div></div></div><span class="HOEnZb"><font color="#888888"><span><font color="#888888">

<p></p>

-- <br>
Remember to send a copy to erlang (dot) questions (at) erlang (dot) org when posting.<br>
--- <br>
You received this message because you are subscribed to the Google Groups "Erlang Programming" group.<br>
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="mailto:erlang-programming+unsubscribe@googlegroups.com" target="_blank">erlang-programming+unsubscribe@googlegroups.com</a>.<br>


To post to this group, send email to <a href="mailto:erlang-programming@googlegroups.com" target="_blank">erlang-programming@googlegroups.com</a>.<br>
Visit this group at <a href="http://groups.google.com/group/erlang-programming" target="_blank">http://groups.google.com/group/erlang-programming</a>.<br>
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank">https://groups.google.com/d/optout</a>.<br>
</font></span></font></span></blockquote></div><span class="HOEnZb"><font color="#888888"><br><br clear="all"><div><br></div>-- <br><div dir="ltr">Studying for the Turing test</div>
</font></span></div>
</blockquote></div><br></div></div>