News for hackers. Stuff that matters.
Re:Bun, JavaScript, and TCO by Jarred on Sunday December 31, 2023 @10:03AM (#38824492)
(I work on Bun)

A neat thing about tail calls in JavaScriptCore: there’s an explicit bytecode intrinsic for it.

  return @tailCallForwardArguments(MyConstructor, this);

To use this in Bun, you’d have to start Bun with the environment variable “BUN_JSC_useDollarVM=1” and then $vm.createBuiltin(mySourceCodeString)

When using this intrinsic, if any of the arguments are incorrect or it cannot otherwise enable it, the entire process will probably crash. In debug builds of JSC it will have a nicer assertion failure but that is not enabled in release builds

Example code: https://github.com/WebKit/WebKit/blob/17351231b4dedb62d81721...

also happy to answer any questions about Bun

Re:Bun, JavaScript, and TCO by CodeGroyper on Sunday December 31, 2023 @10:32AM (#38824702)
Love bun, thank you so much Mr. Sumner.

What is the priority of app router integration for NextJS?

Re:Bun, JavaScript, and TCO by johnfn on Sunday December 31, 2023 @03:16PM (#38827157)
> What is the priority of app router integration for NextJS?

I'm not Jarred, but what do you mean by this? I'm using bun + app router + NextJS and everything seems to work just fine.

Re:Bun, JavaScript, and TCO by atmin on Sunday December 31, 2023 @03:39PM (#38827348)
Not OP, but interested: can you deploy on a vps having only bun and not node?
Re:Bun, JavaScript, and TCO by maxboone on Sunday December 31, 2023 @04:24PM (#38827641)
Yes
Re:Bun, JavaScript, and TCO by reducesuffering on Sunday December 31, 2023 @05:51PM (#38828218)
I don't think you're talking about what GP comment is.

For clarification, Bun can act as a package manager like npm (probably the case of "bun + app router + NextJS" comment), and it can act as a replacement to a node runtime a la Express on a VPS (I'm assuming this is what you mean by "yes"). But Bun currently does not implement enough of the Node API's to use Bun as the runtime for a Next.js app.

From Bun themselves: "The Next.js App Router currently relies on Node.js APIs that Bun does not yet implement. The guide below uses Bun to initialize a project and install dependencies, but it uses Node.js to run the dev server."

https://bun.sh/guides/ecosystem/nextjs

Re:Bun, JavaScript, and TCO by CodeGroyper on Sunday December 31, 2023 @05:53PM (#38828230)
On https://bun.sh/guides/nextjs it says that bun currently does not implement the API to run the dev server.
Re:Bun, JavaScript, and TCO by Jarred on Sunday December 31, 2023 @07:08PM (#38828592)
After Windows support is further along, but not that long from now
Re:Bun, JavaScript, and TCO by leptons on Sunday December 31, 2023 @07:20PM (#38828645)
When do you see AWS Lambda supporting Bun, if ever?
Re:Bun, JavaScript, and TCO by Jarred on Sunday December 31, 2023 @07:38PM (#38828741)
You can use it today with containers in Lambda or a custom Lambda runtime, but both approaches have embarrassingly slow cold start. Lambda has special optimizations for Node which are not possible without official support.

I have no idea when Lambda would add an official runtime layer. But if you work at Lambda and are interested, feel free to email me - [email protected]