• zack_overflow Profile Picture

    zack (in SF) @zack_overflow

    3 years ago

    When Zig is safer and faster than Rust: I recently wanted to compare Rust vs Zig, so I wrote a garbage collected bytecode interpreter in both languages It turned out that the Zig version was actually faster AND safer than the Rust version How come?

    23 78 741 182K 219
  • zack_overflow Profile Picture

    zack (in SF) @zack_overflow

    3 years ago

    Garbage collection is a hard problem to solve in Rust, it fundamentally is something that doesn't play nicely with the borrow checker. It's possible to write one in safe Rust, typically using refcounting or arenas+handles, but those seem to be slower than a typical mark/sweep gc

    2 3 78 16K 3
  • mcbobadilla Profile Picture

    Mike Bobadilla @mcbobadilla

    3 years ago

    @zack_overflow @ThePrimeagen

    3 0 37 7K 0
    Download Gif
  • joseph_h_garvin Profile Picture

    Joseph Garvin @joseph_h_garvin

    3 years ago

    @zack_overflow Alas, consistent with my experience that writing unsafe C++ is easier than writing unsafe Rust. I think the key thing is the Rust aliasing model is *too strong*. As you say in your post, you have to avoid forming refs, which kills ergonomics and is too easy to do by accident.

    0 1 17 5K 0
  • lodurel Profile Picture

    Louis Dureuil @lodurel

    3 years ago

    @zack_overflow Interesting post, I agree that writing unsafe rust is difficult. A point you don't cover in the post is how unsafe rust is expected to be encapsulated behind a safe interface, which considerably adds to the difficulty of writing unsafe Rust.

    1 1 16 5K 0
  • jauhararifin10 Profile Picture

    Jauhar Arifin @jauhararifin10

    3 years ago

    @zack_overflow Zig is safer than unsafe rust

    1 0 9 2K 0
  • modularformsboy Profile Picture

    modularformsboy @modularformsboy

    3 years ago

    @zack_overflow Thank you! It's so refreshing to hear someone admit "well I tried for a while but I couldn't figure it out so I gave up" -- it's something that computer (language|system|software) designers *really* need to take to heart when considering why not everyone uses their darling.

    0 0 8 2K 0
  • naasking Profile Picture

    Sandro Magi @naasking

    3 years ago

    @zack_overflow Good project. I doubt the pointer arithmetic in Rust accounts for it all, as those are nearly zero cost with pipelining and instruction scheduling these days. I would guess some extra bounds checking or something.

    0 1 6 2K 0
  • codinbzh Profile Picture

    Frédéric Bonnet 🇺🇦 @codinbzh

    3 years ago

    @zack_overflow @pietmichal Interesting, thanks! I wrote a GC a few years ago in C and expected to use it for my current language project. But things have evolved since, so I wanted to give Rust a try, but after reading your post I think I'll go with Zig instead as it seems more relevant for this task.

    0 1 5 2K 1
  • willfp Profile Picture

    Will FP @willfp

    3 years ago

    @zack_overflow it takes a certain kind of person to test performance and safety by writing a garbage collected bytecode interpreter

    0 0 6 867 0
  • leviska0 Profile Picture

    Iskandarov Lev @leviska0

    3 years ago

    @zack_overflow It seems that you've tried to write zig/c++ style code in Rust, which is a bad idea. First of all, I saw `enum Obj` just as enum, and then you store it inside each kind. The usual way to do that in rust in reverse: enum Obj { Class(ObjClass), //etc }

    1 1 2 812 0
  • KenAKAFrosty Profile Picture

    Ken aka Frosty @KenAKAFrosty

    3 years ago

    @zack_overflow as a relative peasant in both, I'd love to hear what @ThePrimeagen and @jarredsumner have to say here.

    0 0 3 2K 0
  • 1EyedBlindKing Profile Picture

    1 Eyed Blind King @1EyedBlindKing

    3 years ago

    @zack_overflow In your second tweet you straight up say “I had to use unsafe Rust” and then try to say that Zig is safer. Neither of them are safe.

    2 1 1 774 0
  • good_unusually Profile Picture

    unusually_good_looking @good_unusually

    3 years ago

    @zack_overflow but, more importantly, how does it compare to Java? *ducks*

    0 0 3 602 0
  • DiegoFreijo Profile Picture

    Diego Freijo @DiegoFreijo

    3 years ago

    @zack_overflow Nice analysis, thanks for sharing! Have you found other cases where Zig is also safer, faster and/or easier to write?

    0 1 1 2K 0
  • itsmartindaniel Profile Picture

    Martin @itsmartindaniel

    3 years ago

    @zack_overflow cc @ThePrimeagen

    0 0 2 3K 0
  • noktec Profile Picture

    Xavier Bellekens @noktec

    3 years ago

    @zack_overflow cc @kubkon

    0 0 1 6K 0
  • fanoot_u202e Profile Picture

    Fânaț @fanoot_u202e

    2 years ago

    @zack_overflow Ok! What?! Versus the Cs, Rust boons speed; but this result bucks it from the gradient! Flouting tramples, speed brings more Ls; but Cs are clunkier, slower, and more error-prone! How the fuck does Rust slam it’s borrow-checking iron fist between?!? How is real Zig code faster?!

    1 0 1 122 0
  • eLeCtrOssSnake Profile Picture

    Leon O 🇨🇦 @eLeCtrOssSnake

    3 years ago

    @zack_overflow Basically the what I've been saying too.

    0 0 0 262 0
  • oscarsm85309043 Profile Picture

    oscar smith @oscarsm85309043

    3 years ago

    @zack_overflow thoughts on mmtk? they have since pretty advanced gc with in rust.

    0 0 0 298 0
  • anti666tv Profile Picture

    anti666tv @anti666tv

    3 years ago

    @zack_overflow I have written around a dozen byte code interpreters/runtimes in my career. I never needed GC for any of them. Care to elaborate a bit on the use case?

    0 0 0 323 0
  • Download Image
    • Privacy
    • Term and Conditions
    • About
    • Contact Us
    • TwStalker is not affiliated with X™. All Rights Reserved. 2024 www.instalker.org

    twitter web viewer x profile viewer bayigram.com instagram takipçi satın al instagram takipçi hilesi twitter takipçi satın al tiktok takipçi satın al tiktok beğeni satın al tiktok izlenme satın al beğeni satın al instagram beğeni satın al youtube abone satın al youtube izlenme satın al sosyalgram takipçi satın al instagram ücretsiz takipçi twitter takipçi satın al tiktok takipçi satın al tiktok beğeni satın al tiktok izlenme satın al beğeni satın al instagram beğeni satın al youtube abone satın al youtube izlenme satın al metin2 metin2 wiki metin2 ep metin2 dragon coins metin2 forum metin2 board popigram instagram takipçi satın al takipçi hilesi twitter takipçi satın al tiktok takipçi satın al tiktok beğeni satın al tiktok izlenme satın al beğeni satın al instagram beğeni satın al youtube abone satın al youtube izlenme satın al buyfans buy instagram followers buy instagram likes buy instagram views buy tiktok followers buy tiktok likes buy tiktok views buy twitter followers buy telegram members Buy Youtube Subscribers Buy Youtube Views Buy Youtube Likes forstalk postegro web postegro x profile viewer