Show HN: PrinceJS – 19,200 req/s Bun framework in 2.8 kB (built by a 13yo) (princejs.vercel.app)

151 points by lilprince1218 ↗ HN
Hey HN,

I'm 13, from Nigeria, and I just released PrinceJS — the fastest web framework for Bun right now.

• 19,200 req/s (beats Hono/Elysia/Express) • 2.8 kB gzipped • Tree-shakable (cache, AI, email, cron, SSE, queue, test, static...) • Zero deps. Zero config.

Built in < 1 week. No team. Just me and Bun.

Try it: `bun add princejs` GitHub: https://github.com/MatthewTheCoder1218/princejs Docs: https://princejs.vercel.app

Brutal feedback welcome. What's missing?

– @Lil_Prince_1218

58 comments

[ 3.1 ms ] story [ 82.7 ms ] thread
Any real world app is going to be waiting on, primarily, IO. These benchmarks that just hit an endpoint that returns a simple object are useless.
I know it's intentional but very amusing name considering the country of origin.
Congrats! That's a sleek framework.

Would love to see the benchmarks checked into source control somewhere so folks can reproduce them.

Can't say I'm the biggest fan of the way the sample code types itself out character-by-character. Took a while for the longer samples to finish typing themselves out.

Damn smart kid. You're going to have a bright future. Stay away from bad influences and you'll be a star.
The github page claims "PrinceJS fits in a tweet," but also that it's 2.8kB after gzip compression.

Are tweets 2800 characters now? (Genuine question, I haven't used the place in years.

An actual nigerian prince that's not a scam. LOL.

Congrats on this, keep building more stuff!

Considering this is barely any code at all I imagine it doesn't provide anywhere near the feature set other web frameworks do. Also there are no tests. How do you know it even works properly? Why would I trust that it works properly?
Object.defineProperty on every request to set params / query / body is probably slower than regular property assignment.

Also parsing the body on every request without the ability to change it could hurt performance (if you're going for performance that is as a primary factor).

I wonder if the trie-based routing is actually faster than Elysia in precompile mode set to enabled?

Overall, this is a nice wrapper on top of bun.serve, structured really well. Code is easy to read and understand. All the necessary little things taken care of.

The dev experience of maintaining this is probably a better selling point than performance.

Nice job building a thing and putting it out there. It's a great accomplishment.
Great job with building and releasing a project. The API looks intuitive, almost the same as Express. Documentation site is good! The animated code blocks is nice on front page but too distracting in the docs itself, I think.

A potential user would want to know: why is it faster? What's the compromise, if any. What specific quantifiable technical points make it faster than other libraries. Benchmarks and tests.

Overall the library feels like a polished open-source project, good attention to design and detail. Definitely valuable as part of a portfolio/resume. Keep going!

Impressive stuff! I see you have contributions startins 2023, does that mean you started programming at 11?
(comment deleted)
Is from Nigeria

Has "Prince" in his HN nick and framework name

I smell either a rat, or an incredibly meme-savvy kid who leaned into the joke.

Anyways, congrats and keep on hacking!

I got emotional thinking about a 13 year old releasing this. No brutal feedback, just proud of you buddy. Keep it going!
This is really interesting, but I'd absolutely love if you could add a light theme to your website. I really can't read on a dark background, it kinda hurts my eyes and when I take my eyes off the screen I see a bunch of horizontal lines for a minute or so.
You asked. We delivered.

Next: tests + security fixes + reproducible benchmarks.

Thank you for making PrinceJS better.

— @Lil_Prince_1218 (13, Nigeria)

Nice work! Some notes:

1. File size is a commonly highlighted metric for JS frameworks because of network transfer cost on the client side. For node/bun/deno frameworks, it isn't very relevant, especially the gzipped size.

2. In the benchmark, the number for all frameworks is quite low - I get closer to 80-100k req/s with Bun on my 3-year old machine. Might be worth using a standard VM size in a cloud provider to make it more meaningful.

3. "Cron" scheduling doesn't seem to belong in the library. This won't be very useful for real-world use cases, as soon as you have >1 node running a server you'll need some form of coordination. More size reduction :)

This is pretty impressive, wow! I always wanted to build a toy HTTP requests framework just to better understand the tools I’m working with, and here you are building the full thing.
Ohhh Nigerian Prince, I thought it was a wrapper for our Prince HTML to PDF formatter, but there is also a JavaScript implementation of Prince of Persia lol.