I'm currently developing a game engine, backed by a new programming language called NAPL. The idea is to develop a engine that can be inserted into any platform.
To start, the engine is developed using Node.js.
After doing some research, I have decided to go ALL IN with Bunjs. After a long rant below, I will explain why.
When developing Node.js, mainly for games but also other random projects, I have a particular workflow and a set of features I'd like to work with:
- TypeScript: For all my projects, I need the ability to work seamlessly with typescript. I want the typescript code bundled in a way that I can reuse it in other projects or in the browser.
I use React mainly for UI. It's separate from the core of the game which is developed in WebGL.
I need the ability to create npm packages and publish them as libraries, then when I develop my app, I want to be able to just import those dependencies seamlessly.
For every library that I build, I need the package to bundle itself, and include a command to server a webpage that will show an example on how the library is used.
My collision detection engine does show this kind of setup:
The demo app needs to be shown when displayed through GitHub pages.
While the demo app is used for manual testing, I also need each component of the package to be united tested.
So this all seems pretty basic, right?
It just doesn't work! I constantly get random errors during the building phase. Some dependency mismatch, node version needs to be upgraded, then no, it needs to be downgraded...
Usually, when I paste the error I get into Google, there's always some StackOverflow post providing the solution on solving the problem. And you know what else? The solution ALWAYS NEVER WORKS! How is it possible that there are clear instructions online on solving the problem, yet those just don't solve the problem at all? Even when asking ChatGPT, I get a buttload of possible ways to fix the errors, and none of them work.
I used to try to understand the actual issue, but at some point I gave up. I no longer have time to understand Node.js. Often, there's one line to edit or one field in the config to set, and somehow I either get pass through the error, or encounter a new one. It's possibly progress, or possibly not.
Eventually, the workflow does kind of work. I get there by randomly manipulating the package.json, tconfig.json, webpack... But often there's something missing. Either I can't use TypeScript, or the library will work with some projects but not others... Sometimes everything works except unit tests.
This is something I just accepted, but everything I would work on a new project, I would encounter those random errors again. It makes me question my life quite a lot. Sometimes I even question the whole world of computers in general. How is it that when you need to do something with the computer, whether it's installing a software, running some command, or setup something new, the general expectation that it will never work if you just follow the instructions online. There's always some extra step you need to do, which is sometimes found somewhere in the instructions, sometimes you need to search on Google, and sometimes it's just non-existent. You just need to know how to fix it.
Imagine picking up a recipe for baking Cupcakes. You follow the instructions to the letter and it doesn't work. Then you realize that the instruction has a prerequisite. Ok, you bought the extra tool to fulfill the prerequisite. Then the cupcakes still fall flat. Eventually, you found out from a friend that there's some extra step that is mentioned nowhere, like you have to add eggs or something. Apparently it's not mentioned because it's obvious to all bakers. Yet, you fell into the trap, so I guess you're just an idiot. That's often what I feel when I'm trying something new with software. I've gotten used to it, but little by little, this really makes me feel like an idiot.
Well, that was a long rant. So anyway, I learned about BunJS and liked the idea. A Node.js replacement that supports TypeScript and React by default, has built-in bundler, and apparently it's super fast.
I gave it a try, and to my surprise, things just worked.
I don't really know what else to say. The workflow that I'm trying to follow just builds without error, and I actually get the result I want.
On top of that, it does seem a lot faster than working with Node.js.
I guess occasionally, I did found odd error in my VSCode editor, such as
Bun.build isn't defined. So it's not perfect, but somehow that's manageable. The error is contained in the editor but the building part does work.
Bunjs is pretty new, but already it delivers on its promise. There aren't many references online, but I feel like the community is growing.
So I'll be putting my faith in Bunjs for my upcoming work on my NAPL game engine. At the end, all I want is something that works, without having to search all over the web for the missing piece in the puzzle, and that's what I got with Bunjs!