Rust & Zig Combined • Richard Feldman • GOTO 2023

Поділитися
Вставка
  • Опубліковано 28 лип 2024
  • This presentation was recorded at GOTO Copenhagen 2023. #GOTOcon #GOTOcph
    gotocph.com
    Richard Feldman - Functional Programming Language Expert & Author of “Elm in Action” ‪@rtfeldman‬
    RESOURCES
    / rtfeldman
    / rtfeldman
    github.com/rtfeldman
    Links
    www.rust-lang.org
    ziglang.org
    www.roc-lang.org
    ABSTRACT
    Why would someone use both Rust and Zig in the same project? Rust is complex and famous for its borrow checker's memory safety benefits, whereas Zig is famously simple and has no borrow checker. Wouldn't a project want one or the other, rather than both together?
    The compiler for the Roc programming language intentionally uses a combination of Rust and Zig. As it turns out, the circumstances that make this a good choice are not as rare as you might think, and the differences in memory safety between Rust and Zig are also not as big as you might think.
    Come learn about the surprising benefits of combining two languages as different as Rust and Zig! [...]
    TIMECODES
    00:00 Intro
    02:45 Outline
    03:02 Why did we mix Rust & Zig?
    17:40 Memory safety in practice
    39:28 Where to draw the line?
    45:15 Outro
    Download slides and read the full abstract here:
    gotocph.com/2023/sessions/2890
    RECOMMENDED BOOKS
    Richard Feldman • Elm in Action • amzn.to/387kujI
    Dean Bocker • Don't Panic! I'm A Professional Zig Programmer • amzn.to/3ljKT8d
    Tim McNamara • Rust in Action • amzn.to/3ux2R9u
    David Drysdal • Effective Rust • amzn.to/4dAjbdX
    / gotocon
    / goto-
    / goto_con
    / gotoconferences
    #Rustlang #Ziglang #Roclang #Rust #Zig #Roc #ProgrammingLanguages #Programming #FunctionalProgramming #BorrowChecker #MemorySafety #Haskell #Concurrency #RichardFeldman
    Looking for a unique learning experience?
    Attend the next GOTO conference near you! Get your ticket at gotopia.tech
    Sign up for updates and specials at gotopia.tech/newsletter
    SUBSCRIBE TO OUR CHANNEL - new videos posted almost daily.
    ua-cam.com/users/GotoConf...
  • Наука та технологія

