10 ms·
I work on Bun - happy to answer any questions
by Jarred 3y ago
I work on Bun - happy to answer any questions
- tsujp 3y agoHey Jarred, big fan of your work on Bun. Until recently I've been using Deno (mostly to avoid using Node and the tooling hell that entails) and it looks like for my use-cases Bun is getting there. I've had a pleasant experience using Bun as the basis of a test harness. Here's my question (with a tiny bit of lead-in): What I like about Deno is the integrated LSP (reducing tooling hell), are there any plans for Bun to feature this too? Bun already internally transpiles TypeScript which is great but having the LSP bundled too would give this single binary integrated experience a boon I feel. Looking forward to Bun 1.0! P.S. I'm starting to stretch my Zig muscles, you looking for Zig developers? ;)
- rubenfiszel 3y agoYou can pretty much use tsserver with bun-types and get most if not all the features you get from deno-lsp. I know because we provide both deno-lsp and tsserver for windmill.dev to provide intellisense over websocket/jsonrpc for our monaco webide at windmill.dev and it works great :)
- twohaibei 3y agoFriendly warning about expected working conditions: https://twitter.com/lukeshiru/status/1563493902560428034 https://twitter.com/lukeshiru/status/1563493902560428034
- BaculumMeumEst 3y agoHow is this relevant to the comment you're replying to?
- oblio 3y agoHe's asking to be hired by the company behind Bun? How <<isn't>> the previous comment relevant?!?
- JonChesterfield 3y agoThere's a school of thought on work life balance which amounts to wanting just enough life overhead to support the work. That 'balance' is not for everyone - but crucially it is what some people want.
- Buttons840 3y agoCompanies wanted to say they have "work / life balance"; rather than change their practices, they expanded the definition of work / life balance. By this definition, is there any company that doesn't have work / life balance? By this new definition you propose, does the term mean anything? Is 996 a good work life balance because "it is what some people want"?
- bitblender 3y ago>That 'balance' is not for everyone - but crucially it is what some people want I've never seen anyone that could sustain an 80+ hour per week grind and make it out without severe personal issues (whether they are willing to acknowledge it or not). I've seen many, many incredibly talented people burn out and suffer permanent health or career damage to hit their short-term goals. I personally know an otherwise healthy 30 year old swe who had a stress related heart attack. It may be what some people want but you can't grind your way out of being a human.
- Tozen 3y agoBut are they compensated or are we dealing with disguised wage theft[1]? A lot of times, when it's time to pay all that overtime or when someone finally speaks up about it, suddenly the "fun" stops. Then there is the not speaking out, resulting in: 1) Burn out and quit. 2) Company dumps or fires them after burning them out. Then does the same to the new ones. Until something obvious or tragic stops them. 3) Quiet destruction of personal lives. Sometimes leading to significant health and/or mental problems, related to stress, and even suicide in some cases. Balance is necessary, because otherwise it can be like playing with fire. It's all "fun and games", until people get or realized they got burned. [1]: https://en.wikipedia.org/wiki/Wage_theft https://en.wikipedia.org/wiki/Wage_theft
- devbent 3y agoNew product teams are a grind, but with the right people, also a lot of fun. It isn't for everyone. When I was hiring for a NPT working on cutting edge tech I told everyone I interviewed they the work life balance was super skewed. The people who accepted job offers self selected for having a passion for pushing technology forward. I tried to keep things as sane as I could, but I'd have to go in on weekends and usher people out of the office. For some people, building cutting edge things is /fun/.
- reducesuffering 3y agoI don't understand the hand-wringing about this. Bun explicitly says, they are a small team working very hard on some hard problems. If that's your idea of a good time, you're free to try and join. If you want a chiller job, there's 1,000 of them out there. It's not like Jarred is some corporate overlord demanding people slave for him while he sips margarita on a beach... he just wants people working on the same frequency as himself.
- guideamigo_com 3y agoWhy would someone use this over much more maintainable and performant backends in Go or Rust?
- aranchelk 3y agoDefine performant and define maintainable. If you have a lot of duplicated functionality in a web frontend and backend, it may be a lot more maintainable to do the development once and not have to keep two implementations in sync. As far as performance, if you’re using one of the JS application frameworks with server-side pre-rendering time to interactivity may very well be faster than anything you can build in Go or Rust.
- LorenzoGood 3y agoThere is no way that a js ssr framework is faster than a go ssr template renderer.
- lolinder 3y agoIf you're building in plain Go with pure SSR, sure, but OP is talking about building a React frontend that is pre-rendered server-side. TTI very well could be faster with that than with a React front end that talks to a Go backend.
- konart 3y agoI'm kind of lost here. It's been ages since I wrote anything frontend related so here the question: how does it matter? I mean unless you have pure front end app - you are still going to talk to some backend. Regardless of how you got your frontend part - generated by the server or a static file served by nginx.
- spion 3y agoModern JS frameworks pre-render the components on the server then they attach to them to "rehydrate" and add JS handlers on the client. They also allow mixing of purely-server-side components (essentially templates, no JS or hydration) and mostly-client-side components (that still pre-render on the server) For Rust, Leptos (https://leptos.dev/ https://leptos.dev/) would be one choice that can do SSR+hydration (but not intermixed with server-side components, at least AFAIK not yet)
- dead_alchemy 3y agoHey Jarred! Is windows support for 1.0 still on the horizon or has that been pushed? What’s been the best part of this project for you?
- Jarred 3y agoThe honest answer is: don't know yet, but if it doesn't happen in 1.0, it will be the priority for 1.1. I'm going to do some experiments in the next few days and see how it goes. Roughly, the way we're thinking of adding Windows support to Bun is: 1) Get all the Zig code using platform-specific system APIs to use the closest Windows equivalent API. Fortunately, we have lots of code for handling UTF-16 strings (since that's what JS uses in some cases) 2) Get uSockets/uWebSockets (C/C++ library we use for tcp & http serve) to compile for Windows, or fall back to using libuv if it takes too long to make it work 3) Get the rest of the dependencies to compile on Windows 4) Fix bugs and perf issues There are a lot of open questions though. None of us are super familiar with I/O on Windows. JavaScriptCore doesn't have WebAssembly enabled on Windows yet. The biggest thing I'm worried about (other than time) re: Windows is async i/o. In Bun, we _mostly_ use synchronous I/O. Synchronous I/O is simpler and when using SSDs, is often meaningfully lower overhead than the work necessary to make it async. I've heard that anti-virus software will often block I/O for potentially seconds, which means that using sync I/O at all is a super bad idea for performance in Windows (if this is true). If that is true, then making it fast will be difficult in cases where we need to do lots of filesystem lookups (like module resolution)
- pie_flavor 3y agoCommon misconception - it's not opening or writing files that can take a second, it's closing them.
- Jarred 3y agoThis definitely also used to be true on macOS. Bun previously would just request the max ulimit for file descriptors and then not close them. Most tools don't realize there are hard and soft limits to file descriptors, and the hard limit is usually much higher. On Linux, not closing file descriptors makes opening new ones on multiple threads occasionally lock for 30ms or more. Early versions of `bun build` were something like 5x slower on Linux compared to macOS until we narrowed down that the bug was caused by not closing file descriptors.
- toastal 3y agoWhen will Bun use an open standard like IRC, XMPP, or Matrix as a community chat option instead of being limited to usage of proprietary Discord & subject to their ToS?
- spankalee 3y agoWhen will a large enough fraction of users prefer that?
- toastal 3y agoThe crowd that is blocked by sanctions, values privacy/freedom, has certain accessibility needs third-party clients could provide, or doesn’t have powerful enough hardware or a big/fast enough internet plan likely hasn’t been able to participate even if they wanted to. It’s a bad choice, and we see users get banned for weird, non-project-related reasons & they lose access to the community due to the whims of the Discord corporation.
- mst 3y agoWithout in any way suggesting this is a solution rather than a work around, the last time I needed Discord for something I used bitlbee to present it as an ircd and it worked out nicely.
- toastal 3y agoThat workaround is obviously not ideal & still requires an account (& possibly a phone number too). And your private message will still be logged. And using the service also still causes a big issue for search as you can’t find solutions using an engine like you could with a forum. If there are the resources a community would self-host a decentralized, federated server where users are in control of their account/data along with the community in control of moderation, bans, CoC, ToS… & then bridge to other services from that base if they are seen as useful. If a community has less resources certain servers use less resources—especially if the server isn’t supposed to hold the entire history (which these chat rooms shouldn’t be seen as a place for permanent decision making anyhow).
- dj_gitmo 3y agoFrom https://oven.sh/ https://oven.sh/ > The plan is to run our own servers on the edge in datacenters around the world. Oven will leverage end-to-end integration of the entire JavaScript stack (down to the hardware) to make new things possible. So how does oven-sh the company make money? It sounds like you release Bun open source, and then sell access to your edge infrastructure to enterprises? Is these edge servers basically a running a smarter version of NPM with a CDN? Can you say more about what this may eventually do? Will individuals be able to use the edge servers via some free tier? Does Bun in it's current form use this edge infrastructure already?
- satvikpendem 3y agoSame as Deno, Vercel, and many others; Oven will host your backend JS code for you and run it.
- nikivi 3y agoHave you given thought what Bun 2.0 would look like? What major features it would have? Or 2.0 if it ever happens is mostly making Bun work 'at the edge'?
- stephen 3y agoHi! I saw your PR review of a community effort to add Bun to the Techempower benchmark. You had really great, exact feedback about "unnecessary allocation here", "unnecessary allocation there". It was eye-opening, in terms of how often us JS programmers play fast & loose with "a little filter" here, "a little map" there, and end up with death by a thousand allocations. Given that context, I'm curious: 1) How much you think Bun's (super-appreciated!) fanatical OCD about optimizing everything "up to & outside of JSC" will translate to the post-boot performance of everyday backend apps, and 2) If you're tempted/could be compelled :-D to create a "Mojo of TypeScript", where you do a collab with Anders Hejlsberg to create some sort of "TypeScript-ish" language that, if a TS programmer plays by a stricter set of rules + relies on the latest borrowing inference magic, we could bring some of the Bun amazing-performance ethos to the current idiomatic FP/JS/TS style that is "lol allocations everywhere". :-) Or, maybe with Bun bringing the right native/HTTP/etc libraries wrapped around the core runtime, doing "just the business logic" in JS really won't be that bad? Which iirc was the theory/assertion of just-js when its author was benchmark hacking Techempower, and got pretty far with that approach. Anyway, thanks for Bun! We're not running on it yet, but it's on the todo list. :-)
- re-thc 3y ago> PR review of a community effort to add Bun to the Techempower benchmark Has this been added? That PR got closed right? Whilst valid, it was sad that Bun didn't make it. Would be good if someone from the community or Bun team can give it another go.
- genuine_smiles 3y agoDoes anyone have a link to the PR?
- polyrand 3y agoPR link: https://github.com/TechEmpower/FrameworkBenchmarks/pull/8337 https://github.com/TechEmpower/FrameworkBenchmarks/pull/8337
- dapperdrake 3y agoConcerning stephen's item (2). The stricter set of rules was laid out by Richard C. Waters in Optimization of Series Expressions: Part I: User's Manual for the Series Macro Package, page 46 (document page 48). See reference Waters(1989a). The paper's language is a bit different than contemporary (2023) language. `map()` is called `map-fn`. `reduce()` a.k.a. `fold` seems to be `collect-fn`, although `collecting-fn` also seems interesting. sorting, uniqueness and permutation seem to be covered by `producing`. Just think of McIlroy's famous pipeline in response to Donald Knuth's trie implementation[mcilroy-source]: tr -cs A-Za-z '\n' | tr A-Z a-z | sort | uniq -c | sort -rn | sed ${1}q As far as pipeline or stream processing diagrams are concerned, the diagram on page 13 (document page 15) of Waters(1989a) may also be worth a closer look. What the SERIES compiler does is pipeline the loops. Think of a UNIX shell pipeline. Think of streaming results. Waters calls this pre-order processing. This also seems to be where Rich Hickey got the term "transducer" from. In short it means dropping unnecessary intermediate list or array allocations. Shameless self-plug: Eliminated unnecessary allocations in my JavaScript code by adding support for SERIES to the PARENSCRIPT Common Lisp to JavaScript compiler. The trick was (1) to define (series-expand ...) on series expressions so that they can be passed into (parenscript:ps ...) and (2) the parenscript compiler was missing (tagbody ... (go ...) ...) support. The latter is surprisingly tricky to implement. See dapperdrake(2023). Apologies for the less than perfect blog post. Got busy actually using this tool. Suddenly stream processing is easy, and maintainable. When adding a Hylang-style threading macro (-> ...) you get UNIX style pipelines without unnecessary allocations. It looks similar to this: (-> (it :let*-symbol series::let) (scan-file in-path-name #'read) (map-fn T #'some-function it) (collect 'list it)) Sadly, the SERIES compiler available on quicklisp right now is a bit arcane to use. It seems like it may have been more user friendly if it would have been integrated into the ANSI Common Lisp 1995 standard so that is has access to compiler internals. The trick seems to be to use macros instead of (series::defun ...) and use (series::let ...) instead of (cl:let ...). Note, that the two crucial symbols 'defun and 'let are not exported by SERIES. So using the package is insufficient and pipelining fails without a decent warning. Am chewing on the SERIES source code. It is available on sourceforge. [series-source]. If anybody is interested in porting it, then please reach out. It seems to be of similar importance as Google's V8 relooper algorithm [relooper-reference]. Waters(1989b), page 27 (document page 29) even demonstrates an implementation for Pascal. So it is possible. References: dapperdrake(2023): Faster Loops in JavaScript https://dapperdrake.neocities.org/faster-loops-javascript https://dapperdrake.neocities.org/faster-loops-javascript Waters(1989a) document page 48, paper page 46 https://dspace.mit.edu/bitstream/handle/1721.1/6035/AIM-1082.pdf?sequence=2&isAllowed=y#page=48 https://dspace.mit.edu/bitstream/handle/1721.1/6035/AIM-1082... Waters(1989b) document page 29, paper page 27 https://dspace.mit.edu/bitstream/handle/1721.1/6031/AIM-1083.pdf?sequence=2&isAllowed=y#page=29 https://dspace.mit.edu/bitstream/handle/1721.1/6031/AIM-1083... [relooper-reference] http://troubles.md/why-do-we-need-the-relooper-algorithm-again/ http://troubles.md/why-do-we-need-the-relooper-algorithm-aga... [series-source] https://series.sourceforge.net/ https://series.sourceforge.net/ [mcilroy-source] https://franklinchen.com/blog/2011/12/08/revisiting-knuth-and-mcilroys-word-count-programs/ https://franklinchen.com/blog/2011/12/08/revisiting-knuth-an...
- meepmorp 3y agoWhat's zig like to work with? Did the lack of async in 0.11 mess you up?
- satvikpendem 3y agoCurious why you chose Zig and not e.g. Rust.
- postalrat 3y agoI'm quite happy they did.
- satvikpendem 3y agoWhy is that?
- toughruck 3y ago[flagged]
- geodel 3y ago[flagged]
- satvikpendem 3y agoThere's Deno already if someone really wants their JS runtime in Rust. Personally, since everything just runs on a JIT JS runtime anyway, I don't really see to much of a difference between Node, Deno, and Bun, it's not like the JS is being AOT compiled via Zig or Rust, which would be very interesting, you could basically treat JS as a compiled language rather than an interpreted one, even if the JIT is already fast.
- kaba0 3y ago> it's not like the JS is being AOT compiled via Zig or Rust That would actually be slower than what you get from a JIT compiler.
- satvikpendem 3y agoI meant the compiler written in a lower level language that then binds to LLVM, as Rust is currently. Why would AOT be slower than JIT?
- POiNTx 3y agoBun is an executable as far as I understand. Would it be possible to call Bun directly from another language with bindings? For example Erlang (and Elixir) has Native Implemented Functions[0] (NIF) where you can call native code directly from Erlang. Elixir has the zigler[1] project where you can call Zig code directly from Elixir. Maybe you can see where I'm going with this, but it would be super cool to have the ability to call Javascript code from within Elixir. Especially when it comes to code that should be called on the server and client. I'm the developer of LiveSvelte[2] where we use Node to do SSR but it's quite slow atm, and would be very cool to use Bun for something like this. In any case Bun is super impressive, keep it up! [0] https://www.erlang.org/doc/tutorial/nif.html https://www.erlang.org/doc/tutorial/nif.html [1] https://github.com/E-xyza/zigler https://github.com/E-xyza/zigler [2] https://github.com/woutdp/live_svelte https://github.com/woutdp/live_svelte
- Jarred 3y agoYes it would be possible, though it'd be easier to start in Bun and then call out to your executable from JavaScript via napi or bun:ffi
- tmikaeld 3y agoDo you plan to support sandboxing like deno? What is your view on the usefulness of sandboxing and why it was skipped for bun?
- kevlened 3y agoWhile not implemented, Bun may eventually have an alternative to Deno's sandboxing: https://github.com/oven-sh/bun/discussions/725 https://github.com/oven-sh/bun/discussions/725 "Rather than runtime permission checks (Deno's model) which could potentially have bugs that lead to permissions being ignored, Bun plans to have binary dead code elimination based on statically analyzing what features/native modules are used by the code."
- NiekvdMaas 3y agoAre there any plans to enhance the bun compile functionality, e.g. bytecode generation? Similar to pkg in the node world. We use the latter to ship close-source binaries to customers.
- LinguaBrowse 3y agoAny plans for Bun on mobile in future? If so, any idea around how big it might be (sub-megabyte, multi-megabyte)?
- wdb 3y agoNice. I should revisit whether Bun nowadays supports OpenTelemetry
- pranay01 3y agoyeah, I would also love to find out about that
- altano 3y agoHey Jarred, any idea where the bundler + React server components fall in the priority list? Colin's post[1] made me excited about the idea of having a lightweight RSC compiler/bundler built into bun. I'm curious when it'll be considered usable and ready for experimentation. [1] https://bun.sh/blog/server-components-in-bun https://bun.sh/blog/server-components-in-bun
- akv777 3y agothe Segmentation Fault issues #499 is closed, but i got this error, its a issue that you guys is work step by step or should be work now?