Rust's Witchcraft

preview_player
Показать описание
You and I would not be here today if it weren't for my favourite feature of rust, and indeed of any language: Macros.
I've mentioned them in the past, but in today's video I'm explain why they're SO POWERFUL.

🖊️ Corrections are in the pinned ERRATA comment.

🙏🏻 CREDITS & PROMO
Thanks so much to Laund for helping me fix a critical error in this script!
My name is Tris Oaten and I produce fast, technical videos.

👏🏻 Special thanks to my patreon sponsor:
- JC Andrever-Wright
And to all my patrons!
Рекомендации по теме
Комментарии
Автор

ERRATA

1:25 - "The whole language always available" actually means at runtime as well as compile time. So Rust does the latter, but does not have the former. Hmm.
6:27 - typo in title. Should be "Arbitrary compile time execution"

NoBoilerplate
Автор

The idea that you can write valid HTML in your Rust files, with syntax highlighting and full Rust style error checking is just 🤯. Love these videos.

billhurt
Автор

It's time for my regular dose of Rust appreciation

vnldces
Автор

It's nice to see someone talking about macros like this. I think a lot of "Rust influencer" types aren't really aware of exactly what it means? Coming from a C++ background, when I saw the section in the rust book about macros I _immediately_ told my friend (who's very much a rust evangelist) that they looked really powerful and I was impressed by them, but he just didn't care and then started going on about the borrow checker and how the compiler "does everything for you". Your videos are a breath of fresh air that honestly have done more to make me want to get into Rust than any of the endless proselytizing I find a lot of rust devs do.

Blayzeing
Автор

I love macro_rules because macros do indeed rule

AshesOfEther
Автор

The most famous sentence in Rust is: "We can do so much more"

olafbaeyens
Автор

This video sent me over the edge: I'm adding Rust to my Exercism tracks now!

jeffreyjdesir
Автор

I used relatively complex macros for example to be able to declare rust structs and generate the OpenGL/Vulkan data automatically to upload them to the GPU, they are really amazing. If you write your own procedural macro, your errors probably won't be quite as nice (usually just highlighting the whole macro invocation) unless you add errors manually but for your own code that should already be enough. I have some problems with them but I think the Rust team is working on improving them and I can still recommend trying them out!

anderdrache
Автор

Procedural macros really blew my mind. This is beyond what I've seen in any other programming language (perhaps lisp), and is SO USEFUL. Attribute macros and Derive macros save-me a lot of boilerplate and spaghetti code...
Thank you Rust developers for this bless

holmybeer
Автор

7:55
I thought I just saw my own neovim setup right there and was shocked

But then I remembered I got the tool recommendations from you
XD

RenderingUser
Автор

I made a vec3 object in rust and using macros really made implementing the operator traits really easy. Definitely worth learning!

aditeya
Автор

After a year of Rust, I'm thoroughly impressed with what people have done with macros. It's just incredible.

AceofSpades
Автор

Wow, even though I do not yet understand everything perfectly, I can feel the energy with which you produce these videos, thank you so much! :D

FABESTAH
Автор

You have my utmost respect for some of, if not *the* most ideal short, sharp rust lessons.

billbennings
Автор

Just what I needed on a Friday morning

ericng
Автор

This is the one. I've always thought "Yeah, Rust is fine, but other languages give me just as much of all the benefits". But this here. This converted me. Checking your HTML is valid and even running test SQL queries at compile time? Awesome

casperes
Автор

So the Youtube algorithm has been recommending me your videos now and then for a while now… But now I've literally had 30 seconds of brain lag where my mind *insisted* that I know your voice from somewhere else.

When I started to listen to Lost Terminal out of curiosity, I'd never have thought it'd come with a free podcast of Seth nerding out about programming details :D. I'm sold. Thank you for both!

btschaegg
Автор

I always love seeing your Rust talks, I've been into the language for a while but they have really helped me appreciate all that makes Rust so excellent. I have absolutely loved macros myself, they're a complete game changer and I didn't know how much I needed them in other languages until I had them in Rust. In any other language I would bemoan the hefty syntax, but in Rust I never actually mind my code getting large, since I know that I will only ever have to write it once. Once and ONLY once, because I can use the type system to build such powerful abstractions, and where even that falls into monotony, macros pick up the slack by letting me compress repetitive syntax like implement blocks into a single line.

june_m
Автор

Yet another great video. I enjoyed every second. I just started to expand my knowledge about macro! and this is great to have in mind. 👏👏

RootsterAnon
Автор

When I realized that I can run shell commands at compile time and insert the output at comoile time into the source code, I knew that rust easily is the best language

snudget