КОМЕНТАРІ • 41

  • @luizpbraga
    @luizpbraga 2 місяці тому +53

    love his "2x video speed" energy

    • @SimGunther
      @SimGunther 11 днів тому +1

      Watching at faster speed to get 6x speed energy 😅

  • @bjorn2625
    @bjorn2625 2 місяці тому +14

    Fantastic that you’ve put this online!!

  • @CouchProgrammer
    @CouchProgrammer 5 днів тому

    If I understand correctly what was done, it was moving the "unsafe" Rust code from the core compiler to zig addon. Like with nodejs/etc and FFI.

  • @joshuathomasbird
    @joshuathomasbird 4 дні тому +1

    sometimes running into problems is the problem. It means the road is less traveled or even unpaved.

  • @possumkeys
    @possumkeys 2 місяці тому +15

    😅 I like how this was NOT a talk about Roc lang. 😂

  • @ZenonLite
    @ZenonLite 2 місяці тому +24

    Zig 🤝 Rust

  • @ulrich-tonmoy
    @ulrich-tonmoy 2 місяці тому +9

    Rust and Zig might be the new C++ and C (rust is not to zig what c++ is to c) to continue their legacy to further

    • @user-zy4yh8iw1f
      @user-zy4yh8iw1f 2 місяці тому +2

      Do you mean rust and zig combined is the future?

    • @ulrich-tonmoy
      @ulrich-tonmoy 2 місяці тому +3

      @@user-zy4yh8iw1f yep zig gives you full control where as rust gives many feature and make you do things its way just kind of like c c++

    • @user-zy4yh8iw1f
      @user-zy4yh8iw1f 2 місяці тому +2

      @@ulrich-tonmoy nice take.

  • @j-p-d-e-v
    @j-p-d-e-v Місяць тому +5

    rust + zig = rig

  • @Solid_Fuel
    @Solid_Fuel 5 днів тому +1

    7:30 Elm mentioned!

  • @TechTalksWeekly
    @TechTalksWeekly 2 місяці тому +1

    This talk has been featured in the last issue of Tech Talks Weekly newsletter 🎉 Congrats!

  • @timi_t_codes
    @timi_t_codes 2 місяці тому +1

    Looking forward to this talk 🔥

  • @Alexander_Sannikov
    @Alexander_Sannikov 26 днів тому

    if you're saying that C++ is by design unsafe because it's backwards compatible with C, then zig is just as much unsafe because it's also just as compatible with C.

  • @chewbaccarampage
    @chewbaccarampage 2 місяці тому

    He probably needs to bootstrap the languag, but wants to avoid bugs in the bootstrapped compiler. It took a decade or so before Microsoft was able to build a .Net compiler in C#. I don't build compilers, but I suspect it's very common to cobble together a few tools to bootstrap a language until it's mature before rewriting the compiler in the language of choice. I did try Linux from Scratch once and it's pretty similar where you bootstrap the system with some janky tools before building the production Linux system.

    • @AGeekTragedy
      @AGeekTragedy 2 місяці тому +2

      I think* I've seen another video where Richard said that he didn't have any plans to have Roc be self-hosting. I think he has a particular set of domains in mind within which he is design Roc to be a natural choice compilers just isn't one of them.
      * It's possible I'm confusing him with the Elm guy. I think it applies to both.

    • @brendanhansknecht4650
      @brendanhansknecht4650 Місяць тому +2

      Roc has no plans to self host. Rust is a correct language for the compiler. Zig would be another great choice. Roc isn't the right choice.

  • @Alexander_Sannikov
    @Alexander_Sannikov 26 днів тому

    it's lovely how people keep writing C for their C++ compiler and then complain about C++ safety. std::string is a prefectly safe string implementation with optional runtime checks, but for some reason on these talks people pretend it does not exist.

  • @yorailevi6747
    @yorailevi6747 2 місяці тому

    i just checked the repo for the roc compiler… Why is there a float implementation in zig? isn’t it supposed to be a hardware primitive?

    • @antonf.9278
      @antonf.9278 2 місяці тому +1

      How would you implement hardware primitives when targeting LLVM?
      You can either generate llvm bytecode directly or have an existing compiler do that for you.
      If it's something self-contained like floating point arithmetic and you want to do the same thing as zig, use zig.

    • @brendanhansknecht4650
      @brendanhansknecht4650 Місяць тому

      We don't implement a float in zig. We do implement `Dec` in zig. That is a fixed point decimal type that is more useful for correctness of certain classes of code.

  • @steveoc64
    @steveoc64 2 місяці тому +2

    Heaven and Hell ;)

    • @RiwenX
      @RiwenX 2 місяці тому +4

      Which one is which?

    • @steveoc64
      @steveoc64 2 місяці тому +1

      @@RiwenX yeah, well if you need to ask….. then you are probably already neck deep in the rust koolaide, so no amount of logical discussion will bring any light to the question

    • @RiwenX
      @RiwenX 2 місяці тому +1

      @@steveoc64 In all fairness that's just projection. You sound like a cultist

    • @user-zy4yh8iw1f
      @user-zy4yh8iw1f 2 місяці тому

      ​@@steveoc64Hey, I just wanna know your opinion.

    • @JaconSamsta
      @JaconSamsta Місяць тому +2

      @@steveoc64 Oh wow, what a well reasoned point. Definitely doesn't make you look like an absolute tool

  • @MegaCashB
    @MegaCashB 2 місяці тому

    Is the video speeded up? lol

  • @abiiranathan
    @abiiranathan 2 місяці тому

    I've seen this video before. Why is it now 3 days ago??? Anz it's at 2x. Anyway nice talk

  • @musicalintuition
    @musicalintuition 2 місяці тому +1

    (slightly off topic) I don't know why everyone keeps saying Zig is simple. Over the years I've done a bit of x86 assembly, C, Java, JS, Haskell and Lisp, and yet, there's just something about Zig that keeps on biting me because it never works the way I expect.

    • @brendanhansknecht4650
      @brendanhansknecht4650 Місяць тому +1

      I think it is a competitive statement
      . Simple compared to c++ and rust. That said, zig is still young and changing. Overall, it has a pretty simple to learn core with less sharp edges than C.

  • @programmerdvorak7032
    @programmerdvorak7032 11 днів тому

    many people praise rust's "safety" until they realise that you can't do anything without unsafe code and their unsafe code is full of UB.
    Rust has a very good marketing team... it's all those people who can't call free after a malloc and check for boundaries... and they are a lot.

  • @NeatMemesDotCom
    @NeatMemesDotCom 2 місяці тому +13

    TLDR a dude tried to cut corners while building a new programming language and ended up having to use two new languages. Jesus...

    • @antonf.9278
      @antonf.9278 2 місяці тому +6

      A yes, rust, the language you use when you want to cut corners.

  • @zcizzorhandz5567
    @zcizzorhandz5567 2 місяці тому +3

    Why tf would anyone combine Rust and Zig. Are we that bored? *Are we trying to solve problems or sing Kumbaya?*

    • @maxmustermann5590
      @maxmustermann5590 Місяць тому +2

      There's actually a nice talk about exactly that question. GoThere Composiums or something like that

    • @SimGunther
      @SimGunther 11 днів тому

      ​@@maxmustermann5590Can't find the talk anywhere. Where is it exactly?