26 ms·
I work on Bun - happy to answer any questions/feedback
by Jarred 3y ago
I work on Bun - happy to answer any questions/feedback
- helsontaveras18 3y agoHow do you ensure cross platform compatibility under the hood?
- Jarred 3y agoWe implement a handful of the most common commands like cd, rm, ls, which, pwd, mv. Instead of using the system-provided ones, it uses ours. Unlike zx/execa, we have our own shell instead of relying on a system-installed one.
- reactordev 3y agoIs this done in zig in the core bun runtime or is it implemented as part of the standard bun lib? How much perf is there? Small commands like cd or ls I'm less interested in. You say you provide your own shell... bsh, zigsh, what?
- Jarred 3y agoIt’s nearly all in Zig. The parser, lexer, interpreter, process execution and builtin commands are all implemented in Zig. There’s a JS wrapper that extends Promise but JS doesn’t do much else. The performance of the interpreter probably isn’t as good as bash, but the builtin commands should be competitive with GNU coreutils. We have spent a lot of time optimizing our node:fs implementation and this code is implemented similarly. We expect most scripts to be simple one-liners since you can use JS for anything more complicated.
- reactordev 3y agoGood to hear you guys made the right decisions. Bun is awesome and the more performance you guys can squeeze with zig, the better. Keep it up! Bang up job already.
- natrys 3y agoThink this should be highlighted in the article, because that's actually pretty cool but the article gave me impression that it's a simple sugar over child_process only.
- airstrike 3y agoI had the exact opposite impression, FWIW. I understood implicitly (assumed?) that it was implementing its own commands
- oblio 3y agoI think Bun is written in Zig. Is Zig stable as in 1.0.0, LTS?
- deleted 3y ago[deleted]
- laserbeam 3y agoNope. Zig is still changing. In my understanding bun is generally quick to adapt to these changes, and one of the projects zig is keeping an eye on when breaking changes are introduced.
- brabel 3y agoI've played around with Zig a few times and quickly ran into compiler bugs, things that should work but are not yet implemented, lots and lots of things completely absent in the stdlib (and good luck finding custom zig libraries for most things)... given all that, I just can't fathom how they managed to write Bun mostly in Zig (I see in their repo they do use many C libs too - so it's not just Zig, but still it's a lot of Zig)... and I wonder how horrible it must've been to go from 0.10 to 0.11 with the numerous breaking changes (even my toy project was a lot of work to migrate).
- cassepipe 3y agoProbably because they are the kind of people that don't rely on libraries and are able to fix compiler bugs
- bryzaguy 3y agoThis is so cool! Is it too late to change the import name? I immediately thought of jquery when seeing "$".
- geuis 3y agoHmm you have a point but I don't think it's a problem since this is for the cli instead of the browser. Plus $ is pretty common in the shell to indicate the prompt.
- mst 3y agoimport { $ as sh } from "bun"; (if you're coming from old school client side javascript I can see the momentary confusion (and in fact I had to blink myself), but in a shell script $ making you think of a shell prompt nonetheless seems like a pretty reasonable default to me)
- 8n4vidtmkvmk 3y agoThis is super cool, but can you fix bun -i so that it actually auto installs missing libs? That would really help with having self-contained scripts. Then I can finally start replacing my shell scripts with bun.
- IshKebab 3y agoDo you worry that people will use this in their actual programs, rather than just in development scripts? You've at least quoted variables, which is several steps better than most Bash scripts, but even so Bash tends to be hacky and fragile. The original JavaScript code using native APIs is more verbose but better code.
- yard2010 3y agoJarred thank you for making the ecosystem better in your own special way like nobody else does