Skip to content

Commit d3276fc

Browse files
author
OiNutter
committed
grammar tweaks and add Christmas tag
1 parent 5ece3be commit d3276fc

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

_posts/2024-05-03-bunjs-a-fast-rising-star.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ tags:
88
- typescript
99
- NodeJS
1010
- BunJS
11+
- Christmas
1112
author: wmckenzie
12-
summary: A festive look at the latest challenger to NodeJS's throne
13+
summary: A (belated) festive look at the latest challenger to NodeJS's throne
1314
---
1415

1516
<style>
@@ -25,7 +26,7 @@ summary: A festive look at the latest challenger to NodeJS's throne
2526

2627
Last year I attended the Infobip Shift conference, where I saw a talk by Tejas Kumar on “[New Trends in Front-End Development](https://www.youtube.com/watch?v=VINfWbaFBVs&list=PLuAItjWV4peETEf336UJKvDsI5RWbshUa&index=31&pp=iAQB)”. In his talk, he demoed building and running a new QwikJS app using Bun instead of Node. I’d been hearing lots of talk about Bun, particularly on the Bytes email blast but hadn’t had a chance to properly check it out so I was particularly interested in seeing how it did.
2728

28-
BunJS is billed as “a fast Javascript all-in-one toolkit”... they’re definitely not lying about the fast part! When he first ran the command to start the app up my colleague and I both looked at each other in amazement and commented “Wow that was fast” (content edited for a PG rating). There wasn’t much more discussed about Bun in the talk, the focus was more on Qwik and it’s approach to Signals, and how that compared to other frameworks (a topic for another time), but it had definitely piqued my interest.
29+
BunJS is billed as “a fast Javascript all-in-one toolkit”... they’re definitely not lying about the fast part! When he first ran the command to start the app up my colleague and I both looked at each other in amazement and commented “Wow that was fast” (content edited for a PG rating). There wasn’t much more discussed about Bun in the talk, the focus was more on Qwik and its approach to Signals, and how that compared to other frameworks (a topic for another time), but my interest was certainly piqued.
2930

3031
The problem I was struggling to solve was; “What can I use this on?”. Our client work would be an ideal candidate, we certainly saw issues with NodeJs slowness that Bun definitely had the potential to help with, however in the world of Fintech new and fancy also means unknown and risky and adopting new tech can be a hard case to make.
3132

@@ -52,15 +53,14 @@ I decided to take my existing solutions from last year and convert them to Types
5253

5354
> N.B. For the purposes of keeping the table concise I've focused on a week's worth of tasks in the middle of the month, this gave me problems with a reasonable degree of difficulty but not ones that would be difficult to re-engineer in Typescript. I've also only included the average total time to load data and complete both parts of each problem across 3 runs, rather than comparing each individual segment.
5455
55-
There's certainly no clear, runaway winner. I'd expected Python to still be the faster option, with BunJS maybe coming close, while still beating NodeJS across the board. However, as we can see, things weren't quite so clear cut.
56+
There's certainly no clear, runaway winner. I'd expected Python to still be the faster option, with BunJS maybe coming close, while still beating NodeJS across the board. However, as we can see, things weren't quite so clear-cut.
5657

57-
BunJS actually managed to outperform Python across the majority of the examples, with 3 wins to Python and NodeJS's 2s. Even expanding this out to the first 16 days
58-
and BunJS stays ahead with 10 total wins, beating Python's 5 and NodeJS's 1. Perhaps most interesting was the fact that calling Bun via NPM performed the best, taking
58+
BunJS actually managed to outperform Python across the majority of the examples, with 3 wins to Python and NodeJS's 2s. Even expanding this out to the first 16 days BunJS stays ahead with 10 total wins, beating Python's 5 and NodeJS's 1. Perhaps most interesting was the fact that calling Bun via NPM performed the best, taking
5959
6 wins to the direct approach's 4. I would've expected the extra overhead to have a negative impact. Admittedly there may have been some skewing of data on this, the run
6060
times via NPM mostly tended to decrease on each execution, suggesting a degree of caching may be taking place.
6161

6262
Also pretty impressive is that both BunJS and NodeJS managed to produce a result on Day 15 where Python continued to crash out. Granted there's probably a flaw in my Python code
63-
but the Typescript code is pretty much a like for like conversion. I also felt like BunJS' perceived load time was faster, even on solutions where Python had the
63+
but the Typescript code is pretty much a like-for-like conversion. I also felt like BunJS' perceived load time was faster, even on solutions where Python had the
6464
fastest execution time, the time from pressing enter to starting to getting output often seemed quite long, with BunJS feeling much more responsive.
6565

6666
## So what did we learn?
@@ -70,15 +70,15 @@ fastest execution time, the time from pressing enter to starting to getting outp
7070
Let's start with the main question, is BunJS faster than NodeJS? The results would suggest that on average, yes, BunJS executes the same code faster than NodeJS.
7171

7272
Should you immediately switch all NodeJS projects to BunJS? Probably not, while BunJS was faster, I would say the differences are not really great enough to warrant the
73-
overhead of any refactoring, however minor. I also hit a scenario in last years Advent of Code where BunJS couldn't run the solution due to import issues, but NodeJS could,
73+
overhead of any refactoring, however minor. I also hit a scenario in last year's Advent of Code where BunJS couldn't run the solution due to import issues, but NodeJS could,
7474
so you may find that converting to Bun will break your project.
7575

7676
Should I consider BunJS when starting a new project? Absolutely! For most use cases you're unlikely to have an issue, and transitioning back to NodeJS should be relatively
7777
straightforward, should you need to. The out-of-the-box Typescript and ESM handling is especially nice, I found I had a lot of headaches with ESM typescript loaders trying to
7878
make the scripts run via NodeJS without compiling, and faster startup times for your application are never a bad thing.
7979

8080
Should I switch all my Python projects to BunJS? Again, probably not. Python is still really fast, and, particularly for these kinds of problems, there are a lot of packages
81-
available to make implementing the more complex algorithm's a lot easier, and as I found with last years challenges, sometimes Python can handle the bigger datasets a lot better.
81+
available to make implementing the more complex algorithms a lot easier, and as I found with last years challenges, sometimes Python can handle the bigger datasets a lot better.
8282

8383
Should I do Advent of Code? Absolutely, while some days puzzles are downright horrible, for the most part it's pretty fun, and you can learn a lot about algorithms and more
8484
advanced optimisation techniques.

0 commit comments

Comments
 (0)