Skip to content
0:00 / 0:00

#roc#rust#zig

Rust & Zig Combined • Richard Feldman • GOTO 2023

GOTO Conferences

1M subscribers • 95 videos on Hallway • Conference channel

YouTube
  • Recommended by 1 person: 1 on Lobsters.
  • Presented by Richard Feldman, Creator of Roc

Intermediate. Assumes working knowledge.

96K views2 years ago1 recommendation

Programming languagesSystems programmingRustZigLanguage design and type systems

Richard Feldman explains why the Roc programming language compiler uses both Rust and Zig, leveraging the strengths of each language.

This presentation was recorded at GOTO Copenhagen 2023. #GOTOcon #GOTOcph gotocph.com Richard Feldman - Functional Programming Language Expert & Author of "Elm in Action" @rtfeldman @SoftwareUnscripted RESOURCES bsky.app/profile/rtfeldman.bsky.social twitter.com/rtfeldman linkedin.com/in/rtfeldman github.com/rtfeldman Links rust-lang.org ziglang.org 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 Intro Outline Why did we mix Rust & Zig? Memory safety in practice Where to draw the line? 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 twitter.com/GOTOcon linkedin.com/company/goto- instagram.com/goto_con facebook.com/GOTOConferences #Rustlang #Ziglang #Roclang #Rust #Zig #Roc #ProgrammingLanguages #Programming #FunctionalProgramming #BorrowChecker #MemorySafety #Haskell #Concurrency #RichardFeldman CHANNEL MEMBERSHIP BONUS Join this channel to get early access to videos & other perks: youtube.com/channel/UCs_tLP3AiwYKwdUHpltJPuA/join 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. youtube.com/user/GotoConferences/?sub_confirmation=1

Why it's here

1 person recommends this

u/gm3_222in r/Zig • Mentions

On “Could 2025 be the year of Zig (for me)?”

…The alchemist model fits, or perhaps an inventor working on novel machines. One reason outside the language itself the community culture’s very nice (primarily on discord), approaching ruby levels of welcoming-ness. A non-toxic community is very important to me. Sorry to link to prime, but this video by him is musing on the exact same question: link to this video While this video (longer) had some really nice thoughts on how zig achieves safety without the laborious requirements of rust, i.e. more organically: link to this video…

u/Not_N33d3din r/Zig • Mentions

On “[Appreciation post] Spent the last week working through ziglings, zig is becoming my favorite language.”

…that in cpp 11, smart-pointers were introduced which can be used to emulate parts of rust's ownership model. Providing safer allocations to a historically "unsafe" language. If you're interested in looking into this issue on a real world project take a look at the following talk by a language creator that uses both zig and rust in their compiler: link to this video…

u/steveoc64in r/Zig • Mentions

On “To the people coming from Rust: Please don't try to make zig turn out like rust”

https://www.reddit.com/r/rust/s/FNQyqnarkf Leverage zig’s cross compile goodness to add better portability to cargo builds link to this video Roc language mixing rust and zig for different aspects of the project

u/No_Penalty2781in r/Zig • Mentions

On “Why did you pick Zig over Rust?”

Why not use both? [video Use Rust for a high-level stuff Use Zig when you need "unsafe" Rust I mean this feels like a complete stack for me. You have a very good type system from Rust (almost on par with Haskell) and if you are a fan of functional programming you will have a breeze time in Rust. On top of that your code would be really performant (not super optimized like you can do in Zig/C/C++ but very very good by being almost functional) The hard parts starts when you really need to think about the performance and use unsafe. So, the solution is just to use Zig in those places.

u/Not_N33d3din r/Zig • Mentions

On “How safe is Zig in practice?”

…s, I default to using ArenaAllocators wrapping my default allocator so that I can ensure things have been handled properly by the end of the function scope. I actually watched a talk recently that spoke about using zig and rust in conjunction on a mainly rust codebase, I reccomend it if you're curious about how more serious projects cover this: link to this video I would argue that your assumption it is as safe as C++ and less safe than C is incorrect on the notion that zig has no global allocators, encouraging allocator passing which signal to the developer when allocations are happening, runtime bounds checking, superior error handling, null safety, and both defer and errdefer keyword for ensurin…