DEV Community

Cover image for Bun is up to 20x slower than NodeJS in logic operations

Bun is up to 20x slower than NodeJS in logic operations

Jeongho Nam on February 01, 2025

Preface typia is a transformer library supporting superfast runtime validation, and JSON serialization function boosting up performanc...
Collapse
 
atsepkov profile image
Alexander Tsepkov • Edited

I don’t get the point of the article, all you’ve proven is that a library hyper-optimized for Node and taking advantage of its hidden features doesn’t work well on Bun. No surprise there. The title claiming that this applies to all logical operations is nothing but clickbait.

Collapse
 
samchon profile image
Jeongho Nam

The validation and serialization code uses below expressions, and you are saying that these common expressions are hyper optimized only for NodeJS so that have not to use in Bun, right?

  • binary expression (===)
  • typeof expression
  • string concat expression
  • return expression
  • Number to String type casting
Collapse
 
vndre profile image
Andre

One very little detail was coincidentally omitted: the OP of this post is the creator of the Typia library and there's a chance they are biased in promoting their hard work. I will believe it when a benchmark is made by an unbiased non-related third party.

Collapse
 
msveshnikov profile image
Max Sveshnikov

Why to check types in runtime? Isn't it most idiotic idea ever?

Collapse
 
samchon profile image
Jeongho Nam

Request body data validation is the most famous case of runtime validation.

nestia.io/docs/core/TypedBody/

Collapse
 
hugohub profile image
Karlis Melderis

Oh no

You get unknowns (often any) from libs, external Apis (even if they claim their contract), raw SQL queries... Keep on adding cases when type is only on the paper

At these cases it's way safer to validate data before using it

Collapse
 
spicy_icy profile image
spicy_icy

nice work on typia 👍
i havent tried it myself but it seems to me that the benchmark is legit.
i hope the bun maintainers catch wind of this but im not sure if they can address this.
either way their github issues is flooded so i am not holding my breath.

Collapse
 
m0ltzart profile image
Roman

Would be an awesome benchmark to add to github.com/moltar/typescript-runti...

Collapse
 
cem_usta_fbe376c46cf78e1d profile image
Cem Usta

I wonder whats the state in Deno2

Collapse
 
khalid_achwaq_04fb3ca1d3d profile image
Khalid Achwaq

What about in Deno 🤔❓

Collapse
 
nabwinsaud profile image
Nabin

Can you show the repo what actually you are trying to do . Typia i don't see the starter repo for that to explore .