by nodesocket · 9y ago · 0 comments
http://benchmarksgame.alioth.debian.org/u64q/compare.php?lan...
Why would it be stunning that a programming language compiled to assembler can beat a broken-by-design interpreted language which doesn't even have integers or arrays? The stunning part is that the people behind node.js have managed to get that much performance.
I assure you that JavaScript is an interpreted language, and it does not have arrays or integers. This is not a harsh statement but a factual one.
(Not sure if you already knew this, but if so, you're not being factual, you're being selectively pedantic to make something sound worse than it is. Lack of ints or arrays isn't a big factor in JS performance for non-pathological cases.)
(edit: reasons for downvotes are appreciated!)
If you don't enjoy JS, it's because you haven't taken the time to learn what's great about it and have gotten hung up on the stupid things other people do with it or you're copying their mistakes.
It looks like the JS version is using the built in runtime's regex engine.
I don't know exactly why (maybe differences or missing features in go's regex) but the go version is actually using the c FFI to call pcre.h, and without profiling it I'd guess a huge hit is that alone.
Don't guess. Look at the measurements. Look at the source code. That Go PCRE program is faster than --
http://benchmarksgame.alioth.debian.org/u64q/program.php?tes...
Maybe faster still to use some of the techniques from this other Go PCRE program --
http://benchmarksgame.alioth.debian.org/u64q/program.php?tes...