6 ms·
> They seem to invest a lot in JavaScript which is not what I’d call a performant language JavaScript (V8 at least) is extremely performant, near native code p
by pyentropy 5y ago
> They seem to invest a lot in JavaScript which is not what I’d call a performant language
JavaScript (V8 at least) is extremely performant, near native code performance. Considering how dynamic it is, it's not an easy feat but Google, Apple and Mozilla work a lot on it.
Here's a benchmark where JS is 50x faster than Python: https://github.com/kostya/benchmarks https://github.com/kostya/benchmarks
Note that PyPy does much better.
- imachine1980_ 5y agopypy in general works better, sometimes equal, sometime slower, and sometimes doesn't(library support is not 100%). the problem whit javascript is mainly no type check in compile time making lot more mistakes if you use a compile langues, that why a lot of big project now days use typescript, and force to use types
- igouy 5y agoAnd some where JS is not 50x faster than Python: https://benchmarksgame-team.pages.debian.net/benchmarksgame/fastest/python.html https://benchmarksgame-team.pages.debian.net/benchmarksgame/...
- Mikeb85 5y agoDid you look at the source of the programs where Python was competitive? Python basically using C types and GMP to write C in Python...
- igouy 5y ago> Did you look at the source of the programs… Did you? :-) That Node pidigits program also uses GMP. Besides those 2, did you notice other JS programs not 50x faster than the corresponding Python programs ?
- Mikeb85 5y agoI never made the assertion JS is 50x faster... But everyone knows it is significantly faster than Python. Probably at least a few times for pure JS vs. pure Python programs. Not that it matters, Python is basically glue to run mostly C and C++ programs.
- igouy 5y agoGiven that you say "basically glue" why the previous surprise about "basically using C types and GMP" ?
- ithrow 5y agoThere are 2 programs there that are 50x faster in JS, other 40x, other 35x, other 16x, a couple 7x, not sure what are you arguing about.
- igouy 5y agoThe importance of looking at more than one measurement.
- CraigJPerry 5y agoI suspect that site is some kind of in-joke. E.g. read the regex-redux example in say c#, now look at the go version, now the python version… It’s not really what you’d expect for a site called computer language benchmarks game. Each example just calls out to a very fast c library (pcre2) to perform the heavy lifting regardless of which language is being “benchmarked”. Seems a pretty pointless site. The other examples have similar nonsense.
- igouy 5y ago> Each example just calls out to a very fast c library… No. https://benchmarksgame-team.pages.debian.net/benchmarksgame/program/regexredux-python3-1.html https://benchmarksgame-team.pages.debian.net/benchmarksgame/...
- makapuf 5y agofrom re import sub, findall That's where pcre2 is called (or a finely tuned regex c lib)
- igouy 5y agore is an ordinary standard Python library — https://docs.python.org/3/library/re.html https://docs.python.org/3/library/re.html pcre2 is not — https://benchmarksgame-team.pages.debian.net/benchmarksgame/program/regexredux-python3-2.html https://benchmarksgame-team.pages.debian.net/benchmarksgame/...
- makapuf 5y agore depends ultimately of this c file https://github.com/python/cpython/blob/main/Modules/_sre.c https://github.com/python/cpython/blob/main/Modules/_sre.c
- igouy 5y agoAnd? CPython is implemented in C. Here's some of a comment from _operator.c "This module exports a set of functions implemented in C corresponding\n\ to the intrinsic operators of Python. For example, operator.add(x, y)\n\ is equivalent to the expression x+y." Why wouldn't you expect that CPython regex would "ultimately" be written in C?
- KronisLV 5y agoThose are some pretty nice synthetic benchmarks! However, if you'd like a look at a more real world scenario or two, have a look at the TechEmpower benchmarks as well. For example, here are filters for both JS and Python: https://www.techempower.com/benchmarks/#section=data-r20&hw=ph&test=fortune&l=zijz7j-sf https://www.techempower.com/benchmarks/#section=data-r20&hw=... Do note that for most of the "realistic" stacks out there, you'd probably want to filter out all of the micro or no framework approaches, to compare something like Express and Koa against Django and Flask, like in the following link: https://www.techempower.com/benchmarks/#section=data-r20&hw=ph&test=fortune&l=zijz7j-sf&f=zhb2sn-zik0zj-zik0zj-zik0zj-zijunz-zik0zj-zik0zj-zik0zj-zik0zj-zik0zj-zik0zj-cn3 https://www.techempower.com/benchmarks/#section=data-r20&hw=... Here's the summary page with composite scores across all tests (though you might also want to filter by data storage solution, for example, MySQL): https://www.techempower.com/benchmarks/#section=data-r20&hw=ph&test=composite&l=zijz7j-sf&f=zhb2sn-zik0zj-zik0zj-zik0zj-zijunz-zik0zj-zik0zj-zik0zj-zik0zj-zik0zj-zik0zj-cn3 https://www.techempower.com/benchmarks/#section=data-r20&hw=... To summarize, the performance from the best to worst currently is: Composite scores: Koa (JS) > Express (JS) > Flask (Python) > Django (Python)
- igouy 5y agoThanks. > "more real world scenario" "realistic" I'm of the opinion that "Real programs may not be representative either". http://www.larcenists.org/Twobit/bmcrock.temp.html http://www.larcenists.org/Twobit/bmcrock.temp.html We have to show that they are or discover they are not.
- KronisLV 5y agoIn this context I believe that if a benchmark does exactly that your software would do in a production environment (shuffling JSON around and accessing a DB), then such a benchmark is probably a rough indicator of how well any stack would work, as long as the source code is also written in an idiomatic fashion. Of course, if you can, take benchmarks with a grain of salt and ideally do some prototyping and load testing.
- 5y ago