🔧 Why we chose Bun
Nachrichtenbereich: 🔧 Programmierung
🔗 Quelle: dev.to
At AlertPix we allow streamers to receive donations from their audience via Pix Instant Payment and show an alert on the live stream.
I was eyecatching Bun for a long time. And while developing the initial version of the platform the excitement to use it when it was more stable was really high.
And when 1.0 reached, I knew it, our real time system should be written in Bun.
No common js or esmodules madness
Our API is in node. And God, how I suffered to import nanoid in an esmodule project. I had to vendor it, since using a previous version was not ideal.
With bun, we can no longer worry about that. Just import what you need and done.
import fs from "node:fs"
const path = require("node:path")
TypeScript ou of the box
We all know that TS is just a linter, so we need it as the project grows right?
That feeling when the auto complete works, hits different.
But the struggle to setup TypeScript in nodejs is a pain.
Well, with Bun, its no longer an issue anymore. It just works.
Fast startup times
Oh boy, while developing AlertPix, I was relying solely on using cloud environments since my laptop was in repair.
I can count how many hours I wasted waiting node to sync the changes (I'm talking about you Next, you are slow even on high end machines) in these cloud enviroments. When switched to Bun, everything felt fast.
Buildless deployment
Our realtime service needs to be deployed as fast as possible.
It means that, the time to identify a bug in production, fix the issue, commit and run de CI deployment should be small.
And we know that, even cached, deployments are slow because of the build step. The bigger the project, the more time it takes.
Since bun runs TypeScript without a build step.
In summary, our container pulls Bun, install the packages, copies the needed files and runs the code with Bun:
FROM oven/bun
WORKDIR /app
COPY package.json .
COPY bun.lockb .
RUN bun install --production
COPY src src
COPY tsconfig.json .
ENV NODE_ENV production
CMD ["bun", "src/index.ts"]
EXPOSE 3000
Pub Sub is easier
Our real time system is a pub sub on top of websockets.
And it is so easy to do, that we already covered it in this post
🔧 Why we chose Bun
📈 45.73 Punkte
🔧 Programmierung
🎥 Why Moure chose a .dev domain name
📈 25.87 Punkte
🎥 Videos
🎥 Why Creator chose a .app domain name
📈 25.87 Punkte
🎥 Videos
🎥 Why DanaScript chose a .dev domain name
📈 25.87 Punkte
🎥 Videos
🔧 Why OpenAI chose Remix?
📈 25.87 Punkte
🔧 Programmierung
🔧 Why I Chose React Over Angular
📈 25.87 Punkte
🔧 Programmierung
🔧 Why I Chose Supabase as BaaS for My Projects
📈 25.87 Punkte
🔧 Programmierung
🎥 Why Netlify chose a .app domain name
📈 25.87 Punkte
🎥 Videos
🔧 Why I chose Supabase as BaaS for my projects
📈 25.87 Punkte
🔧 Programmierung
🎥 Why Clerk chose a .dev domain name
📈 25.87 Punkte
🎥 Videos
🔧 Why I chose Svelte over React?
📈 25.87 Punkte
🔧 Programmierung
🔧 Why I Chose Vite.js for My React Projects
📈 25.87 Punkte
🔧 Programmierung
🎥 Why Kedasha chose a .dev domain name
📈 25.87 Punkte
🎥 Videos
🔧 Why we chose C over Rust
📈 25.87 Punkte
🔧 Programmierung