38 comments

  • mpeg1 day ago
    This is cool, and it&#x27;s a really impressive feat especially for someone with relatively little experience due to your age.<p>A few notes:<p>- it&#x27;s easy to be faster than other routers when you&#x27;re doing less, for example it seems wildcards are not supported yet, and there&#x27;s no tests but I suspect there would be a lot of bugs in the way routes are handled. I wouldn&#x27;t focus that much on speed<p>- your code organisation is ok for a personal project, but it could use a bit of structure. things are all over the place, I would try to separate pieces of functionality that can be developed (and, importantly, tested) in isolation. For example, your router could be its own module, that way it would also be easier to get started in writing unit tests. (once you&#x27;ve got some example code you can just offload a lot of the test writing to an LLM, then clean them up manually as it will do stupid things)<p>- your benchmarks are quite low in general, I don&#x27;t know how good the node.js tool you&#x27;re using for it is but I would give them a go with something like oha. also, it&#x27;s very odd that hono beats elysia in your tests, in my own testing elysia is much faster than hono, but it suffers from the same tradeoffs as any trie based router (more set up time)<p>- instead of zod, you should use the @standard-schema&#x2F;spec package, so that it can work with any validation library (including zod) – they have some nice type utilities too that simplify inferring types from schemas
  • lioeters1 day ago
    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.<p>A potential user would want to know: why is it faster? What&#x27;s the compromise, if any. What specific quantifiable technical points make it faster than other libraries. Benchmarks and tests.<p>Overall the library feels like a polished open-source project, good attention to design and detail. Definitely valuable as part of a portfolio&#x2F;resume. Keep going!
  • ricardobeat1 day ago
    Nice work! Some notes:<p>1. File size is a commonly highlighted metric for JS frameworks because of network transfer cost on the client side. For node&#x2F;bun&#x2F;deno frameworks, it isn&#x27;t very relevant, especially the gzipped size.<p>2. In the benchmark, the number for all frameworks is quite low - I get closer to 80-100k req&#x2F;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.<p>3. &quot;Cron&quot; scheduling doesn&#x27;t seem to belong in the library. This won&#x27;t be very useful for real-world use cases, as soon as you have &gt;1 node running a server you&#x27;ll need some form of coordination. More size reduction :)
    • ricardobeat1 day ago
      some more after reading the source:<p>- JWT needs to be validated, as it is, your implementation[1] happily accepts anything, you can impersonate anyone you want. I&#x27;d argue that it&#x27;s a bad default choice too [2]<p>- baking-in resend.com as email provider is unlikely to be useful for most people<p>- x-forwarded-for [3] is only added by proxy servers, and will often not be present. This means you&#x27;ll be applying a shared rate limit to most of your users<p>- the &#x27;ai&#x27; helper is missing from the code. If this is vibe-coded, having tests for the examples will help keep it cohesive<p>Sorry if this is a lot, I hope it can help.<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;MatthewTheCoder1218&#x2F;princejs&#x2F;blob&#x2F;main&#x2F;src&#x2F;middleware.ts#L42" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;MatthewTheCoder1218&#x2F;princejs&#x2F;blob&#x2F;main&#x2F;sr...</a><p>[2] <a href="https:&#x2F;&#x2F;paragonie.com&#x2F;blog&#x2F;2017&#x2F;03&#x2F;jwt-json-web-tokens-is-bad-standard-that-everyone-should-avoid" rel="nofollow">https:&#x2F;&#x2F;paragonie.com&#x2F;blog&#x2F;2017&#x2F;03&#x2F;jwt-json-web-tokens-is-ba...</a><p>[3] <a href="https:&#x2F;&#x2F;github.com&#x2F;MatthewTheCoder1218&#x2F;princejs&#x2F;blob&#x2F;main&#x2F;src&#x2F;middleware.ts#L53C33-L53C48" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;MatthewTheCoder1218&#x2F;princejs&#x2F;blob&#x2F;main&#x2F;sr...</a>
      • lilprince121820 hours ago
        Ok thanks. The ai is missing cause I couldn&#x27;t fully implement it and I didn&#x27;t want it half baked so I just took it out.
    • lilprince121819 hours ago
      Ok sure. And my Laptop is almost 8 yrs old so
    • lilprince121820 hours ago
      Ok. Thanks you
  • lxe1 day ago
    Object.defineProperty on every request to set params &#x2F; query &#x2F; body is probably slower than regular property assignment.<p>Also parsing the body on every request without the ability to change it could hurt performance (if you&#x27;re going for performance that is as a primary factor).<p>I wonder if the trie-based routing is actually faster than Elysia in precompile mode set to enabled?<p>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.<p>The dev experience of maintaining this is probably a better selling point than performance.
  • jryan491 day ago
    Considering this is barely any code at all I imagine it doesn&#x27;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?
    • jryan491 day ago
      I do want to applaud your efforts, especially at your age. Add some tests, and keep making things :)
  • swiftcoder1 day ago
    Congrats! That&#x27;s a sleek framework.<p>Would love to see the benchmarks checked into source control somewhere so folks can reproduce them.<p>Can&#x27;t say I&#x27;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.
    • jryan491 day ago
      Agree get rid of the character-by-character animation. It&#x27;s very annoying.
  • a-dub1 day ago
    this is pretty fun, slick to think you can do things like this now and it will be performant: <a href="https:&#x2F;&#x2F;github.com&#x2F;MatthewTheCoder1218&#x2F;princejs&#x2F;blob&#x2F;main&#x2F;src&#x2F;helpers.ts#L13" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;MatthewTheCoder1218&#x2F;princejs&#x2F;blob&#x2F;main&#x2F;sr...</a><p>interesting to dig deep into the bun runtime (it&#x27;s in zig) to see how this remains efficient. it&#x27;s a heap: <a href="https:&#x2F;&#x2F;github.com&#x2F;oven-sh&#x2F;bun&#x2F;blob&#x2F;509a97a43516fe4f6d4ff4003d1c9aeef89e92ce&#x2F;src&#x2F;bun.js&#x2F;api&#x2F;Timer.zig#L15" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;oven-sh&#x2F;bun&#x2F;blob&#x2F;509a97a43516fe4f6d4ff400...</a><p>of these: <a href="https:&#x2F;&#x2F;github.com&#x2F;oven-sh&#x2F;bun&#x2F;blob&#x2F;509a97a43516fe4f6d4ff4003d1c9aeef89e92ce&#x2F;src&#x2F;bun.js&#x2F;api&#x2F;Timer&#x2F;EventLoopTimer.zig" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;oven-sh&#x2F;bun&#x2F;blob&#x2F;509a97a43516fe4f6d4ff400...</a><p>pretty cool clean and simple code for the framework (and bun).
  • sidcool23 hours ago
    The name is interesting, considering it&#x27;s created by a Nigerian.
  • gwd1 day ago
    I thought it was going to have something to do with this:<p><a href="https:&#x2F;&#x2F;princejs.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;princejs.com&#x2F;</a>
  • silvestreh1 day ago
    This is really interesting, but I&#x27;d absolutely love if you could add a light theme to your website. I really can&#x27;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.
    • lilprince121818 hours ago
      You asked. We delivered.<p>Next: tests + security fixes + reproducible benchmarks.<p>Thank you for making PrinceJS better.<p>— @Lil_Prince_1218 (13, Nigeria)
    • lilprince121820 hours ago
      Ok bro
  • Rather than requests per second, I prefer &#x27;clock cycles per request&#x27;.<p>As well as being slightly more hardware independent, it also helps highlight exactly how efficient&#x2F;inefficient the code must be.<p>This code is ~100k clock cycles per request.
  • RestartKernel18 hours ago
    The readme and stats remind me of VanillaJS, which should be a sign that you&#x27;re not making a fair comparison here. Anyhow, I think this can be a very educational experience if you keep adding features and benchmarking — it&#x27;ll get slower, but you&#x27;ll know exactly why.
    • lilprince121817 hours ago
      and im totally fair. I mean its not me that decide what the computer outputs sometimes when i run my code, mine is even bulkier than them
    • lilprince121817 hours ago
      well i am still adding features. And thanks also
    • RestartKernel18 hours ago
      Here&#x27;s the obligatory comment complimenting you on the project given your age too. It&#x27;s certainly more advanced than anything I tried at that age.
  • jeremy_su1 day ago
    I think you are misunderstanding &quot;Type-safe&quot;<p>In traditional development, the backend engineer writes the API and writes the relevant documents. Then, the frontend developer writes the request API function based on the documentation.<p>However, in type-safe API development, once the backend API is finished, the frontend merely needs to install the API module and import the API function, eliminating the need for any manual wrap code.<p>But anyway, good job, you are build something, and it&#x27;s amazing!!
  • gbuk20131 day ago
    My favourite question to ask when seeing benchmark results such as this is “how much latency did you have &#x2F; inject when running the benchmark”. This tends to lead to interesting conversations and learning. :)<p>One my favourite instances of this was in a benchmark measuring contest with a Golang enthusiast who was surprised to see that with a bit of latency his server was not 3x faster than Node.js like he thought it would be.
  • leeoniya1 day ago
    i was initially confused how 19.2K rps is notable when Express typically benchmarks around 15K rps [1].<p>however, the author is benchmarking a route with an id param here, not a static route.<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;uNetworking&#x2F;uWebSockets&#x2F;discussions&#x2F;1415" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;uNetworking&#x2F;uWebSockets&#x2F;discussions&#x2F;1415</a>
  • oliwarner11 hours ago
    Prince from Nigeria?<p>That&#x27;s some incredible comedic insight for a 13yo.
  • Alex_L_Wood1 day ago
    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.
  • ramon1561 day ago
    Impressive stuff! I see you have contributions startins 2023, does that mean you started programming at 11?
  • jasonjmcghee1 day ago
    Nice job building a thing and putting it out there. It&#x27;s a great accomplishment.
  • bitwize1 day ago
    Is from Nigeria<p>Has &quot;Prince&quot; in his HN nick and framework name<p>I smell either a rat, or an incredibly meme-savvy kid who leaned into the joke.<p>Anyways, congrats and keep on hacking!
  • BewareTheYiga1 day ago
    This is amazing! It does everything but make the jollof.
  • super2561 day ago
    At that age I couldn&#x27;t even code. Keep it up, young man :)
  • altmind1 day ago
    Will you bench against techempower benchmarks?
  • waschl1 day ago
    Mighty impressive
  • rvz1 day ago
    Looks great.<p>However, there are no tests yet.
    • lilprince121819 hours ago
      I&#x27;ll make sure to add that&#x27;s
      • rvz19 hours ago
        Other than that, well done and keep it up.
  • moralestapia1 day ago
    An actual nigerian prince that&#x27;s not a scam. LOL.<p>Congrats on this, keep building more stuff!
  • fwip1 day ago
    The github page claims &quot;PrinceJS fits in a tweet,&quot; but also that it&#x27;s 2.8kB after gzip compression.<p>Are tweets 2800 characters now? (Genuine question, I haven&#x27;t used the place in years.
    • chuckadams1 day ago
      People with blue-check accounts get a 25000-char limit. Everyone else is at 280. Have had twitter&#x2F;x aliased to localhost for a while now myself.
  • Uptrenda1 day ago
    Damn smart kid. You&#x27;re going to have a bright future. Stay away from bad influences and you&#x27;ll be a star.
  • stevepotter1 day ago
    I got emotional thinking about a 13 year old releasing this. No brutal feedback, just proud of you buddy. Keep it going!
  • virajk_3118 hours ago
    damn! you are just 13yo, impressive. Do you even play with other kids your age?
    • lilprince121817 hours ago
      yh. only when im in school though. But not everyone gets me
  • yahoozoo1 day ago
    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.
    • tayo421 day ago
      You would be otherwise just benchmarking the slow service if you benchmarked it any other way
      • koakuma-chan1 day ago
        What is being benchmarked there anyway? Receiving a request from the underlying HTTP library, calling the user&#x27;s handler function, and passing the response back to the HTTP library? Hono, Elysia, PrinceJS... all these &quot;frameworks&quot; really are just routers, and Bun comes with its own router.
      • ricardobeat1 day ago
        No, you would be benchmarking the overhead of juggling several requests in flight, I&#x2F;O and memory usage, which is what really distinguishes servers in terms of performance.
  • dlisboa1 day ago
    I know it&#x27;s intentional but very amusing name considering the country of origin.
    • alexfoo1 day ago
      It’s almost certainly not because of the advance fee scam.<p>You don’t have to meet many Nigerians before you find one that claims to be some kind of a Prince back home.<p>Nigeria used to be hundreds&#x2F;thousands of separate kingdoms and many people have a claim to be chiefs&#x2F;kings of those historic kingdoms. Male descendants of such leaders will claim the unofficial title of Prince. They may not have any real national standing but such leaders will be respected by their local communities.<p>It may look like one big country but there’s no official single royal family (unsurprising since it is a Republic). To give an idea of the diversity of Nigeria consider the fact that the country has over 500 native languages that are actively spoken.
  • mikeday1 day ago
    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.
  • Why would you tree-shake your backend?
  • doppelgunner19 hours ago
    [dead]
  • [dead]