Hacker News new | ask | show | jobs
by pjmlp 1334 days ago
Doesn't seem to hinder JavaScript runtimes.
3 comments

Hasn't Microsoft experimented with disabling the JIT for security reasons?[1] Doesn't have much relevance for Python at the moment, but I'm just mentioning it to underline that a modern JIT can be very complex thing and keeping it simple for 3.11 seems like a very reasonable requirement.

[1] Random google result as source: https://www.cyclonis.com/microsoft-edge-tests-disabling-java...

That isn't what is being discussed here, every JIT has a potential for eventually generating code patterns susceptible of exploits.
JavaScript has multiple companies with valuations measured in billions of USD competing. Optimizing JavaScript is just as hard but they can throw massive development teams at the problem. Python isn’t without resources but the level of scale is dramatically different.
> JavaScript has multiple companies with valuations measured in billions of USD competing.

A couple of them have valuations in the trillions of USD, actually.

Yeah, I thought about that when I was writing that but didn’t want to get into debates about what fraction of those resources they put into web stuff. Even if you ignore the big ones however, Mozilla is just web stuff and they’re still much bigger than the core Python team.

(Mozilla does support a ton of OSS, too, so read that as everyone else needing to step up rather than an attack on them)

Google does Tensorflow and V8.
Exactly: V8 benefits almost everyone using JavaScript, TF doesn’t benefit anyone not doing ML with that stack.

All I’m saying is that asking why JS performs faster than Python in some cases is less about the languages and more what you could do with hundreds of engineers working for years. If the stars had aligned differently and that effort had gone into Python (or Ruby, etc.) I’d expect a similar delta.

Because those investing into machine learning frameworks in Python rather spend their resources rewriting their libraries in C, C++ and Fortran while calling it "Python".
Python's ease of calling C libraries is both the blessing and a curse.

My opinion is that it's mostly a curse, since you are hampering the language's evolution and growth for a mere temporary benefit.

Not to mention the horror of distributing compiled libraries, which is one of the biggest reasons why packaging in Python is still such a nightmare.

Making CPython faster by getting rid of the GIL will do wonders for this language and it's community. It will make it much more portable, too. Think of Java-level portability, but in a much nicer package.

Sure, my point was just that the number of corporate investment in the core Python language is smaller. Investing in an ML framework isn’t a bad thing but it doesn’t support anyone working on the core language the way Google, Apple, Microsoft, Samsung, etc. contribute directly to Chromium/WebKit development.
Some of those companies overlap both ecosystems.
JavaScript doesn’t have a C API, that makes all the difference
what about NAPI? Or deno/buns JITed api?

I’ve heard this “no C API” thing echoed by a couple people and it’s baffling. Do folks really think three major JS engines all written in C++ wouldn’t have an interface to interact with C?

The problem is evolving the interpreter in a way that doesn't break bazillions of third party bindings -- Win32, OpenGL, Fortran for NumPy/Pandas, databases, GPUs, every C and C++ library ever, etc.

Python's C API exposes ref counting and the GIL. It's also very large

JS doesn't have that problem -- more code is written in pure JS, there are no C/C++ bindings in the browser.

There are C/C++ bindings in node.js for v8, but as far as I know they are discouraged and not used very much. The bindings are more "first party" in node.js than third party.

They have issues, but not the same ones as CPython, because the API is very different

JS VMs must be re-entrant because they're embedded in browsers. That was never the case for CPython

> as far as I know they are discouraged

Fwiw, this a fully stable and well documented API. It’s not even v8 exclusive, Bun cloned it for WebKit.

https://nodejs.org/api/n-api.html

The only C code JavaScript needs to interact with is 100% under the control of the browser implementing that JavaScript engine.

JavaScript doesn't interact with random C libraries that the user might have, like Python does.

This is unfortunately a bit misinformed. You are thinking of a specific JavaScript implementation (browsers). The language has heavy adoption in the native space. Check out Node.js!

JavaScript does interact with random C libraries :)

Yep, although for a very, very long time that wasn't the case.
Well, that changed over a decade ago