Rust's Witchcraft

  Переглядів 167,285

No Boilerplate

No Boilerplate

Рік тому

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.
❤️ If you would like to support what I do, I have set up a patreon here: / noboilerplate - Thank you!
📄 All my videos are built in compile-checked markdown, transcript sourcecode available here github.com/0atman/noboilerplate this is also where you'll find links to everything mentioned.
🖊️ Corrections are in the pinned ERRATA comment.
🦀 Start your Rust journey here: doc.rust-lang.org/stable/book/
🙏🏻 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.
Follow me here / 0atman
Website for the show: noboilerplate.org
Come chat to me on my discord server: / discord
If you like sci-fi, I also produce a hopepunk podcast narrated by a little AI, videos written in Rust! www.lostterminal.com
If urban fantasy is more your thing, I also produce a podcast of wonderful modern folktales www.modemprometheus.com
👏🏻 Special thanks to my patreon sponsor:
- JC Andrever-Wright
And to all my patrons!

КОМЕНТАРІ: 632
@NoBoilerplate
@NoBoilerplate Рік тому
ERRATA 0:21- link should be github.com/0atman/noboilerplate 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"
@CaptainOfDoom
@CaptainOfDoom Рік тому
I panicked for a second there
@pedrobraz2809
@pedrobraz2809 Рік тому
0:21 it's com/0atman not com:0atman
@RenderingUser
@RenderingUser Рік тому
@@CaptainOfDoom must have left something unwrapped then.
@NoBoilerplate
@NoBoilerplate Рік тому
@@pedrobraz2809 well spotted! I muddled up git/http address obviouly, woops!
@precumming
@precumming Рік тому
I was wondering if there was a new permissable link format
@billhurt3644
@billhurt3644 Рік тому
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.
@NoBoilerplate
@NoBoilerplate Рік тому
Rust's incredible isn't it? Though the syntax highlighting is down to the editor, I found that most editors highlight it really well! And of course once the web frameworks (like yew.rs) become more mature, folks will write editor plugins that highlight the html really well, just as JSX has!
@warpspeedscp
@warpspeedscp Рік тому
@@NoBoilerplate rsx for the win
@NoBoilerplate
@NoBoilerplate Рік тому
@@warpspeedscp Really great standard here crates.io/crates/syn-rsx/reverse_dependencies
@warpspeedscp
@warpspeedscp Рік тому
@@NoBoilerplate wow, i didn't realise people were already working on thos
@NoBoilerplate
@NoBoilerplate Рік тому
@@warpspeedscp Yeah! The macro I demoed in the video uses syn-rsx behind the scenes, loads do!
@user-vn9ld2ce1s
@user-vn9ld2ce1s Рік тому
It's time for my regular dose of Rust appreciation
@NoBoilerplate
@NoBoilerplate Рік тому
Likewise friend, thank you so much :-)
@eymenu7281
@eymenu7281 Рік тому
Lol
@eboatwright_
@eboatwright_ Рік тому
same
@drew-et1mm
@drew-et1mm Рік тому
@@NoBoilerplate Thanks doc 👨‍⚕️
@emmavdev
@emmavdev Рік тому
My Friend who doesnt like Rust that much went "Oh, its just Rust D sucking" when I sent her this channel lmao
@olafbaeyens8955
@olafbaeyens8955 Рік тому
The most famous sentence in Rust is: "We can do so much more"
@NoBoilerplate
@NoBoilerplate Рік тому
"Hold my beer"
@KohuGaly
@KohuGaly Рік тому
and the most infamous sentence continues: "...once we resolve the 5-year-old soundness issues in this laundry list of systems"
@mannycalavera121
@mannycalavera121 Рік тому
@@KohuGaly example?
@qwertyqwerty-jp8pr
@qwertyqwerty-jp8pr Рік тому
@@mannycalavera121 there is quite a bit of soundness issues, but they don’t really affect real code
@mannycalavera121
@mannycalavera121 Рік тому
@@qwertyqwerty-jp8pr give me an example
@TobiasSN
@TobiasSN Рік тому
I love macro_rules because macros do indeed rule
@NoBoilerplate
@NoBoilerplate Рік тому
that = true
@raffimolero64
@raffimolero64 Рік тому
Still watching declarative macros 2.0 though, stuff looks a lot cleaner, shinier, and more consistent with the module system.
@TobiasSN
@TobiasSN Рік тому
@@raffimolero64 Yeah, declarative macros 2.0 looks so much better! Can't wait for it to be in stable
@daishes
@daishes 9 місяців тому
I though i was the only one that read it as "MACRO RULES!" It always sounded like a joke to me
@hashtags_YT
@hashtags_YT 8 місяців тому
@@daishes Half the time it's precisely that, other half it's like the fundamental rules of the universe.
@Blayzeing
@Blayzeing 10 місяців тому
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.
@NoBoilerplate
@NoBoilerplate 10 місяців тому
Right! As I say in a few of my earlier videos, as a python developer, I didn't care about memory safety at all - I never had to! It's a bad selling point when there are 10 other LIFE CHANGING features to talk about :-)
@Blayzeing
@Blayzeing 10 місяців тому
@@NoBoilerplate Totally. Looking forward to watching more of your content! Again, just absolutely loving the no-nonsense, straight-forward and balanced approach you have to topics.
@snudget
@snudget 4 місяці тому
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
@NoBoilerplate
@NoBoilerplate 4 місяці тому
RIGHT
@jeffreyjdesir
@jeffreyjdesir Рік тому
This video sent me over the edge: I'm adding Rust to my Exercism tracks now!
@NoBoilerplate
@NoBoilerplate Рік тому
Fantastic! It's not the easiest language to learn, my biggest advice is to read the error message twice, it's usually got the answer! also: - The Rust Book - Rustlings - fasterthanli.me - the rest of my videos...! Do come chat on my discord over in #newbie-advice if you get stuck, GOOD LUCK!
@theherk
@theherk Рік тому
@@NoBoilerplate Great recommendations. Love fasterthanlime; also Jon Gjengset.
@cotneit
@cotneit Рік тому
@@NoBoilerplate Don't forget Jon Gjengset! Love his and fasterthanlime's content, it's quite in-depth yet easy to follow
@rumplstiltztinkerstein
@rumplstiltztinkerstein Рік тому
The borrow checker, macros and how generics are implemented are the bumpiest parts of learning the language. Everything else is easier to understand in Rust than other languages. You will love it when your code compiles and there is almost no bugs at all in your system.
@olafbaeyens8955
@olafbaeyens8955 Рік тому
After the obligatory headache in Rust it gets better :-)
@AceofSpades5757
@AceofSpades5757 Рік тому
After a year of Rust, I'm thoroughly impressed with what people have done with macros. It's just incredible.
@NoBoilerplate
@NoBoilerplate Рік тому
Yeah! And There's SO much more we could do!
@holmybeer
@holmybeer Рік тому
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
@NoBoilerplate
@NoBoilerplate Рік тому
Such a great feature THAT NO-ONE TALKS ABOUT OMG!
@vitalyl1327
@vitalyl1327 Рік тому
Lisp, Forth, Converge, Nemerle, Template Haskell, and a lot more.
@NoBoilerplate
@NoBoilerplate Рік тому
@@vitalyl1327 Yeah! Great feature that I don't see why couldn't be in every language. Though Template Haskell has it's detractors.
@micahrufsvold
@micahrufsvold Рік тому
@@vitalyl1327 Julia too! I think Julia and Rust are kindred spirits.
@vitalyl1327
@vitalyl1327 Рік тому
@@micahrufsvold yes! And Julia front-end is based on Scheme, which makes it pretty natural to extend.
@anderdrache8504
@anderdrache8504 Рік тому
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!
@NoBoilerplate
@NoBoilerplate Рік тому
Absolutely, it's a developing area, as Macros usually are. But what a feature ALREADY!
@RenderingUser
@RenderingUser Рік тому
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
@NoBoilerplate
@NoBoilerplate Рік тому
ha! AstroNvim *is* pretty great.
@RenderingUser
@RenderingUser Рік тому
@@NoBoilerplate agreed One of the best neovim setups
@aditeya1024
@aditeya1024 Рік тому
I made a vec3 object in rust and using macros really made implementing the operator traits really easy. Definitely worth learning!
@NoBoilerplate
@NoBoilerplate Рік тому
That's so cool! Did you publish on crates.io?
@aditeya1024
@aditeya1024 Рік тому
@@NoBoilerplate While I could, i'm fairly certain there are better implementations out there. What I built is part of a ray tracer implementation which I learned to build from a tutorial. I found the macros on stack overflow when trying to find an elegant solution to the problem.
@sekoia2812
@sekoia2812 Рік тому
@@aditeya1024 ohh, please link! I'm doing the exact same thing and my vec3 file is ~300 lines of `impl Add for Vec3` etc..
@ZKtheMAN
@ZKtheMAN Рік тому
@@aditeya1024 Was the tutorial "Ray Tracing in One Weekend", by any chance?
@aditeya1024
@aditeya1024 Рік тому
@@ZKtheMAN yes it was
@ericng8807
@ericng8807 Рік тому
Just what I needed on a Friday morning
@RoamingAdhocrat
@RoamingAdhocrat Рік тому
Captain, it's Wednesday
@casperes0912
@casperes0912 Рік тому
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
@NoBoilerplate
@NoBoilerplate Рік тому
People LOVE to forget the innovations of lisp! Do start with the book, it's really well written and approachable! doc.rust-lang.org/stable/book/
@casperes0912
@casperes0912 Рік тому
@@NoBoilerplate thanks. I never really looked much at Lisp. Too many parentheses to see the beauty beyond it. But made a few compilers and interpreters for fun so might take a jab at a Lisp one sometime too to get friendly with it. Rust documentation generally seems nice and good.
@ducksies
@ducksies Рік тому
FINALLY, after so many decades, other languages are beginning to look into what Lisp macros have to offer.
@NoBoilerplate
@NoBoilerplate Рік тому
EXACTLY. I'm excited by Rust because it takes most of the features I love from Lisp and Haskell and hides it inside C's clothing :-D
@kuhluhOG
@kuhluhOG 8 місяців тому
@@NoBoilerplate Quite frankly, imo Macros (especially Macros as powerful as LISPs) are more of a downside than an upside when working together with a lot of people. Seriously, is it so hard to use the same code for runtime and compile time generation (oh, wait, it's not, Zig has done it).
@NoBoilerplate
@NoBoilerplate 8 місяців тому
@@kuhluhOG You've missed the point: Rust macros have full access to the system - disk and network etc. SQLx can't be written in zig's comptime because it has no access to the system at compile time. You can write zig's comptime inside rust macros, but not the other way around. Proof: crates.io/crates/comptime BTW rust ALSO has what you want: doc.rust-lang.org/reference/const_eval.html
@kuhluhOG
@kuhluhOG 8 місяців тому
@@NoBoilerplate About Rust's sqlx crate: I think you mean the query! macro to not be possible because everything else is in fact possible with Zig's comptime. Also, full network and disk access at compile time is not necessarily wanted by everyone (for example the C++ committee voted against giving std::embed because they thought of it as too insecure; yes, really...). But I don't think you get why I dislike Macro's that much. It's not about the power of network access or the like, it's that you can embed or even invent your own language inside of it and that it has essentially it's own rules compared the rest of the language (to a point where one can consider it it's own PL). While this may not be too bad for a project (you can straight up outlaw these kinds of things), you can't do that on an ecosystem level. This leads to ecosystem divergence on not a choice, but understandability level. Also, const_eval is quite limited compared to Zig's comptime
@NoBoilerplate
@NoBoilerplate 8 місяців тому
@@kuhluhOG Rust isn't a theoretical language, it's been out for 16 years with macros. Your fears have not come true. Macros are FINE, honestly 🙂
@billbennings8990
@billbennings8990 Рік тому
You have my utmost respect for some of, if not *the* most ideal short, sharp rust lessons.
@NoBoilerplate
@NoBoilerplate Рік тому
Thank you so much Bill, that's so kind of you to say. I hope to write many many more!
@NoBoilerplate
@NoBoilerplate Рік тому
blazingly fast!
@FABESTAH
@FABESTAH Рік тому
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
@NoBoilerplate
@NoBoilerplate Рік тому
My pleasure! Thank you for saying so :-)
@ericbwertz
@ericbwertz 10 місяців тому
Be careful -- that's how you were tricked into getting "vaccines" of extremely dubious value. Macros may or may not be the right code injection for you!
@btschaegg
@btschaegg Рік тому
So the UKposts 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!
@NoBoilerplate
@NoBoilerplate Рік тому
oh amazing! I love it when the stars align for that! Hey, I have two other podcasts you might like, one that does exist and one that doesn't yet but you should keep an eye on: 1. Modem Prometheus, urban fantasy written by my friend Neil and performed by my friend Kate. I produce and write music (also I read the credits) If you love Buffy or anything Neil Gaiman has been involved in, you'll love this first episode: ukposts.info/have/v-deo/l4N1oouNf3d0lWg.html 2. /usr/stories podcast. Similar to Lost Terminal, hard scifi but set this time in the past. Season 1 in pre-production, probably will drop in a month or so twitter.com/usrstories Thank you!
@btschaegg
@btschaegg Рік тому
@@NoBoilerplate Got it, thanks for the heads up! :)
@lucky-segfault4219
@lucky-segfault4219 Рік тому
Procedural macros are unreasonably powerful. I'm working on one which can validate a SQL-like statements used by SurrealDB against a schema. So far it will correct your clause ordering, inject variables with proper escaping, ensure fields exist when you query against a schemaful table, and parse the results into any serde compatible type. The possibilities are endless, and would be even more so if the tokeniser could parse backticks.
@NoBoilerplate
@NoBoilerplate Рік тому
It's SO powerful, right? I love it!
@RootsterAnon
@RootsterAnon Рік тому
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. 👏👏
@NoBoilerplate
@NoBoilerplate Рік тому
thank you so much!
@CaptainOfDoom
@CaptainOfDoom Рік тому
The most complex thing I did with macro_rules! was a macro I called "fluid" that (recursively) turned a series of statement-looking lines into a builder chain, including support for nested builders. The whole thing is only like 20 lines, but *relatively* parseable, if you're used to recursive code at least. I cannot possibly imagine doing that on a text replacement-based "macro" engine.
@NoBoilerplate
@NoBoilerplate Рік тому
omg like clojure's arrow macro? (->) I LOVE IT PLEASE TELL ME THE PACKAGE NAME (don't use urls, yt hates that)
@CaptainOfDoom
@CaptainOfDoom Рік тому
@@NoBoilerplate I'll be honest, I never thought about publishing it (or anything, for that matter). I will try doing so over the weekend, and get back to you on that!
@xValerikx
@xValerikx Рік тому
@@CaptainOfDoom Please post it here if/when you do publish! :)
@katech6020
@katech6020 Рік тому
Don't forget to share it
@diadetediotedio6918
@diadetediotedio6918 Рік тому
@@NoBoilerplate I do know the macro "pipeline" from my searches, you can do things like: let length = pipe!( "abcd" => [len] => (as u32) => times(2) => [to_string] ); // from their documentation I did not use it yet, but I saved as fav because it looks so cool
@wannabelikegzus
@wannabelikegzus Рік тому
Okay, I only understood like 10% of that, but I'm stoked to learn more.
@NoBoilerplate
@NoBoilerplate Рік тому
It's a complex topic! Check out my other rust videos 😁
@oh_suiiii
@oh_suiiii Рік тому
“The dream of Scala is alive in Rust", I love it
@NoBoilerplate
@NoBoilerplate Рік тому
I am so sad that scala has deprecated xml literals - what a cool feature! Ah well, we have Rust now :-)
@Mesqa3o
@Mesqa3o Рік тому
You are really good, the sound is so comfy that I can see the video and enjoy the information. Thanks for the great video
@NoBoilerplate
@NoBoilerplate Рік тому
Thank you so much for saying :-) I have a lot of practice speaking because I am currently on season 11 of my hopepunk/scifi podcast, Lost Terminal. I'd love for your feedback on it! Episode 1 is here ukposts.info/have/v-deo/qGOTeHtwoqmrrpc.html
@wtcxdm
@wtcxdm Рік тому
Thanks for the interesting video as always! Still halfway through the book but it’s really good to see so many new, fun things to learn.
@NoBoilerplate
@NoBoilerplate Рік тому
Fantastic! You're gonna have a great time, and thanks for your support friend :-)
@julienmarcuse9023
@julienmarcuse9023 Рік тому
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.
@NoBoilerplate
@NoBoilerplate Рік тому
That's right! But don't forget (I beg you) that proc macros can access the disk and network. What might you do with that power?
@philippecholet9484
@philippecholet9484 Рік тому
@@NoBoilerplate In a proc macro, I did parse the library dependencies (reading "Cargo.toml") with the "cargo_toml" crate because my advent of code binary needs a solver library for each puzzle, list that evolves with time.
@NoBoilerplate
@NoBoilerplate Рік тому
@@philippecholet9484 so meta, I love it!
@averageyoutubeenjoyer5865
@averageyoutubeenjoyer5865 Рік тому
Love your videos, seeing the potential of procedural macros I would love you see you go in deapth for that topic and explain the syntax and how they are used. Amazing video man, love your work
@NoBoilerplate
@NoBoilerplate Рік тому
Thank you! I have noted that, and it looks like I will indeed do a part 2 in the future!
@RinLovesYou
@RinLovesYou Рік тому
every time i miss hearing you talk about rust, you're right there! great video as always~
@NoBoilerplate
@NoBoilerplate Рік тому
Thank you so much! I'm on a regular 2 week schedule now on fridays. (though Patrons get the video a day early!) Perhaps you'd like to hear me talk about science and tech through the lens of a fictional AI? That's what my podcast Lost Terminal is about! ukposts.info/have/v-deo/qGOTeHtwoqmrrpc.html
@yankee-in-london
@yankee-in-london Рік тому
love your videos ... always smart and thoughtful ... keep on keeping on; you make a difference.
@NoBoilerplate
@NoBoilerplate Рік тому
That's so kind of you to say Ken, thank you, I will! :-)
@Artentus
@Artentus Рік тому
Procedural macros really allow you to do some black magic. I once wrote one that allows the user to turn very verbose parser combinator code into a concise DSL with infix operators.
@NoBoilerplate
@NoBoilerplate Рік тому
yaaaas did you publish?
@Artentus
@Artentus Рік тому
I did, the crate is called langbox
@TheFreeSpiritKID
@TheFreeSpiritKID Рік тому
wat?
@NoBoilerplate
@NoBoilerplate Рік тому
@@Artentus Amazing! crates.io/crates/langbox
@Artentus
@Artentus Рік тому
​@@NoBoilerplate thanks!
@Saeid-Za
@Saeid-Za Рік тому
You really make my day by uploading a new video, keep up the excellent work ❤️
@NoBoilerplate
@NoBoilerplate Рік тому
That's so kind of you, thank you!
@somebody_on_the_internetz
@somebody_on_the_internetz Рік тому
I really like the way you narrate this video. This really motivates me to finally have a deeper look at how to write Marcos in rust. Aside have you ever had a look at type providers in rusts cousin F#? There is a SQL type provider that checks your query definitions at design and compile time. Also exists for CSV, XML and others. If Microsoft put a little more love into it it would blow C# out of the water.
@Mikenight120
@Mikenight120 Рік тому
I am here because ThePrimeagen allowed me to discover this channel and find curiosity in NeoVim and Rust hoping to enjoy this journey! Love the channel content!
@NoBoilerplate
@NoBoilerplate Рік тому
Thank you so much! Primeagen is such a nice chap, welcome!
@malteesch
@malteesch Рік тому
This has grown to be my favorite channel on yt. Nice vid as always!
@NoBoilerplate
@NoBoilerplate Рік тому
Thank you! You're too kind!
@nahiyanalamgir7056
@nahiyanalamgir7056 7 місяців тому
This is mind blowing!
@andredasilva6807
@andredasilva6807 Рік тому
as always an amazing new rust video. macros are so good.. i need to get more into it.
@jongeduard
@jongeduard Рік тому
Thanks. Great addition to what I have read in chapter 19.5 of the The Rust Programming Language book. The book goes a bit more into detail (and the Reference and other docs probably even a lot more, but I am not there yet), but this video has greater examples with HTML and SQL. We keep learning. :)
@NoBoilerplate
@NoBoilerplate Рік тому
Thank you so much! Yes, The Book is wonderful, as is Rust By Example and Rustlings. I imagine Amos over at @fasterthanlime (fasterthanli.me) will one day write the definitive article on Macros and then we'll all be enlitened!
@AgentXegy
@AgentXegy Рік тому
I want to point out that C++ got constexpr and consteval, they are compile time expression and can be made into function that run in compile time.
@NoBoilerplate
@NoBoilerplate Рік тому
Can't do side-effects though, right? Can they access the network at compile time?
@somenameidk5278
@somenameidk5278 6 місяців тому
@@NoBoilerplate i've seen a demo that printed ASCII art at compile time at different scales based on a size parameter, so some side effects can be done
@NoBoilerplate
@NoBoilerplate 6 місяців тому
@@somenameidk5278 I'm delighted to inform you that this sounds like a bug in the compiler's handling of constexpr "neither std::cout
@cyrilemeka6987
@cyrilemeka6987 3 місяці тому
​@@NoBoilerplateamazing
@invitapriore
@invitapriore Рік тому
Hey, I just want to thank you for these videos. This channel is one of the few I've found that is targeted to experienced practitioners, presented even-handedly, and isn't just horrendously off-putting from an aesthetic standpoint, so I hope you'll keep going for a long time. Re proc macros, I'm still a low-intermediate Rust user and hadn't previously encountered anything like Yew's html macro in the wild, and so I think I assumed when I saw that they consume TokenStreams that they necessarily took in basically Rust-adjacent syntactic forms. I'm glad to see that they're much more powerful than that! They do make me long for an intermediate point on the simplicity vs. power scale, since Rust has solutions for both extremes but nothing right in the middle, which is how I would characterize Common Lisp's or Clojure's "defmacro" since these allow you to transform and generate syntax with simple list operations and don't require all the machinery of parsing (CL of course has reader macros too, which are basically equivalent to proc macros in their flexibility to define new syntax entirely). Of course that's a consequence of Lisp syntax being composed of lists already and so there's likely no possible analog in Rust, I just miss that particular affordance. Still, it's amazing to have a feature this expressive in a language that also permits such explicit control of details like memory layout. It's truly an excellent environment to work in.
@NoBoilerplate
@NoBoilerplate Рік тому
Thank you so much for saying, I really appreciate it. I am indeed targeting just those sort of users, and I aim to not just continue, but ramp up this year, with some tasteful adverts, I might even be able to go full-time youtube! Check out macro_rules! for a simple solution that does the parsing for you, lisp style!
@ZacksArtz
@ZacksArtz Рік тому
You convinced me to try using Rust (I was previously an avid golang user) and I'm loving it
@NoBoilerplate
@NoBoilerplate Рік тому
Go is great! You're gonna have a great time with Rust, it punches through both go's ceiling and floor to be lower-level and higher level than it. To get the async ergonomics you're used to with go, learn tokio, it's the de-facto standard. Do watch my videos and read all of fasterthanli.me and The Rust Book! Have fun!
@jakubbartczuk3956
@jakubbartczuk3956 11 місяців тому
Man everything you made that UKposts suggests is gold, love your content
@NoBoilerplate
@NoBoilerplate 11 місяців тому
My pleasure! Do check my other videos, they're in the same style, and I do interesting non-rust videos too!
@Turalcar
@Turalcar Рік тому
I avoid macros whenever I can. The most complicated one I had to write is to verify that an array is sorted. And I will replace it with a const function whenever that becomes possible
@NoBoilerplate
@NoBoilerplate Рік тому
I daresay we will get const functions, just as we got macro_rules! compile-time matchers, anyone can write this feature for us today, within a macro!
@syudagye2837
@syudagye2837 Рік тому
One of the best example of procedural macro i know, is the derive_xrb! macro from the WIP xrb crate. It includes custom syntax to implement the types needed for X11, as well as serialization and deserialization. This is awesome work from Antikyth !!!
@NoBoilerplate
@NoBoilerplate Рік тому
Fantastic!
@cherdak_turista
@cherdak_turista 11 місяців тому
Amazing! Thank you. Would be cool to to see DSL with Rust macro video from you as well)
@NoBoilerplate
@NoBoilerplate 11 місяців тому
noted, thank you!
@theninjascientist689
@theninjascientist689 Рік тому
This is just what I needed after a long day of fixing issues in a java codebase caused by over-reliance on boilerplate.
@NoBoilerplate
@NoBoilerplate Рік тому
All those extra bloated features in java, all they need was proper macros in 1996!
@formulaetor8686
@formulaetor8686 Рік тому
Your voice is super soothing and distracts me from focusing on what you're explaining (can't blame you though lol). Jokes apart, nice and enjoyable content packed with information. Could you also please make videos on low level/unsafe rust too because there aren't many.
@NoBoilerplate
@NoBoilerplate Рік тому
That's so kind of you to say, thank you! I'm afraid it'll be a while till I do a deep-dive on unsafe and low-level, because I don't work with that level typically. I've talked about it in half of this video, and I'm very happy with the high-level description: ukposts.info/have/v-deo/iKV-jI2aZ66jrGQ.html If you would like to hear my voice in a format where I'm TRYING to be soothing, I'd love to know what you think of my AI/hopepunk scifi podcast, Lost Terminal ukposts.info/have/v-deo/qGOTeHtwoqmrrpc.html
@formulaetor8686
@formulaetor8686 Рік тому
@@NoBoilerplate Hello, I've just listened to the lost terminal podcast and I could relate to the satellite because I'm lonely too. Again, could just listen the whole podcast just for your soothing voice, but as for the podcast content, I personally didn't find it really engaging and entertaining 😅 (super sorry, but please don't feel bad and think that you're making bad content, its just my personal opinion and there are many viewers apart from me who love the podcast).
@NoBoilerplate
@NoBoilerplate Рік тому
@@formulaetor8686 Quite alright! I produce and write the music for Modem Prometheus, maybe you'd like it instead? It's very VERY different ukposts.info/have/v-deo/l4N1oouNf3d0lWg.html&embeds_euri=https%3A%2F%2Fmodemprometheus.com%2F&feature=emb_title
@redcrafterlppa303
@redcrafterlppa303 Рік тому
I wrote a macro library that mangels the correct jni name based on given parameter types and package info. It also encloses your code so you can return a result and it will throw a java exception if it's an error.
@gdjhd1700
@gdjhd1700 Рік тому
I currently don't have the time or motivation jet to lern Rust and have a hard time to understand the syntax as a java user (because of school). So I like your funny words, magic man.
@NoBoilerplate
@NoBoilerplate Рік тому
I wrote just the video for you, Rust is easy! ukposts.info/have/v-deo/e3qlqqScp4OHook.html
@kaiiboraka
@kaiiboraka Рік тому
I like your funny words, magic man. I was with you until about halfway through and then I had no idea what was happening, but it sure sounded impressive! I'm still kind of scared of rust, to be honest. Maybe I'll come around eventually lol
@NoBoilerplate
@NoBoilerplate Рік тому
Ha! Macros are so weird aren't they! Don't worry, you don't have to write a single one to write normal Rust. It's like writing C extensions for python/js/ruby etc, it's mostly wizards who do that for us! You sound like you need a relaxing video to watch after this one, I prescribe ukposts.info/have/v-deo/e3qlqqScp4OHook.html (let me know what you think!)
@michaelschnell5633
@michaelschnell5633 Рік тому
Thanks a lot for covering this advanced issue ! I am impressed about what Rust macros can do !! E..g. executing code at design time e.g.with the database crate. I suppose it is possible to write code that is to be executed as well at design time as in the compiled program, when executed. But this is not a completely unparalleled feature. *Delphi* - in it's combination of language / compiler, library, and IDE - also features database access at compile time to try out and configure the communication with a database server. Moreover Delphi uses the same paradigm for it's "WYSIWYG" GUI designer. Here the code at compile time displays the GUI under constructions (allowing to use the mouse for editing the design) and writes a file (similar to jason) with the construction and functionality rules. As runtime the (essentially) same code reads that file (in fact embedded in the executable as a resource) and displays the GUI to be used by the business logic. I do hope that something similar once will be provided by an appropriate Rust crate (of course based on Macros), e.g. based on egui / OpenGL. Same will allow to create projects that can be compiled for multiple platforms including Browser / webassembly. Thanks for listening
@NoBoilerplate
@NoBoilerplate Рік тому
The great thing with HTML, as a universal interface language, there are MANY visual designers that you can build your UI in, then just template them into your server code with (say) rocket.rs.
@michaelschnell5633
@michaelschnell5633 Рік тому
@@NoBoilerplate Can you comment on " I suppose it is possible to write code that is to be executed as well at design time as in the compiled program, when executed"
@NoBoilerplate
@NoBoilerplate Рік тому
@@michaelschnell5633 What does "design time" mean? I'm Familiar with compile time and run time?
@michaelschnell5633
@michaelschnell5633 Рік тому
​@@NoBoilerplate My dream always was a system that allows for a decent local GUI and and a bowser based GUI (i.e. local and remote GUI to choose from). With Rust this seems to be possible by Webasm and WebGL (e.g. vi egui) . But nowadays it might be appropriate to use html for this by implementing a browser in the desktop app. Now for design time a WISYWIG HTML editor might be implemented by a Rust Macro. I just don't yet see how to have the designer easily bind business logic functionality within the GUI design flow. But I am no expert on HTML stuff at all :) -Michael
@NoBoilerplate
@NoBoilerplate Рік тому
@@michaelschnell5633 Ah! I see! I'd recommend trying out tauri.app and doing their tutorial, getting a simple app working, and taking it from there! Lots of videos on youtube can help you design html interfaces, it's really not too complicated, I promise 🙂
@tonhom260
@tonhom260 8 місяців тому
just new to this rust, really love this concept !!!
@NoBoilerplate
@NoBoilerplate 8 місяців тому
It's *amazing*, so much of what I like in one languages. Do check out this short playlist of my best Rust videos for more info ukposts.info/have/v-deo/p4lhjK2Ehomr0mg.html
@tonhom260
@tonhom260 8 місяців тому
i will surely thankyou dude@@NoBoilerplate
@ShaderKite
@ShaderKite Рік тому
Loved this video! Traits are my favorite Rust feature, but macros are a very close second! Though, I'd appreciate it if next time maybe you mentioned some bad things as well :P E.g. here would be the cost we pay in compilation time (esp. for procedural macros)
@NoBoilerplate
@NoBoilerplate Рік тому
I've mentioned that in the past in more general Rust videos, it's a price I'm very happy to pay! :-D
@anamewithnoface1330
@anamewithnoface1330 Рік тому
I don't know why I like these videos so much, I have never written a single character of anything resembling code in my entire life.
@NoBoilerplate
@NoBoilerplate Рік тому
You're so kind! I wonder if you'd like a scifi story read by me, if that is the case? I'd love to know what you think of Lost Terminal ukposts.info/have/v-deo/qGOTeHtwoqmrrpc.html
@anamewithnoface1330
@anamewithnoface1330 Рік тому
@@NoBoilerplate I watched the first three episodes. I'm very interested! I find it actually captivating to think about what an AI actually 'thinks' about. Though Seth is very personified for an AI, he is quite endearing. looks to me that I have something new to listen to on my drives to work! thanks for your great work and dedication to the story!
@NoBoilerplate
@NoBoilerplate Рік тому
@@anamewithnoface1330 I'm so pleased! I too love listening to podcasts while on long journeys - perfection! You can listen to LT on spotify, itunes or wherever you listen to music and audio - more handy than youtube when in the car! If you'd like to chat about LT (or indeed NB), come and say hi on my Discord server!
@thedeathstar420
@thedeathstar420 2 місяці тому
I primarily code in Julia and it has this feature too. Really cool way of programming
@tristanmisja
@tristanmisja Рік тому
This video has made me decide to start using Rust.
@NoBoilerplate
@NoBoilerplate Рік тому
Wonderful! Do check out my other videos, there's so much good stuff here! ukposts.info/have/v-deo/oZaSgKFsrWmImmQ.html
@legendrags
@legendrags 5 місяців тому
I never thought rust would be so easy yet so complicated. Love it.
@NoBoilerplate
@NoBoilerplate 5 місяців тому
It's terrific! Do check my high-level intro to Rust: ukposts.info/have/v-deo/p4lhjK2Ehomr0mg.html Sorry to be picky (kind of my job!) but I think of Rust in the opposite terms: It's not easy, but it is simple.
@legendrags
@legendrags 5 місяців тому
@@NoBoilerplate If I was able to understand it, then it is easy bro.
@_fudgepop01
@_fudgepop01 Рік тому
YEAH OK FINE. I GET IT. YOUVE CONVINCED ME. Next WASM experiment I try - or reverse engineering/modding experiment - will almost certainly be in Rust because your way of breaking down the features in a digestible manner and into layman’s terms is absolutely bloody brilliant. Thank you, or heck you - time will tell (though I’m quite sure it’ll be the former)
@NoBoilerplate
@NoBoilerplate Рік тому
I'm so pleased! You'll have such a great time, make sure you watch the rest of my rust series, starting with this one on wasm: ukposts.info/have/v-deo/iGR9gZyifYKD1H0.html
@stracker494
@stracker494 Рік тому
The rust macro system is wonderful, but it does have its caveats. Declarative macros have some limitations, since they always have to output some standalone valid code, which makes them hard to combine. You end up having to use the weird TT muncher pattern, which is pretty impractical and hard to read. Procedural macros are also limited by the complete lack of context to their input. If you want to make a procedural macros that feels idiomatic to rust, you'll quickly feel the lack of typing or general location of the call.
@NoBoilerplate
@NoBoilerplate Рік тому
Oh yeah, I have so much respect for those who write macros. Even in lisp, macro's natural habitat, they're weird. Worth it though!
@lionbryce10101
@lionbryce10101 Рік тому
I love watching Rust videos. That one snippet for bounded_impl had just enough syntax hell to dissuade me from wanting to learn it though
@NoBoilerplate
@NoBoilerplate Рік тому
Oh don't even worry about macros, they ALWAYS look nasty in whatever language you write! There's an old lisp saying "never do in a macro what could be done in a function". True in Rust too! Rust syntax is only as complex as it has to be, I promise. There's loads of great features that simply require more syntax to work. You must make your programming language as simple as possible, but no simpler. I'd love to know what you think of my video here ukposts.info/have/v-deo/e3qlqqScp4OHook.html
@lionbryce10101
@lionbryce10101 Рік тому
@@NoBoilerplate I'd seen the video before, just watched it again. I'll never say the compiler isn't really handy since that's what everyone talks about with Rust and I'm sure you can get 90% of the way there with just the compiler messages. My main reasons for not learning it are: 1. I just don't have a use for any compiled languages at the moment (I use Lua to make addons for various games and Python to get data off of websites) and when I write code I want it to run immediately without waiting for compile time 2. When I do need to use a compiled language, memory safety is usually not on my mind because I'm not doing anything important or to scale 3. (Especially for Rust and C++) when I look at other people's code and see a ton of mumbo jumbo(&forThe,compiler) => {} it's a real turn off, not that most languages don't have their moments of that but c++ was really nasty to look at and Rust is just c++ with added rules, syntax, etc cool logo and nice idea though
@NoBoilerplate
@NoBoilerplate Рік тому
@@lionbryce10101 Absolutely fair, lua's really great (I recently converted my nvim config from vimscript to lua and I'm so much happier! If you want to play in the following domains, Rust might be worth the price of entry: - webasm - bare-metal without using C - high-performance computing My take is Rust is EXTREMELY different to what I was used to: No inheritance, new syntax for lifetime annotations and borrows, and the compiler hates a lot of the standard normal patterns we've been using for decades. I know how you feel there! Back in 2020 I crashed out of learning Rust twice. First time due to multiple string types (Haskell's biggest mistake made again, I thought to myself) and second due to the lifetime syntax. At the time I had a great mentor who picked me up and helped me back on the path. Most people don't have this. This is why I made my Rust series. Yes Rust is very different from what you're used to. But that's the point. Anyway, you sound like you're in a good place, no rush to learn new stuff. Python made my career for 15 years, no harm in that at all. BTW do check out bevyengine.org/examples/ if you're interested in game dev, impressive stuff there. Certainly, people on my discord rave about it! Cheers!
@JavierHarford
@JavierHarford Рік тому
May we please have some of your fantastic stylistic approach towards wasm and the like? Your explanation process is excellent 👌
@NoBoilerplate
@NoBoilerplate Рік тому
I have great news! I already wrote two videos on wasm! First video's here, the second part is 2 videos later ukposts.info/have/v-deo/iGR9gZyifYKD1H0.html
@JavierHarford
@JavierHarford Рік тому
@@NoBoilerplate 🙌 Many thanks!
@codenamelambda
@codenamelambda Рік тому
There's one thing that I feel is very much missing in Rust macros currently - the ability to "see" the surrounding namespace to be able to query it. As is, if you see an `Option` in a macro, you do not know if it actually *is* `core::option::Option` or any other type. On a related note, afaik you can't exactly tell the compiler in which order to expand the macros such that you can keep track of some state to effectively "annotate" other types with information about them that might be useful. While you *can* do both of these things to *some* extent with traits and/or consts, it's rather difficult sometimes & in my opinion does limit the *reasonable* possibilities quite a bit. This is where I think Zig actually does this rather well - Zig has compile time only functions, which you can use to generate new types or do compile time reflection on existing types.
@NoBoilerplate
@NoBoilerplate Рік тому
Oh fascinating - this is something called macro hygiene, I think? Hygenic macros only act on the scope they've been provided, and are thus easier to reason about, unhygenic macros slurp up stuff outside there scope. I could be wrong there. I'm not as familiar with zig compile time functions as you are (though I've read much). Can't you generate new times and do compile time reflection on existing types with rust macros? My understanding is that zig compile time functions can only do a subset of what rust macros can do?
@codenamelambda
@codenamelambda Рік тому
@@NoBoilerplate macro hygiene isn't a way of "seeing" the environment, but rather is a way of making sure that macros don't end up having unwanted interactions with the scope in which they are expanded, by actually going it it's own "separate environment" to some extent. Say you have a macro that expands to `{ let x = foo(); bar($expr); baz() }`, then that `x` will not be visible to the expanded `$expr`, meaning it won't shadow an `x` defined in the scope in which the macro is expanded. Regarding how powerful macros / Zig functions are, pretty sure it's the other way around, Zig functions can do everything macros can but not the other way around, except for custom syntax (since functions in Zig still operate on "values", be they compile time values (which include types) or not - and not token streams). In general, in Zig you can do things like given a type find out if it's a tagged union, enum, union, struct or primitive, and even see the fields it has and their types etc. Beyond that you can also concatenate variable length slices at compile time without having to worry about allocations or lengths without issue, read files at build time, etc etc - the print function in Zig also uses the same compile time machinery: ziglang.org/documentation/0.10.1/#Case-Study-print-in-Zig So you can do pretty much everything (and if you need a DSL you can parse it from a string at least, or put it in another file) at compile time in the actual context in which you know all the context of your types etc. (It should be noted that you can get some similar stuff in Rust at least as it pertains to types with a ton of derives, but it's much more work to implement.) Meanwhile in Rust, macros just turn token streams into other token streams - if you see the token `Option`, you only know it's an identifier, and not what that identifier refers to / what traits it may implement / etc Which I should note though, is a hard problem to solve - the abstractions Rust chooses make it pretty much impossible without having a lot of metadata about each macro, especially where traits are involved. I ultimately still prefer the safety and abstraction language via traits Rust provides over Zig for actual production level stuff, but I do very much enjoy the "reflective power" and compile time goodness Zig can provide that Rust is comparatively lacking.
@NoBoilerplate
@NoBoilerplate Рік тому
@@codenamelambda Ah of course! Thank you for the explanation. I have enormous respect for Zig, though the minimalism of the language isn't quite for me (in the domains I work in).
@mechwarrior83
@mechwarrior83 Рік тому
I would have settled for Rust style error checking alone but this takes it so much further. I cannot wait to see this language with a little pedigree behind it.
@NoBoilerplate
@NoBoilerplate Рік тому
Don't wait my friend, Rust's already replaced C in the Linux kernel, in Discord, in CDNs around the world, and even some of NPM's backend services. It's achieved critical mass, and is ready! What are you waiting for, what's not good for you?
@AlexEscalante
@AlexEscalante 4 місяці тому
Súper bueno! i wan't aware Rust macros where so different. I am liking Rust a lot!
@NoBoilerplate
@NoBoilerplate 4 місяці тому
Cool right! If Rust didn't have macros (my favourite feature from lisp) - we wouldn't be speaking, I'd be using Haskell or Go - terrible! :-D
@AlexEscalante
@AlexEscalante 4 місяці тому
@@NoBoilerplate hahaha… I tried Go last year and really didn't like it a lot. Since I already know C++ and C#, I really needed something comparable. Rust makes a lot of sense to me.
@NoBoilerplate
@NoBoilerplate 4 місяці тому
@@AlexEscalante hehe, yes Ken Thompson and Co were rather blinkered when they made go, I think. They tried for "cpp but modern" and I believe they succeeded wildly. But I need more than that 😅
@BenjaminWheeler0510
@BenjaminWheeler0510 Рік тому
Babe wake up new rust cult video dropped
@NoBoilerplate
@NoBoilerplate Рік тому
All are welcome in the cargo cult!
@joaosouza2678
@joaosouza2678 Рік тому
Your channel is making me fall in love with Rust! Do you have any recommendations to land a job? Most of the positions I see requirer at least 3y of exp. Im currently freelancing Fronend and Web3 (Solidity and Js basically), but never worked in a company before. Looking forward to dev smart contracts in the NEAR Ecosystem, looks promissing.
@NoBoilerplate
@NoBoilerplate Рік тому
There's a small but growing market for Rust developers, all the big players are taking rust seriously, look at this list that contains Microsoft, Aws, github and others www.rust-lang.org/sponsors - find their job boards and apply to them all! Secondly, four of my videos were sponsored by companies actively recruiting for Rust devs, apply quick! Videos: - ukposts.info/have/v-deo/gnmnf52KsKyl2X0.html - ukposts.info/have/v-deo/iGR9gZyifYKD1H0.html - ukposts.info/have/v-deo/sWFhnoCPamukyXk.html - ukposts.info/have/v-deo/q5KHrKdupYSlyKM.html Good luck! I'll try to add more sponsors who are recruiting for Rust, and maybe even do a "how to" video in the future!
@codedifferent
@codedifferent Рік тому
I started learning Rust this past December and didn't really get how macros worked (aside from the simple text-substitution ones). The SQL example one helped me out a lot. Now I want to try making macros that execute at compile time and maybe integrate them into a project I'm working on.
@NoBoilerplate
@NoBoilerplate Рік тому
Wonderful! Yes they're tricky to understand at first. I only understood their importance due to my lisp background. Good luck!
@Aspiiire
@Aspiiire Рік тому
Fantastic videos thanks :)
@NoBoilerplate
@NoBoilerplate Рік тому
My pleasure!
@redumptious2544
@redumptious2544 Рік тому
Holy shit. I thought the feature interesting but failed to grasp it's real use (beyond i.e. a build system). But the sql blew me away. Awesome as always Tris.
@NoBoilerplate
@NoBoilerplate Рік тому
Fantastic. I'm so pleased, this was just the sort of misunderstanding I was hoping to help with by making this video - Macros are great! XD
@RetoonHD
@RetoonHD Рік тому
yeah the sqlx query macro is actually insanely nice. It's everything i want from an ORM without any of the things i hate about ORMs
@NoBoilerplate
@NoBoilerplate Рік тому
It's fun to think what postgres/whatever features sqlx supports. All of them.
@PlonkapplePrequel
@PlonkapplePrequel 8 місяців тому
So with the feature of embedding other language inside of rust, is there a way to type rust, but with the indent based syntax that python has without squiggly brackets?
@NoBoilerplate
@NoBoilerplate 8 місяців тому
I bet there is (search crates.io) but let me defend curly brackets: I've written python professionally for 15 years. At the start, indentation scope is nice and easy. When you're at production-level, and you've got huge levels of indentation and debugging where the mistake is, you wish wish WISH you had curly braces XD This is how I think about Rust's more complex syntax: there's more detail, but it's there to help you. My video on this here: ukposts.info/have/v-deo/apiJgpptr2-ku6c.html
@thebaconbreadful
@thebaconbreadful Рік тому
Hey! I really appreciate your videos and this one as well! Would you mind spelling abbreviations you use out on your presentation cards? I find myself googling some of them.
@NoBoilerplate
@NoBoilerplate Рік тому
Thank you so much! This is a great idea, I will put in the markdown scripts links to the first usages of all abbreviations going forward! github.com/0atman/noboilerplate/
@thebaconbreadful
@thebaconbreadful Рік тому
@@NoBoilerplate I can give that thank you right back! I really enjoy your videos and you being so open to feedback will improve on that even more.
@NoBoilerplate
@NoBoilerplate Рік тому
@@thebaconbreadful this is the way!
@Rudxain
@Rudxain Рік тому
I've been procrastinating the learning of macros. My SV3G repo would seriously benefit from them! (I need to validate CSS colors and SVG strings at compile-time)
@NoBoilerplate
@NoBoilerplate Рік тому
oh that would be perfect for a macro! Make sure you're always using nightly, and try this to help understand what is happening github.com/dtolnay/cargo-expand If you need help, post in #programming on my discord, loads of smart people live there! :-)
@Rudxain
@Rudxain Рік тому
@@NoBoilerplate Thank you!
@bradtechnologies
@bradtechnologies Рік тому
I'm in awe!
@NoBoilerplate
@NoBoilerplate Рік тому
Rust's pretty incredible! Do check out my other videos to get more excited about it :-)
@MrAngeloniStephen
@MrAngeloniStephen Рік тому
This is the one video that Really makes me want to get onboard. I love using SQL to generate SQL so this is Panacea. But boy do you speak fast ! Thanks for everything.
@NoBoilerplate
@NoBoilerplate Рік тому
My pleasure!
@_schwm
@_schwm Рік тому
3:20 ngl, creating implementation with declarative macros hasn't crossed my mind. it's genius.
@NoBoilerplate
@NoBoilerplate Рік тому
I suspect we're only just (re)learning, as an industry, how to use macros!
@kira.herself
@kira.herself Рік тому
I love every single video of yours ♥
@NoBoilerplate
@NoBoilerplate Рік тому
That's so kind of you to say! I wonder if you've watched my little hopepunk/scifi show, Lost Terminal? ukposts.info/have/v-deo/qGOTeHtwoqmrrpc.html I'd love your thoughts on it!
@josefaguilar2955
@josefaguilar2955 Рік тому
I love the power of the macros but I can imagine a scenario where the DB a macro pulls from changes or is missing and that breaks compilation. Might be a great security feature though.
@NoBoilerplate
@NoBoilerplate Рік тому
Sure, just like when you run your project and it tries to connect to a database and it says "db not found", or if the db changes and suddenly your schema is out of data in your running app. With sqlx you get that feedback *immediately*, which I love. Early errors are much better than late errors! Honestly, that's the Rust thesis right there :-)
@XzcutioneR2
@XzcutioneR2 Рік тому
Narrator: *talks about macros, HTML syntax within rust etc etc. Me who started learning the language 3 days ago: o.O
@NoBoilerplate
@NoBoilerplate Рік тому
You're going to have an *incredible* time learning Rust! Do ask questions in #newbie-advice on my discord if you get stuck, and read The Book! doc.rust-lang.org/stable/book/
@joshaustintech
@joshaustintech Рік тому
I cannot escape Rust. Every time I try something else it calls me back like the siren from The Odyssey. And I have no earplugs.
@NoBoilerplate
@NoBoilerplate Рік тому
Don't tie yourself to the mast - come in, the water's fine! Interestingly I actually have a video in draft making an analogy to an Odyssean pact and Rust's type system...!
@flyingsquirrel3271
@flyingsquirrel3271 Рік тому
@Peter I strongly disagree. Rust has a single compiler that defines what valid rust is and for most projects and companies (by far), that is enough. It still makes sense to work on a spec but that should not stop people from using Rust right now. And it doesn't. Don't take my word, just look at all these large companies and FOSS projects that are already investing heavily in Rust and using it for crucial parts of their infrastructure (Google for Android, Microsoft for some low level stuff in windows, Cloudflare, Amazon, you name it). Cloudflare is a good example, they replaced nginx (!!!) with an inhouse solution written in rust, serving billions of requests every day. Even Linus pushed towards adding Rust to the kernel.
@NoBoilerplate
@NoBoilerplate Рік тому
@Peter I have good news for you! 1. The Rust team are considering a formal specification (which is what I think you want, not standardization). and 2. Many industries don't require standardisation - web development being a huge one! I'm excited for Rust to become even more useful, and would welcome a formal specification to allow use in organisations that have come to assume specification = correctness.
@FlaminPigz7
@FlaminPigz7 7 місяців тому
Macros are love, macros are life. May our syntax be free, may our code be proud, and may not a single phrase EVER be written more than once!
@NoBoilerplate
@NoBoilerplate 7 місяців тому
SO good right!?
@kelvinpraises
@kelvinpraises Рік тому
I didn't understand everything but I was blown away
@NoBoilerplate
@NoBoilerplate Рік тому
honestly same, that's why I'm here :-)
@kelvinpraises
@kelvinpraises Рік тому
@@NoBoilerplate Thanks!
@Capharas
@Capharas 3 місяці тому
What? That's so cool! Why didn't I know about this?
@jmrumble
@jmrumble 10 місяців тому
Every time I stumble upon these videos my brain goes “Hey it’s the lost terminal voice” 😂 (even though I found that because of this channel, it made such an impression 😊)
@NoBoilerplate
@NoBoilerplate 10 місяців тому
Hehe!
@justsomeonepassingby3838
@justsomeonepassingby3838 5 місяців тому
I thought Rust macros could not compete with Lisp macros (seriously, who would dare bootstrap object oriented classes in any language other than Lisp ?) because lisp relies on abstractions like dynamic typing or garbage collection, which are not possible in Rust, in order to maximize expressivity and minimize the syntax. But this video proves me wrong, implementing html and sql as Rust DSLs seems to be as much power as one could get from Lisp. Rust is indeed the ultimate language. Actually, there is still one thing i haven't seen Rust do yet: continuations But i think a continuation passing style macro would be no problem for Rust
@NoBoilerplate
@NoBoilerplate 5 місяців тому
Certainly you could implement them using macros, just as CL does - this is how async/await was prototyped in Rust at first, but it's now a native language feature! rust-lang.github.io/async-book/03_async_await/01_chapter.html
@first-thoughtgiver-of-will2456
@first-thoughtgiver-of-will2456 Рік тому
I'd love to see opencl and CUDA kernels with macros. (May already exist I need to check again). I never got into gpgpu kernels because I couldn't stand typing string literals as syntax.
@NoBoilerplate
@NoBoilerplate Рік тому
AFAIK, That is exactly what the asm!() macro does doc.rust-lang.org/rust-by-example/unsafe/asm.html I hope there's one for CUDA!
@wontcreep
@wontcreep Рік тому
i'm buying whatever you're selling rn, man, such passion
@NoBoilerplate
@NoBoilerplate Рік тому
My real passion is not getting paged by another syntax error in production at 4am
@pauldirac5069
@pauldirac5069 7 місяців тому
Greatly put! I should give Rust another chance 😂
@NoBoilerplate
@NoBoilerplate 7 місяців тому
It's really incredible!
@nyxalexandra-io
@nyxalexandra-io Рік тому
Was just thinking about how you would probably release a video soon
@NoBoilerplate
@NoBoilerplate Рік тому
That's Pavlovian conditioning: I release every other Friday :-)
@yurtle1851
@yurtle1851 Рік тому
wow, this one kinda blew my mind
@NoBoilerplate
@NoBoilerplate Рік тому
I know right! I started to take Rust seriously when I discovered it had a lisp-style macro system! Did you see my previous video on it? ukposts.info/have/v-deo/iKV-jI2aZ66jrGQ.html
@0.Maiden
@0.Maiden Рік тому
In the future I also want to learn about the rust, and I have a question, does the rust have "full oop features - four principles of oop" like c++, java? thanks p/s: sorry for my english, i used gg translate
@NoBoilerplate
@NoBoilerplate Рік тому
Perfect english! Rust is not an OOP language, it is BETTER than that. As you learn more about languages, you may discover alternatives to OOP that are just as good - we often think of OOP as the *only* way to program, but it's simply *one way* to program. If I'm reading this right, the 4 principles are abstraction, inheritance, encapsulation, and polymorphism. Rust has all of those, but in very different ways than Java and C. polymorphism is the most different in Rust. Rest assured, Rust has comprehensive techniques for building as large projects as you want. I would recommend reading The Book: doc.rust-lang.org/book/ Good luck, and please ask me more questions on my Discord if you need help :-) (links in the description)
@0.Maiden
@0.Maiden Рік тому
@@NoBoilerplate thanks, what I am interested in is that rust has all 4 principles of oop, and surprisingly it still has those principles, about how to approach and implement them, I will research
@itay1232
@itay1232 Рік тому
I think of macros as turning any language into a domain-specific language, excpept it's specific to every domain.
@NoBoilerplate
@NoBoilerplate Рік тому
Exactly. Lisp is described as a "programmable programming language" and Rust is too!
@etooamill9528
@etooamill9528 Рік тому
what you mean is i can design a programming language, build a macro for it in rust, write my code inside the macro, and then use the rust compiler to make an executable of it?
@NoBoilerplate
@NoBoilerplate Рік тому
Yes, with full support of the rust ecosystem and ide support. It's not even that difficult, macro_lisp is only 300 lines crates.io/crates/macro_lisp
@etooamill9528
@etooamill9528 Рік тому
@@NoBoilerplate oho this is exiting! I'll definitely try and play with it, it'll definitely be easier to learn macros than build a compiler or interpreter, which was the thing that was holding me back from even entertaing the idea of designing a programming language!
@NoBoilerplate
@NoBoilerplate Рік тому
@@etooamill9528 You'll learn different things making a language outside of rust, so by all means do it the old fashioned way for learning! But if you're doing it to solve problems... do it INSIDE rust! XD
@etooamill9528
@etooamill9528 Рік тому
@@NoBoilerplate you are right, even if it's scary I'll never learn if i don't get out of my comfort zone
@KohuGaly
@KohuGaly Рік тому
...well... kinda but not really... A procedural macro is just a program that takes a token stream and spits out a token stream. If you want to write a new language in it, then you'll basically be writing a transpiler/compiler to transform your code into valid rust. What proc-macro gives you in this context is the ability to then use that language inline inside any rust program.
@naranyala_dev
@naranyala_dev Рік тому
thank you
@NoBoilerplate
@NoBoilerplate Рік тому
My pleasure :-)
@eloyam9973
@eloyam9973 Рік тому
Mind blowing
@sbx1720
@sbx1720 Рік тому
I'm so pumped after watching this. Off to coding some macros.
@NoBoilerplate
@NoBoilerplate Рік тому
Remember the old lisp rule: "Never write a macro if a function will do" and good luck!
@alkeryn1700
@alkeryn1700 Рік тому
i once wrote a proc_macro that would take an arbitrary amount of iterator and generate a sql bulk query from them because the library i was using didn't support it.
@NoBoilerplate
@NoBoilerplate Рік тому
Perfect!
@maybeanonymous6846
@maybeanonymous6846 Рік тому
The more I search the more awesome Rust gets!
@NoBoilerplate
@NoBoilerplate Рік тому
Same!
@tonygamer4310
@tonygamer4310 6 місяців тому
this is just one of those things that you don't realize you need until you hear about it, and then you hear about it and wonder why it doesn't exist anywhere else
@NoBoilerplate
@NoBoilerplate 6 місяців тому
This is called The Blub Paradox, introduced in Paul Graham's fantastic essay on Lisp (which Rust implements 80% of!) paulgraham.com/avg.html
@sinom
@sinom Рік тому
constexpr in c++ is all about compile time code. Right now c++ is trying to discourage the use of the preprocessor and shift over to constexpr and other things instead for compile time evaluations and other preprocessor usecases
@NoBoilerplate
@NoBoilerplate Рік тому
Can you access the network in constexpr?
@sinom
@sinom Рік тому
@@NoBoilerplate sadly no. networking hasn't even made it into the stl yet and the TS for it has been kinda dead since 2018... Constexpr and similar afaik aren't as powerful as rust macros but they have similar ideas behind them. Just wanted to mention constexpr because the video mentioned c macros. So I wanted to mention what C++ is doing to replace them with something safer and more modern.
@NoBoilerplate
@NoBoilerplate Рік тому
@@sinom Ah! Got it, thank you very much for pointing that out, so it's an attempt to do c macros but better? That's super! No side-effects is a reasonable choice, macro_rules! can't do side-effects either.
@KohuGaly
@KohuGaly Рік тому
Rust also has constexpr. They serve different purpose than macros. Constexpr is for compile-time evaluation. Macros are for pre-compile-time code generation. Just because you can use the latter to do the former does not mean it's a good idea to do so.
How to Learn Rust
10:36
No Boilerplate
Переглядів 494 тис.
Rust Functions Are Weird (But Be Glad)
19:52
Logan Smith
Переглядів 121 тис.
10 Minutes To Escape Or This Room Explodes!
10:00
MrBeast
Переглядів 66 млн
1 класс vs 11 класс (рисунок)
00:37
БЕРТ
Переглядів 3,2 млн
Сын Расстроился Из-за Новой Стрижки Папы 😂
00:21
Глеб Рандалайнен
Переглядів 2,3 млн
Rust Data Modelling Without Classes
11:25
No Boilerplate
Переглядів 154 тис.
Rust is not a faster horse
11:37
No Boilerplate
Переглядів 313 тис.
Unix Domain Socket in 100 seconds
1:41
nixhero
Переглядів 32 тис.
Hack Your Brain with Polyphasic Sleep
11:02
No Boilerplate
Переглядів 1,2 млн
Rust makes you feel like a GENIUS
10:48
No Boilerplate
Переглядів 395 тис.
Rust makes cents
13:24
No Boilerplate
Переглядів 111 тис.
NixOS: Everything Everywhere All At Once
15:10
No Boilerplate
Переглядів 234 тис.
Rust Powered Polymorphism ⚡️ With Traits
9:55
Code to the Moon
Переглядів 86 тис.
Hack your brain with Obsidian.md
11:53
No Boilerplate
Переглядів 1,8 млн
ADHD: A Left-handed Brain
19:36
No Boilerplate
Переглядів 105 тис.
10 Minutes To Escape Or This Room Explodes!
10:00
MrBeast
Переглядів 66 млн