Bun (TypeScript) is faster than Rust!?!

Поделиться
HTML-код
  • Опубликовано: 4 июн 2024
  • I cannot believe this! Is bun ackshually faster? The best way to find out is to write some amazing tests.
    Repo
    github.com/ThePrimeagen/BunSp...
    Twitch
    Everything is built live on twitch
    Twitch : bit.ly/3xhFO3E
    Discord: discord.gg/ThePrimeagen
    Editor
    All my videos are edited by Flip. Give him a follow! / flipmediaprod He is also open to do more editing, so slide deeeeeeeeep into his dms.
    Links
    Linode: linode.com/prime
    / discord
    Twitch: / theprimeagen
    Insta: / theprimeagen
    Twitter: / theprimeagen
    VimRC & i3: github.com/ThePrimeagen/.dotf...
    Keyboard (15% off, I don't earn commission): bit.ly/primeagen-adv2
    #coding #programming #softwareengineering #javascript #vs
    chapters
    0:00 Bun Is BlazinglyFast
    1:06 The Code
    4:08 The Methodology
    4:57 The Results
  • НаукаНаука

Комментарии • 514

  • @ThePrimeagen
    @ThePrimeagen  Год назад +875

    Would you like me to do add in Zig + Go?

  • @AndrewBanchich
    @AndrewBanchich Год назад +1300

    Zig isn't memory safe like Rust is, which I'd guess is why you're getting blazingly fast segfaults.

    • @razvan683
      @razvan683 Год назад +76

      whats the point of zig over c++ or c then ?

    • @shubhampawar7921
      @shubhampawar7921 Год назад +132

      God tier comment.

    • @dickheadrecs
      @dickheadrecs Год назад +7

      take off every zig

    • @ThePrimeagen
      @ThePrimeagen  Год назад +278

      You're absolutely right, as I also seg faulted myself several times on stream

    • @IlhanNegis
      @IlhanNegis Год назад +4

      daaayum

  • @marcio603
    @marcio603 Год назад +177

    Man... as a computer science researcher, I love your experiments! Thanks for bringing this "scientist" spirit to the public! :)

    • @ThePrimeagen
      @ThePrimeagen  Год назад +33

      yayaya! I actually try to follow a more rigorous style.
      1. test
      2. consistent methodology
      3. results
      People tend to just mix 1 + 2 and not consider the implications of that (say local host testing).

  • @quachhengtony7651
    @quachhengtony7651 Год назад +38

    You had my hopes up for a blazingly fast second there

  • @earthling_parth
    @earthling_parth Год назад +3

    This was really informative. Can't wait for the Go and Zig comparisons as well. Thanks Prime 👍

  • @ramtinabadi
    @ramtinabadi Год назад +220

    It would be extremely interesting to rebuild your TS server that you used to compare against GO and Rust in Bun. I think everyone would love to know what percentage of requests would be within acceptable ms using Bun instead of Node

    • @ThePrimeagen
      @ThePrimeagen  Год назад +48

      yeah! It actually wouldn't be very hard at all because its the entry point that was different, the rest is plain ol js.

    • @KManAbout
      @KManAbout Год назад +2

      @@ThePrimeagen see is there any reason to ever build rust servers if go servers are just that good in every case except the most extreme teams? Since go is usually faster and rust code needs to be really good to beat it doesn't it just make since to write go code for most code bases?

    • @echoptic775
      @echoptic775 Год назад

      @@KManAbout there is a reason, discord was using go backend in the past and switched to rust

    • @poolkrooni
      @poolkrooni Год назад +6

      @@echoptic775 sure, but 99% of us aren't Discord or at FANG scale

    • @KManAbout
      @KManAbout Год назад +8

      @@poolkrooni more like 99.99% of us almost none of use are ever going to have billions of users.

  • @andreagiorgi3512
    @andreagiorgi3512 Год назад +67

    Before: is nodejs faster than rust?? (lol no)
    Now: is bun faster than rust??? (lol no, with segmentation faults)

    • @victorgabr
      @victorgabr Год назад +9

      No one can survive on RUclips without clickbait. lmao

  • @IlhanNegis
    @IlhanNegis Год назад +50

    other thing with bun is, it is open to unhealthy amount of puns which will make our lifes kind of unbearable at some point

    • @ThePrimeagen
      @ThePrimeagen  Год назад +14

      these are facts. which is why i tried to make 0

    • @DanWalshTV
      @DanWalshTV Год назад +16

      @@ThePrimeagen 6:58 "plenty of time to bake it" 😏

    • @rubenverster250
      @rubenverster250 Год назад

      Writing this server app will be fun on a bun :D
      Bender from Futurama has no objection :P

  • @maddada
    @maddada Год назад +1

    How is this the first time I come across this channel! This was amazing, subbed!

  • @calder-ty
    @calder-ty Год назад +83

    A revisit once bun has matured some more could be interesting. Great content as always.

  • @fishfpv9916
    @fishfpv9916 Год назад +55

    On Theo's video had huge doubts about the claims that bun http is faster than rust. Glad to see an unbiased comparison that lives in reality

    • @ThePrimeagen
      @ThePrimeagen  Год назад +40

      people constantly run bad experiments.
      please be careful when looking at results :) Always expect a methodology.

    • @t3dotgg
      @t3dotgg Год назад +45

      To be fair I’m not smart enough to write the Rust code for testing comparisons

  • @franekborowiec9648
    @franekborowiec9648 Год назад +27

    Got inspired to try vim with your vids. I'm tempted to try rust now

    • @noorhu2555
      @noorhu2555 Год назад +2

      Read the book. I know prime doesn't recommend it but it's really good.

    • @nickschmitt8594
      @nickschmitt8594 Год назад

      Read “A Half Hour To Learn Rust”

  • @harrybilsonia
    @harrybilsonia Год назад +9

    Nice to start the work week with upbeat prime energy

  • @rashad123us
    @rashad123us Год назад +4

    I’ve been waiting for this! 😁

  • @wWvwvV
    @wWvwvV Год назад +2

    Golang is also very strict. A thread locking a mutex twice is doomed to be a dead lock. Unlocking a not locked mutex is a Go panic. Both are programming errors. I try to implement something like async/await for QML and Go, stop at a QML-Dialog in your code and wait for the result before proceeding. You can still have callbacks/signals, but for dialogs it is much more convenient to hold your program (thread) until there is a result.

  • @user-db8xn8vh7u
    @user-db8xn8vh7u Год назад +1

    I have been immediately reminded of you when I saw the BLAZINGLY FAST phrase from bun lol

  • @artemhrytsaienko3063
    @artemhrytsaienko3063 Год назад

    I can't express enough how I like Prime performance. Dude you are the best!

  • @alexandersobolev5284
    @alexandersobolev5284 Год назад +1

    I was waiting for this review. Blazingly fast!!!

    • @ThePrimeagen
      @ThePrimeagen  Год назад +1

      there is going to be a follow up :)

  • @denzilv
    @denzilv Год назад +5

    Another great video. The end got me really good. Shout out to Mrs. Primeagen! 😂

  • @SayWhat6187
    @SayWhat6187 Год назад +7

    7:16 “A real language” loool

  • @knelasevero
    @knelasevero Год назад

    your channel deserves more views all around

  • @daymaker_bybit
    @daymaker_bybit Год назад +1

    I love these "BlazinglyFast" series so much! :D

  • @regbot4432
    @regbot4432 Год назад +9

    I tried many new C/C++ like languages and zig is subjectively the most fun to use, the most readable and do-not-get-in-your-way language. Also it comes with toolchain that makes it really easy to work with C/C++ libraries and mix code.

    • @ThePrimeagen
      @ThePrimeagen  Год назад +2

      yeah! it is really fun, though i have never tried to debug/other tool it.

    • @marcs9451
      @marcs9451 Год назад

      try Odin

  • @F.a797
    @F.a797 Год назад +1

    your videos are BLAZINGLY BEAUTIFUL.

    • @ThePrimeagen
      @ThePrimeagen  Год назад

      This comment is Blazingly Appreciated

  • @IlhanNegis
    @IlhanNegis Год назад +18

    bun has a very bright future behind her

    • @ThePrimeagen
      @ThePrimeagen  Год назад +10

      Dang, cold as ice

    • @IlhanNegis
      @IlhanNegis Год назад +10

      @@ThePrimeagen you're the one who spread the bun and show us the light.

  • @topcivilian
    @topcivilian Год назад +49

    remove MUTEX with the Backspace button

  • @sirdespin
    @sirdespin 8 месяцев назад

    I'll love to see this test again with Bun 1.0

  • @ac130kz
    @ac130kz Год назад +40

    Zig is basically C, but the shotgun is a boomerang. Jokes aside, after looking at how well Zig integrates with C, assembly and adds neat features to C, I'm sure it will have a certain niche as a C replacement for hardcore nerds. The nerds who love cool, weird and at the same time incomplete languages like Vala or Julia, for example.

    • @rakaboy1619
      @rakaboy1619 Год назад +6

      i mean julia is pretty complete yk

    • @FLMKane
      @FLMKane Год назад +1

      Good that you didn't mention Matlab

  • @alisontahiri8452
    @alisontahiri8452 9 месяцев назад +4

    Hi! Waiting forward for a comparison now that Bun 1.0 is out. Thanks for your insights!

  • @JamieMason
    @JamieMason Год назад

    Really wanted to see that `aboo` method show up after `peek` dropped and got me all excited

  • @ph4nt0mcz130
    @ph4nt0mcz130 Год назад +5

    How this guy can code at this level and entertain at the same time? It is a completely different talent tree and yet he managed to do that.

  • @benabitbol7767
    @benabitbol7767 Год назад

    and here i was excited about blazing fast bun, see you my friend it was nice knowing you

    • @ThePrimeagen
      @ThePrimeagen  Год назад +1

      hah, i am going to get cancelled, arn't i?

  • @ibrahimkoz1983
    @ibrahimkoz1983 Год назад +8

    Could you compare the performance of Kotlin and Golang? Kotlin has coroutines which are very similar to goroutines, it simply multiplexes jobs to threads. But it offers structural concurrency which is the greatest thing I've seen lately.

  • @darkarie
    @darkarie Год назад +2

    real language master race

  • @musdevfrog
    @musdevfrog Год назад +1

    I'd like to see more frontend Primeagen in the future, please.

  • @danielscheurwater5500
    @danielscheurwater5500 Год назад

    Lets settle! Thanks for the vid bud :)

  • @TJDeez
    @TJDeez Год назад

    I love go. I started learning it because of your videos. Would love to see a go comparison

  • @austinhoward1035
    @austinhoward1035 Год назад

    Most of our batch servers / micro services at my company are Spring boot and I’ve suggested multiple times that we can consider Go as a way for front end devs familiar with Typescript to relatively easily make contributions to servers but the overwhelming pushback is - Node and Java are easy to hire people for.

    • @ThePrimeagen
      @ThePrimeagen  Год назад +4

      i hate that argument. i think go is really getting easier to hire for every day. Plus there is a TON of devs who don't want to keep getting javascripted

  • @4445hassan
    @4445hassan Год назад

    Is your TS queue a lock-free concurrent queue or does it work because it is single threaded anyways? Is peeking really necessary or could it be avoided, peeking seems kind of impossible in a lock free context to me as a dequeue could happen in an ABA scenario?

  • @epiderpski
    @epiderpski Год назад +6

    This was fantastic! also, usually I put the playback speed to 2x for most people. Max I can do is 1.5x for you and still understand. lol

    • @ThePrimeagen
      @ThePrimeagen  Год назад +1

      i am a winner!

    • @tini_
      @tini_ Год назад +4

      prime is blazingly fast

  • @abel090713
    @abel090713 Год назад

    Blazingly sad is a pretty apt description for all my projects

  • @bendotcodes
    @bendotcodes Год назад +53

    Node is a great beginner language that's for sure. It can perform relatively well enough by scaling up more instances but will be pricier over big load. ❤️ for Golang for an easy learning curve and being much more BLAZINGLY FAST.

    • @ThePrimeagen
      @ThePrimeagen  Год назад +25

      Agreed. Go Lang is definitely the best choice for the balance of developer, velocity and speed

    • @eliasgill2453
      @eliasgill2453 Год назад +1

      Go for the win 🥰

    • @johanw2267
      @johanw2267 Год назад +23

      Node is not a language.

    • @bendotcodes
      @bendotcodes Год назад

      @@johanw2267 You're right! But JS by itself can't do much outside of the browser 🙃

    • @hl7297
      @hl7297 Год назад +1

      @@johanw2267 Your input is pointless here sir. Keep it to yourself.

  • @sasipraveen5257
    @sasipraveen5257 Год назад +5

    Love you Prime ❤

  • @male3399
    @male3399 Год назад

    I was waiting for this video and I was sure that you gonna add that "Blazingly fast" even though they didn't put it

  • @veebeeTV
    @veebeeTV 9 месяцев назад

    That logo made me bust out chuckling so loud i think i scared my neighbors 😅

  • @jpbeckner7980
    @jpbeckner7980 Год назад +1

    Hi, nice video.
    Could you do a part 2, adding Python, GoLang, and Zig to this graph comparison?
    I think it would be nice to see, just out of curiosity.

  • @jacobleslie8056
    @jacobleslie8056 Год назад +1

    Lol... I love the concession "Node is fine for the backend if your site sucks and get's no traffic and you don't care if it performs well."

  • @amanueltigistu8268
    @amanueltigistu8268 Год назад +1

    I would like to see Deno included in these benchmark. it's blazingly Great to use Deno.

  • @ade5324
    @ade5324 Год назад +1

    Do you have recorded live steam where you do these kind of tests?
    Not saying that i doubt your test results, but I'm curious what is your process of making these test, like i wanna see the full coding, how you collect data and stuff like that.

    • @ThePrimeagen
      @ThePrimeagen  Год назад

      If I say I stream one more time on twitch I swear.

    • @ade5324
      @ade5324 Год назад

      @@ThePrimeagen lol sry

  • @M1chlos
    @M1chlos Год назад +14

    :soyjak: Noo, no GO comparison. How am I suppose to claim superiority online now as GO developer.

    • @ThePrimeagen
      @ThePrimeagen  Год назад +5

      I'll be possibly doing that!

    • @M1chlos
      @M1chlos Год назад

      @@ThePrimeagen Great, I've never been happier!

  • @gwendalfernet1961
    @gwendalfernet1961 Год назад

    Hey, nice video, for the Rust side Can you try yo open a thread for managing the vecquedeque and sending message through channels to see how it compares to the mutex?

  • @canonurer6555
    @canonurer6555 Год назад +2

    I like how you said "Real Language"

  • @scotttang6229
    @scotttang6229 Год назад

    You're hilarious! Thanks for sharing!

  • @bitcode_
    @bitcode_ Год назад +3

    Edit skills Tier 3

    • @ThePrimeagen
      @ThePrimeagen  Год назад +3

      Completely agree. Flip is getting too powerful

  • @swanandx
    @swanandx Год назад +3

    Blazingly recived SIGSEV ( core dumped )

  • @tilakmadichettitheappdeveloper

    "the dinosaur is going extent again people !" had me.

  • @AndersonPEM
    @AndersonPEM 8 месяцев назад +1

    Okay now Bun reached stable. Do it again!
    DEW IT!

  • @luccahuguet
    @luccahuguet Год назад

    Awesome! Still waiting the ELIXIR version of that other server
    You PROMISED. gotta keep your promises hehe

  • @absbi0000
    @absbi0000 Год назад

    Good insight

  • @cameronfoale8270
    @cameronfoale8270 Год назад +5

    Be interesting to see how much of the js/rust difference is due to the difference in queue implementations; VecDeque uses a ring buffer which will avoid memory allocation and garbage collection entirely once it reaches steady state, whereas your JS implementations use linked lists with dynamic allocation for all enqueues, which will dramatically increase GC pressure.

    • @ThePrimeagen
      @ThePrimeagen  Год назад +6

      I'll redo it doing a ring buffer, and in zig because I can

  • @thanhtupham4726
    @thanhtupham4726 Год назад

    nice colortheme ! What is your colortheme ?

  • @vinaynk
    @vinaynk Год назад

    I subbed only because of this dudes presentation style. LOL.

  • @AbhinavKulshreshtha
    @AbhinavKulshreshtha Год назад +1

    Does twitch save livestream for later viewing? It is hard to catch livestreams when I live on opposite side of date line.

  • @not_a_human_being
    @not_a_human_being 8 месяцев назад

    "voice and energy for a political video" + "accessible semi-deep dive content for a technical video" + "editing for a social video" = awesome stuff!

  • @didierhoarau7624
    @didierhoarau7624 Год назад

    Thanks for the video. Just a comment on speed for bigger websites...
    For bigger websites it is very likely that there are multiple replicas the API endpoints. Like with Kubernetes (but not necessarily) and a load balancer on top. So if performance is a problem...
    1. You can scale vertically with a bigger machine
    2. You can indeed use a faster technology (rust,...)
    3. You can scale horizontally and increase the number of replicas
    It doesn't mean that you should not use Rust, it's just that if you hit bottleneck with Node or other technologies there are other options.

    • @ThePrimeagen
      @ThePrimeagen  Год назад +1

      this is true. but horizontal scaling as a solution is coming to an end. Its already started to get squeezed in certain geographic regions and I do not see a slow down.
      Vertical scaling will become the new norm and node is very tricky with state to vertically scale. Also you get a ton less for your buck on vertically scaling.

  • @azatecas
    @azatecas Год назад

    This feels the like the DENO Hype-train all over again

  • @quentincaldway
    @quentincaldway Год назад

    My favorite thing about this video is prob all the times you say..."Que"...I'll wait for it.....🤣😂!
    Good stuff as usual ! The fact that I have to literally take notes when I watch your videos should say something...So...Go, Rust, and now Bun (Typescript)..Bruh im just getting my feet wet with React....and its no even mentioned. 😩.
    ~Cheers!

  • @Khari99
    @Khari99 Год назад

    Is that elixir comparison still coming 👀

  • @tobz1000
    @tobz1000 Год назад

    Betteridge's law in action

  • @shahreazneeloy2119
    @shahreazneeloy2119 8 месяцев назад

    Very informative. Please make this video with bun 1.0

  • @leulgirma
    @leulgirma Год назад

    What do you think of .net core do you think it is a worthy to compete?

  • @neo3290
    @neo3290 Год назад

    One way around mutex could be channels. By publishing the data to a VecDeque on another thread, you may not need a lock on it as you'd have passed the ownership to the data to that thread? And run the dequeue part on this thread as well ?

  • @keatonhatch6213
    @keatonhatch6213 Год назад

    That’s a blazingly fast bun spreader lol.

  • @MarlonEnglemam
    @MarlonEnglemam Год назад +2

    what I liked the most about bun is that you can write typescript and JSX and just RUN IT!!!!!!!! without any pre configuration files being all over the place! It feels like this is what javascript or node should have been like since the beginning.

    • @ThePrimeagen
      @ThePrimeagen  Год назад +1

      Yeah, that part is incredible

    • @mariogutierrez4989
      @mariogutierrez4989 Год назад

      There is `tsup` package for node, which uses esbuild. Not sure about JSX, I use `tsup` for ad-hoc CLI scripting

  • @renefernandez360
    @renefernandez360 Год назад +1

    "if I'm not screaming while coding, then what I'm doing with my life"

  • @earthling_parth
    @earthling_parth Год назад

    Prime, is there a reason why you release videos on Monday mornings (US time)? I think you would get more traffic in the afternoon or other times... I don't have much knowledge in the SEO/YT algorithm area so it might be completely wrong, but I'm still curious...

    • @ThePrimeagen
      @ThePrimeagen  Год назад

      negative.
      there are reasons, and if you have my stats you would know too :)

    • @earthling_parth
      @earthling_parth Год назад

      @@ThePrimeagen Gotcha 👍

  • @darkarie
    @darkarie Год назад +4

    we need a jon_gjengset_pilot plugin for the next rust implementation

  • @lesto12321
    @lesto12321 Год назад

    Is it really JS faster at prototyping? how long did it take to write + debug JS and rust?

  • @adampodkowinski2165
    @adampodkowinski2165 Год назад +1

    what font do you use in the terminal?

  • @chuckles2040
    @chuckles2040 Год назад +1

    Bun fails to tell you about these benchmarks... bun is cache'ing EVERYTHING.

  • @LIVE-dm6rc
    @LIVE-dm6rc Год назад

    5:47 ".. blazingly sadly .." 😂

  • @PhilipDenys
    @PhilipDenys 8 месяцев назад

    prime is the DR disrespect of the dev world :D

  • @robby7292
    @robby7292 Год назад

    Segfault in JavaScript hahahaha XD A dream come true

  • @PlayerofNoobishness
    @PlayerofNoobishness 9 месяцев назад

    Can we make sure the tests are not utilizing multi-CPUs?
    I saw a test comparing Golang with Nodejs but when they reduced the CPUs of golang down to 1, go and nodejs were not very different.

  • @herrxerex8484
    @herrxerex8484 Год назад +2

    zig zags into segfault

  • @razvan-mihaiilie7001
    @razvan-mihaiilie7001 Год назад

    On Rust u made workers for each CPU, did u do the same in the node/bun?

    • @ThePrimeagen
      @ThePrimeagen  Год назад

      1 worker on 1 cpu
      I only test on single cpu instances.

  • @teej_dv
    @teej_dv Год назад +14

    F I R S T ?

  • @ivorscott
    @ivorscott Год назад

    mmm mm mmh. I'm seeing big wins in the bun department. Yesir.

  • @lynyrdrossalquiroz2029
    @lynyrdrossalquiroz2029 8 месяцев назад +1

    Can we get an updated reaction for bun 1.0? :)

  • @WaylonWalker
    @WaylonWalker Год назад

    Best project name

  • @mirkosedda3196
    @mirkosedda3196 Год назад +1

    Man i love when u scream: blazingly faaaast ❤️❤️❤️ best content as usual! Im becomong addicted to u and theo.gg ❤️❤️❤️

  • @CGMossa
    @CGMossa Год назад +2

    You said "bake" about bun.
    Nice.

  • @saultube44
    @saultube44 10 месяцев назад

    Did you used Tokyo 🗼? Or just vanilla Rust?

  • @Stumashedpotatoes
    @Stumashedpotatoes Год назад +2

    what about Deno? does Bun beat it on this benchmark?

  • @Cwiet
    @Cwiet Год назад

    I’m frontend dev and I love how other roasts JavaScript and its entire ecosystem as well as the framework-mania. I think we worked hard enough and we fully deserved it 😂.
    I’m discovering Rust currently and make the same with Go last year to get a picture of both. One thing I don’t yet get is a web development (client) using one of these languages. At the first sight it looks to be too complex and bloated. For running an API server I wanted Go to replace my Node instance immediately 😅.

  • @ANDROID_SRB
    @ANDROID_SRB Год назад

    I'm not offended by Rust jokes. It's great to make memes because people use too much "blazingly fast". Subscribed :D Have a nice day!

  • @dailymeow3283
    @dailymeow3283 Год назад

    I think he would be an actor, something like "my name is Earl"

  • @metaltyphoon
    @metaltyphoon Год назад +2

    Can you build it in C#?

  • @tehseensajjad1003
    @tehseensajjad1003 8 месяцев назад +1

    Bun 1.0 just released, would like to see a rematch

  • @psk177
    @psk177 Год назад

    Watching this at 1.5x made my blood pressure spike.