Live data from Hacker News

Compiled JavaScript with NectarJS can be faster than Node.js and C

blog.seraum.com

1–10 of 30 posts

Re: Compiled JavaScript with NectarJS can be faster than Node.js and C

#3
gcc should just add a 'remove fibonnaci' optimisation pass, that just optimises this away entirely, and stop people using this benchmark.

This is one of the stupidest things I've ever heard of -- I'm going to be really mean now. They want me to use a compiler remotely, every time I want to recompile? So if their servers go down, or my internet connection goes down, I can't even run my compiler? And they have all the source code I've ever compiled?

And their evidence for their amazing super-awesome compiler is... optimising fibonnaci? Which their compiler (any compiler) could easily be detecting and special-casing? (I'm surprised more don't actually).

Re: Compiled JavaScript with NectarJS can be faster than Node.js and C

#4
That the C code is compiled with "gcc -O7" tells me just about everything I need to know about the soundness of these experiments. "-O3" and "-Ofast" are the highest optimisation levels, where "-Ofast" includes optimisations that break some standard-compliant programs (mostly -ffast-math).

Not to mention that comparing running times for a single run on an unspecified machine isn't "benchmarking".

Re: Compiled JavaScript with NectarJS can be faster than Node.js and C

#6

gcc should just add a 'remove fibonnaci' optimisation pass, that just optimises this away entirely, and stop people using this benchmark. This is one of the stupidest things I've ever heard of -- I'm going to be really mean now. They want me to use a compiler remotely, every time I want to recompile? So if their servers go down, or my internet connection goes down, I can't even run my compiler? And they have all the…

I came here to leave this comment and found you. Thanks.

This is not a benchmark on any regard. I thought we were past the stage of optimizing to specific microbenchmarks and then showcasing those.

If you're not going to show me real performance, at least show me Octane https://chromium.github.io/octane/ or something similar.

Finbonacci is utterly meaningless. Here, my language does Fibonacci(45) in 0.001 seconds, it compiles any output to the python code `print 1134903170`.

Re: Compiled JavaScript with NectarJS can be faster than Node.js and C

#7

gcc should just add a 'remove fibonnaci' optimisation pass, that just optimises this away entirely, and stop people using this benchmark. This is one of the stupidest things I've ever heard of -- I'm going to be really mean now. They want me to use a compiler remotely, every time I want to recompile? So if their servers go down, or my internet connection goes down, I can't even run my compiler? And they have all the…

gcc already optimises away loops like for (i = 0; i It wouldn't be too much of a stretch to detect and optimise away code that computes linearly recurrent sequences.

Re: Compiled JavaScript with NectarJS can be faster than Node.js and C

#8
So, it's just caching the return values of the method calls? I thought applying dynamic programming to fibonacci numbers was algo 101?

And what is -O7 level? Or, better, O7 lvl? :) Dynamic version of 45th fibonacci number (see http://www.geeksforgeeks.org/program-for-nth-fibonacci-numbe...) has the following runtime:

    ᐅ gcc -O2 fib.c -o fib && time ./fib
    1134903170
    ./fib  0.00s user 0.00s system 49% cpu 0.005 total

Re: Compiled JavaScript with NectarJS can be faster than Node.js and C

#9

Or, the code gets tail recursion optimized, turned into an iterative solution whilst the c code is recursive? If it was doing the same thing its unlikely to be faster.

Turning the recursive formulation of the Fibonacci function into an iterative loop is not easy for a compiler (unless you just program that specific pattern into it).

However, this "benchmark" is totally dominated by function call overhead, and it's quite conceivable that you can engineer your compiler to optimise for that case at the expense of others. You could do it quickly enough by unrolling the recursion a few times. This can cause the code to balloon in size in the general case, but not for this simple case.

It's also not particularly impressive to optimise a Javascript program that does not exhibit any complex behaviour. Again, you can just write a compiler that detects whether the Javascript program is straightforward, and if so, turns it into C or whatnot. Without being able to see what the compiler is doing, there is no way to know.

Also, "Compiler as a Service" may be a good idea for some cases (like farming an aggressively optimising but very slow compiler off to the cloud), but as the default case? No way.

Re: Compiled JavaScript with NectarJS can be faster than Node.js and C

#10
A compiler is software that IMHO really should not be SAAS. I don't want to pay monthly for everything in my life. Honestly, I want to pay a monthly fee for as little as possible. The worst part of it all is what happens if you go out of business and I've build an entire product with "NectarJS"? Can't I even compile the code then?

NodeJS already is fast, and if one really needs something faster maybe use something else than javascript?

Post reply on HN