Live data from Hacker News

Bun has an open PR adding shared-memory threads to JavaScriptCore

github.com

111–120 of 330 posts

Re: Bun has an open PR adding shared-memory threads to JavaScriptCore

#111

Earlier quoted context omitted.

The solution to concurrency in JS is hard to understand and I would expect even hardened JSVM folks (me included) to be super confused by it

I think you're underselling your own level of intelligence Fil. If even you would be confused by an implementation (and you're the author of the concept) what chances do you think this PR has to actually work correctly?

Lots of tests

Re: Bun has an open PR adding shared-memory threads to JavaScriptCore

#112
post #46
post #17

I am shocked by how good and comprehensive the bun docs & ecosystem is. Its so well contained I never need to look outside its ecosystem for basic components. It's a true "Batteries Included" runtime.

Yet I rarely hear about it being used in production systems and replacing Node.js.

I run it in production for multiple systems.

Ready to migrate back to node once the slop version is out.

Re: Bun has an open PR adding shared-memory threads to JavaScriptCore

#114
post #93

Earlier quoted context omitted.

You still need a compiler for TSX, though. There's also a tiny bit of non-erasable Typescript (enums).

There’s a mode to pretend those features don’t exist and not allow them. Meaning it gets far simpler to just type elide rather than any actual compilation effort. I think this idea is getting more popular and it would be kinda nice if TS committed to not adding any more features like that.

TS has committed to not adding any more features like that. Features only get added when they reach a certain threshold on the TC39 standardisation track.

Re: Bun has an open PR adding shared-memory threads to JavaScriptCore

#115

Earlier quoted context omitted.

I think with ES6 and newer things really cleaned up and now we’re left with avoidable ugly parts, of which every language has. Before when you didn’t even have strict equality checking, for example, you were forced to know about implicit type casting. Getting on the same page with modules also helped a lot. Typescript directly in Node is great. Look mom, no build system!! I’m just hoping one day browsers will accept…

When did JS not have strict equality?

1995-1999. Strict equality was introduced in ES3 which was first released in December 1999.

https://www-archive.mozilla.org/js/language/e262-3.pdf

Re: Bun has an open PR adding shared-memory threads to JavaScriptCore

#116

I knew it was possible :-) https://webkit.org/blog/7846/concurrent-javascript-it-can-wo...

Years ago I did "multithreaded Javascript" by calling into Rhino (Javascript engine) from multiple threads. Granted, I converted Rhino from JVM to CLR, so it wasn't exactly a stable environment, but it did "work".

Re: Bun has an open PR adding shared-memory threads to JavaScriptCore

#117
post #75

I wonder if I'm the only one for whom the bun project vanished completely. In software code is only part of the package. Stability and trust are big part of it, too. And for me 1800 files change PRs created by Anthropic overseen by one person is not necessarily adding to the package. Even it that'd be the best code and design in the world, I won't use it. I don't trust it.

It looks like quite a lot of analysis went into the rewrite

https://bun.com/bun-unsafe-audit

If the tests pass, then why not accept the rewrite?

An interesting article of Prisma using the rewrite:

https://www.prisma.io/blog/bun-rust-rewrite-prisma-compute

Re: Bun has an open PR adding shared-memory threads to JavaScriptCore

#118
post #67
post #8

One of the biggest things preventing software like SQL DB's from being written in TypeScript is the lack of proper threading. I genuinely think you could write a competitively-performant multi-threaded DB in Bun + TS if you had shared-heap threads and fast atomics/locking primitives.

"I genuinely think you could write a competitively-performant multi-threaded DB in Bun + TS if you had shared-heap threads and fast atomics/locking primitives." Not likely. Databases that attain any significant use in the field end up getting optimized to the n'th degree because they're the bottleneck of the entire system of every system they get put into. Javascript runs on the "5-10x slower than C" language tier. P…

Something compiled to WASM still gives a fair amount of control over memory layout, something that AFAIK is not possible in JS without building effectively a new embedded language on top of an array (Emscripten being an existence proof that you can do more or less anything that way).

One place where an interpreter + JIT language could be interesting is if it were sufficiently safe to allow user code into the query execution engine, such that the JIT could optimize it all together.

Re: Bun has an open PR adding shared-memory threads to JavaScriptCore

#119

Earlier quoted context omitted.

Yeah I don’t get that either It’s a super successful language

I think with ES6 and newer things really cleaned up and now we’re left with avoidable ugly parts, of which every language has. Before when you didn’t even have strict equality checking, for example, you were forced to know about implicit type casting. Getting on the same page with modules also helped a lot. Typescript directly in Node is great. Look mom, no build system!! I’m just hoping one day browsers will accept…

> I’m just hoping one day browsers will accept TS the same way.

Wouldn't that be a direct kill of JS?

Re: Bun has an open PR adding shared-memory threads to JavaScriptCore

#120
Back when Node was the new kid on the block, the single-threaded async model was justified by pointing out that the major challenge with multithreading was shared memory. It's one of the strong points of the language / environment, because you never have to worry that some callback will run on another thread.

Javascript shines when it's handling multiple concurrent IO operations, and concurrent operations can become very thread-like with async/await syntax. Multithreaded code in this context only helps with CPU-bound operations; but if I was doing something CPU-bound, I'd probably choose a different language.

One thing I wonder, does Bun (or Node) have a way to call into native code on another thread, but still keep single-threaded once back in JavaScript?

Post reply on HN