Runtime Arguments
Conversations about technology between two friends who disagree on plenty, and agree on plenty more.
Runtime Arguments
32: Why Rust?
Use Left/Right to seek, Home/End to jump to start or end. Hold shift to jump forward or backward.
High-points on Rust: how it’s different, how it might help you even if you never actually use it on a project, why people care. … And some things Jim and Wolf have (separately) been working on.
Links:
- SQL 'SELECT * (EXCEPT ...)' new functionality
https://peter.eisentraut.org/blog/2026/06/30/waiting-for-sql-202y-stockholm-meeting-report - Marlon recommended a book: “the book” (https://doc.rust-lang.org/book/)
- Rustlings website: https://rustlings.rust-lang.org/
- links from Robbie about the LLM episode:
https://www.youtube.com/watch?v=05e4AgvXT18 (Never use ChatGPT again)
pewdiepie-archdaemon/odysseus: Self-hosted AI workspace. - Mentioned by Wolf: https://github.com/wolf/engineering-philosophy
- Direnv:
Home: https://direnv.net
Repo: https://github.com/direnv/direnv
My PR: https://github.com/direnv/direnv/pull/1594 - Atuin:
Home: https://atuin.sh
Repo: https://github.com/atuinsh/atuin - My PR: https://github.com/atuinsh/atuin/pull/2851
- Helix:
Home: https://helix-editor.com
Repo: https://github.com/helix-editor/helix
Hosts:
Jim McQuillan can be reached at jam@RuntimeArguments.fm
Wolf can be reached at wolf@RuntimeArguments.fm
Follow us on Mastodon: @RuntimeArguments@hachyderm.io
If you have feedback for us, please send it to feedback@RuntimeArguments.fm
Checkout our webpage at http://RuntimeArguments.fm
Theme music:
Dawn by nuer self, from the album Digital Sky
Welcome to another episode of Runtime Arguments. I'm Jim McQuillan, and here's Wolf.
Wolf:Hey, uh… I don't know what I usually say, but I think I'm not going to say that today. Instead, I'm just going to say, hey.
Jim McQuillan:Hey. Hey, thanks. This is episode 32, our 33rd episode. Am I doing the math right?
Wolf:I think here.
Jim McQuillan:I think it is. Alright, today we're gonna talk about Rust, the programming language. And, uh, much to, uh, much to Wolf's chagrin, I had a subtitle, Rusty, Not Crusty. He didn't like that, so he erased it out of the outline. But it's still in my head. It's not going anywhere. Um… That's, uh, I guess a little private joke between us. Um, so, Rust. It should be an interesting episode. This came about… one of our long-time friend listeners suggested it, Jim Peterson, and so here we are. We're going to talk about it in a couple of minutes. First, let's cover a little bit of feedback. You know, we love feedback. There's information in the show notes about how to send us feedback. The more feedback, the better. I think it makes these episodes more interesting, so we're always happy to get it, and it tells us that somebody is listening. You know, we can see from the website that people are downloading it. We just don't know if they're listening, so at least a couple of you are, and we appreciate that. So, uh, we did an episode a couple of weeks ago on local LLMs, large language models, that's AI stuff, and our friend Robbie, he suggested a couple of places for more information. Uh, there's a YouTube, uh, thing, uh, if you search for Never Use ChatGPT Again, that's, uh, a video about how to use, uh, local LLMs, and I think it kind of follows what we do, or what we explained. And then there's a GitHub repo from somebody named PewDiePie. I think I've heard that name before. I don't really know who that person is. Are you familiar with PewDiePie?
Wolf:Well known to YouTubers.
Jim McQuillan:PewDiePie? Okay, not to me, but…
Wolf:Well, a certain category of YouTubers.
Jim McQuillan:Yeah. Okay. Well, he's, uh, he's got a video up about, uh, self-hosted, uh, AI workspaces. Uh, and there's links to all this stuff in the show notes. So, uh, check that out. Uh, could be really interesting. Several months ago, we did an episode on databases, and I talked a lot about SQL. And I came across an article a couple of days ago about a draft standard proposal, and I believe it's going to be in the next official version of SQL, which I don't know when that's going to be, maybe 2027, uh, for. a feature added to the SQL language where you can do a select, and you can… you know, if you do, like, a select star on a table, you get all the columns of the table. And sometimes, at least for me, that's really annoying, because sometimes I have… I have, uh… tables where I don't want to see every column, and I don't want to list them all out. I don't want to say select, uh, ID, comma, name, comma, blah blah blah, uh, just to get the columns I want, and skip one column. So there's a draft proposal to add, uh. uh, exclude to that. So you could say, uh, select list. And in parentheses, I'm sorry, in, yeah, in parentheses, exclude, and then you can list the fields you want to exclude from that output. And that to me is really, really useful because I do have some tables that have like large JSON objects in them. And I don't want to see those every time I do a select on the table. And I don't want to list the columns I want.
Wolf:Would it really be a list? Or would it be select star exclude something?
Jim McQuillan:Well, you say select star, and that, by default, gets all of them, and then… You say excluding, or exclude. one or more columns. So you'd get all the columns except those that are in your exclude list, which. Just seems really, really useful for me.
Wolf:So, I, I still have a problem with that, and my problem is that, uh, that sounds great, uh, interactively, when you're sitting at a terminal asking questions. Yeah.
Jim McQuillan:Yeah, yep, yep. Oh yeah, this is all interactive. Yeah. Yeah.
Wolf:But if you actually are trying to assign values or whatever, you want specific ones and in a specific order, and Star doesn't give you that.
Jim McQuillan:Absolutely. In fact, we, we have a rule at my company when you, when you embed SQL into the program. We don't use wild cards. we name the columns we want, because tables change. You know, columns get added, and… and… there's a couple of things here. First off, columns get added, so now when you do a select start, you might get a whole lot more data than you planned on, and maybe you don't want that, maybe it conflicts with other columns from other tables that you're joining. Uh, the other rule we have is, uh, always.
Wolf:Uh-huh.
Jim McQuillan:qualify your column names with the table name. So, you know, if you have a patient. dot name, you always say select patient dot name. You never just say select name from patients. or select them from patient, in this case. Uh, we always qualify our column names with table names.
Wolf:Good.
Jim McQuillan:But… and the other thing was, like I said, we never use wildcards in our… in our select list, because you never know what you're going to get. And here's the other thing. This can solve… this can prevent a bug from happening, and that is, let's say you, uh… alter the table, and you remove a column. and you say select star, you're not going to get that column, and you're not going to get an error. Your program's not going to behave the way you expect it to, you're not going to get an error, unless the program is doing something to detect that that column wasn't included in the output. if you say select, and then you name every column you want, and then somebody later on drops a column from the table, you'll get an error when that SQL tries to run it. I think that's… a good idea. So, yeah.
Wolf:Yeah, it's valuable.
Jim McQuillan:Anyway, I'm excited. And one thing I like about Postgres, I like a lot of things about Postgres, but one of the things I really like is they're pretty forward thinking and they were involved in this draft proposal. Peter Eisentraut, I think is. how you say his name, uh, he was actively involved in this thing, and he wrote the blog post that explained it to me. Um, and I think this also means that Postgres likely might have that. that feature very soon. Postgres 19 is coming out soon. It won't be there, but it could be in Postgres 20, even if the standard isn't completely published. Uh, I'd like to see that. It'd be very helpful. And as Wolf said, this is really for interactive, so when I'm using PSQL to look at a table. This is what I want. So, yeah, um, that, do you have any feedback, Wolf?
Wolf:Yeah.
Jim McQuillan:Anything you want to say about that?
Wolf:up. Uh, about that specific item?
Jim McQuillan:No, anything, any kind of feedback. Or that item. I don't care.
Wolf:I don't think I've gotten anything outside of… I mean, a couple of the things that you read off is stuff that came to both of us, so I did see it, but I don't think I got anything special to me. I have had some positive reactions, people saying, hey, listen.
Jim McQuillan:Yep. Yeah, you saw it. Okay, well.
Wolf:Uh, just hearing that they listen, that's kind of the feedback for me. Uh, and occasionally they have something to say. Usually what they say is, I'm still on episode 13, and I am trying to go forward.
Jim McQuillan:Yah.
Wolf:But apparently we talk too much.
Jim McQuillan:Well… One of us talks too much.
Wolf:I wonder which one.
Jim McQuillan:Sometimes, sometimes I talk too much. But, yeah. Anyway, how was your wolf? How was your week, wolf?
Wolf:Um, well, I've been exhausted, but man, this has been a really, really good week. Um, I have had… first of all, I've accomplished a lot at work. Second of all, I have had, uh, another open source PR, uh, accepted and merged. That one was to Helix. And I have had some reviewers.
Jim McQuillan:Oh, the Helix one got merged in?
Wolf:My my helix one got merged in.
Jim McQuillan:That's… That's cool.
Wolf:And I also, speaking of helix, by the way, hear that we are super close to a helix with. Steel, which is the scheme-based language. For, um… Uh, building plugins and whatnot, that'd be a big deal. Uh, I have a PR out.
Jim McQuillan:Oh, for doing plugins or extensions? Nice.
Wolf:for DirEnv, which I use all the time, that adds layout UV. It hasn't been accepted, but I have actual people. paying attention and having a discussion with them in the, um, in the ticket associated with the PR, or maybe it's in the PR itself, I can't remember exactly where, I just followed the links. Uh, and they have important stuff to say, so… can't tell if I'm heading closer to a merge there, but, uh, definitely their input is helping me improve it. Uh, I feel good about that. And I have a fully working… Uh, PR out to… Atuine, which I use, um, and what my PR does is, whatever you have set your editor to, um, and there's multiple ways to do that, typically people set dollar editor.
Jim McQuillan:Umm.
Wolf:But in a case like this, the real hierarchy is FCEDIT, which is the editor you have set for the FC command.
Jim McQuillan:Huh-huh.
Wolf:then visual, then editor, um, and then… it might be that you're using one of the Debian systems that has, uh, a special way of saying what your editor is, which is by putting a symbolic link in slash user slash bin slash editor.
Jim McQuillan:Oh, uh, yeah, the alternate system? Yeah.
Wolf:yeah, Alternates, or I think it's Alternates is the name. Uh, and finally, uh, it'll look for Vim or VI. So that's how it figures out what editor you want.
Jim McQuillan:And just so everybody knows, add toing is the command line, shell history, edit commands, all that kind of stuff.
Wolf:Right, so when you're in a shell, almost every shell does this. If you use Ctrl+R, you can search backwards in time. for commands that look like what you're typing right now. Uh, some editors already map that to up arrow, or you can use up arrow. At Duween. is a fast, Rust-based, smart. cross-shell, uh, version of this power that has a database behind it, it uses SQLite, can share, um, you can back your stuff up to a server if you want, that's totally optional. Um… and when you do the thing, however you've configured the keys, a list pops up in exactly the way you want, you know, top-down or bottom-up, or… and it narrows as you type more, and you can pick the command you want. And if you hit enter when you're on one of the commands. It doesn't. And if you hit Tab, then it goes back to your shell, and the command that you were on is all entered and ready to go, and your insertion point is at the end. Uh, Atoine calls this edit mode. You're now able to edit the command.
Jim McQuillan:It's a one-line edit mode.
Wolf:Except it's not edit mode. It's like you just typed this command, and now you're at the end, and so you can start hitting backspace. I don't like that. Because I'm used to FC!
Jim McQuillan:Yeah.
Wolf:uh, fixed command, the FC command, uh, where you say FC, and boom, you're in whatever your favorite editor is, according to that list I just gave.
Jim McQuillan:Right. Yeah, it launches the editor and…
Wolf:And now you're editing it.
Jim McQuillan:Giving you your command line, yeah.
Wolf:Right, and if you, like, for me, that might be VI or Helix or whatever, if you colon WQ, if you save and then exit. Boom, it exits your editor, executes the command, and adds it to history. All… All in one stroke. Um, and Atoine just puts it on the command line and lets you, you know, hit backspace. Sure, you can get to your editor from the command line, um, if you're in the normal mode that people are usually in, which is called Emacs mode, if you're using Readline or whatever. then, uh, I think you say, um, Ctrl-E, Ctrl-X, maybe, and boom, you're in your editor, whatever you've set.
Jim McQuillan:Okay.
Wolf:If you're in VIM mode, then, uh, you have to say ESCAPE, because you were in INSERT, now you're in NORMAL after ESCAPE. and then V would take you into your editor. If you're in Z shell in Vim mode, then you actually have to say V twice. That's a lot of keys to get to that same place, instead of just typing FC or whatever. So the PR that I added for Attuin says that when and of course key bindings, you can set whatever you want, but my default is you're in that list. You're looking at the thing you want instead of hitting tab. type. Control V. And now, it's just like you did FC already. You're in your favorite editor, do whatever you want. save and exit, it executes the command and adds it to history. To me, that's incredibly useful. So I have a PR for that on Attuine. Um, Atoine is super popular, so there's lots and lots and lots of people, so it hasn't gotten any attention yet. Um, I guess we'll see. So that's one thing, uh, all these PRs.
Jim McQuillan:Sure. One question for you. One question about that. Is there a way to abandon the command? You bring it up in your editor, and then you decide, nah, I don't want to do this, and I don't want to execute it.
Wolf:Yeah.
Jim McQuillan:Is there a way to abort that?
Wolf:Yes. Uh… for instance, in Vim, if you say… even if you didn't make a change, so you wouldn't have been required to use the exclamation point.
Jim McQuillan:Mmhm.
Wolf:In Vim, if you say colon Q exclamation point.
Jim McQuillan:Mmhm.
Wolf:You abandoned it, and it doesn't execute.
Jim McQuillan:Okay. Okay, but if you had written it… Or, like in Vim, I used colon X to get out and save the file, so that would… that would run it, and it would save it, and it would save the command, and then execute it.
Wolf:Yeah, okay, and another thing that you could do is you could, uh, you know, in Vim, you would DD, and that would empty the line, uh, and then you could, uh…
Jim McQuillan:But if you did a quit. Oh, sure.
Wolf:Save and execute that, and nothing would happen.
Jim McQuillan:Okay.
Wolf:So.
Jim McQuillan:So.
Wolf:There's a couple ways. I don't know if there's something explicit is needed, and I don't know if I have the power to add that explicit thing, because.
Jim McQuillan:Yeah.
Wolf:when you make that decision, you're already in the editor, and I'm not… there's no code from me, I don't…
Jim McQuillan:Yes. Right. Editor has control. Yeah. You're not going to send a signal or something. Yeah.
Wolf:Right.
Jim McQuillan:I get it. Okay, cool.
Wolf:Okay, but here's the important thing.
Jim McQuillan:Yes.
Wolf:It is not pushed to GitHub. At this moment. But by the time you are listening to this podcast, it will be. Um, I am about to push… what I am, at this moment, considering to be maybe the most meaningful. repo, new repo of mine, content from me, to GitHub. And the name of this repo is… Engineering Philosophy. Engineering-Philosophy.
Jim McQuillan:Oh, right.
Wolf:Um, and it's kinda big. I'd start at the README. Um, it's not all that big, but if you were to read every file there, it's about 2 hours worth of reading.
Jim McQuillan:Two.
Wolf:But it's about… Um… The battle-tested knowledge I have. on writing software. This is the stuff I feel is worth it. Knowing. It was super hard won. I've been doing this for four decades. And, you know, this isn't… All made up or discovered. I am standing on the shoulders of giants. I learned stuff from so many people everywhere and there's stuff I tested and stuff that turned out to be wrong that I was told is not included and it's a lot of stuff.
Jim McQuillan:Sure.
Wolf:And there's room to grow. I talk about, in the languages section, I talk about here's what it means to write good Python, but I'd like to add a section on what it's like to write good SQL, and I think maybe, Jim, you can help me with that part. Um… But this is a thing, including ways to audit your code. with an actual audit list to see if it's good enough. Umm. I think this is valuable. I think this is maybe the most valuable thing. I have pushed to GitHub. Um, and so I'm very, very, very excited for this to be a complete object available, artifact available on GitHub.
Jim McQuillan:So this is… so this is your… your version of the art of programming. That you're going to get out there and share.
Wolf:Although much, much shorter, yes.
Jim McQuillan:Well… Shorter now? Right? You think the first version of The Art of Programming was long?
Wolf:I do. The fact that it's 7 volumes now, and I'm not sure if I'm counting a thing he calls fascicles as volumes?
Jim McQuillan:Okay. All right. Yeah.
Wolf:But I kinda am. Damn, that thing's big.
Jim McQuillan:Yes.
Wolf:Anyway, that was my my week.
Jim McQuillan:All right, well… I've been working on a project. When, Wolf, when you, when you work on a new thing, maybe it's a new, really big thing. Do you… do you think it all out? Do you design it all ahead of time? Do you have it all worked out in your head, how everything is gonna work? And then you execute.
Wolf:Nope, because that's waterfall. Here's what I do. I have a general idea of. where I'm trying to go. What… what is the thing I want to make happen? For instance, um, I know some of the stuff you're doing and working on.
Jim McQuillan:Yah.
Wolf:maybe I would start with the idea, I want to make it easier for, um, doctors and admins to figure out what patients are doing.
Jim McQuillan:Mmhm.
Wolf:Right? And that…
Jim McQuillan:Yeah, that's… that's… yeah.
Wolf:uh, that might mean that right away, I can think of 4 or 5 different things that if they had those things, that would make it easier. I don't sit down and figure out, how can I give you those 5 things? Are there other things beyond those 5? And now that I've got them all, let me start writing? I don't. Instead, what I do…
Jim McQuillan:Sure, sure. Okay, good.
Wolf:is I say to myself. Well, this looks really important, this one right here. How many appointments do I have this week? What's the right way to show it to him, and how can I write something that proves that's useful? Minimum viable product. And then I do it. The minimum viable product.
Jim McQuillan:Okay, well. I wrote something back in 2006 to help with workflow in a doctor's office. And it's what they call a dashboard. And it's dragging patients around on the screen and saying what they're going to do. And things happen when you drag and drop. And it's an amazing system, but it's 20 years old. Uh, and at the time, I wrote it, uh, in Perl, using ModPerl, so I'd get some decent performance, and, uh, put it out in production, and… It changed their world in a great way. But ever since then, I've been wanting to rewrite it. And so for, like, okay, like, 18 years, I've been dreaming in my head how to rewrite this thing. I've been working out all kinds of different ways, and I've gone through all kinds of different thought processes on what. Technology I should use. And I finally got the customer to agree that, yeah, we should rewrite this, which means they're paying for it, which is a motivating, motivating factor for me, right? But I'm finally working on it and I've been working on it for the last six weeks or so. And I'm enjoying it so much. Uh, it turns out I'm using, um, uh, Node.js, I'm using Node.js, uh, in TypeScript, and of course there's a lot of SQL involved, and, and some, some, um… You know, it's server-side, it's client-side, and I'm having so much fun with this thing. And I'll tell you, when you don't plan everything out in advance, which obviously I didn't plan this whole thing out, I didn't know how I was gonna do it. It, you know how it, it sort of starts off with an idea and you prototype it and see what'll work and what won't work. And then you start. iterating, right? Um… It brings a lot of anxiety for 15 or 18 years. I'm confident in my ability to know that I can do it. But having done it is a whole different thing. And, uh, this past week, I hit a… I hit a point, a milestone, where I've really pretty well solved the really tough problems. So now, I'm, you know, I'm going through it, I'm sort of cleaning up, I'm making it run faster, but my ideas are working, and it's such a wonderful place to be. when you've been thinking about something for 18 years, and you finally see it working. Um… and it's… I'm having so much fun. I really am. It's…
Wolf:I feel like in so many things people always talk about the idea of the difference between zero and one is way bigger than the difference between one and two.
Jim McQuillan:Yah.
Wolf:Not to a mathematician, obviously, but to anybody who's not using numbers as numbers.
Jim McQuillan:Right.
Wolf:and not working. to something that not only works, but does a thing that's interesting and either useful on its own, or obviously is about to be useful. That's one. And the difference between zero and one is absolute. You know, people use these words for it like quantum blah blah except that quantum is exactly the wrong word because quantum means the smallest.
Jim McQuillan:Yeah, yeah.
Wolf:possible? It's not a quantum change. It's THE change.
Jim McQuillan:Yeah, yeah, yeah. No. Yah. it's, uh, it, it, like I said, it's been so much fun, and, and, uh, uh, I have noticed my anxiety has dropped substantially. Now that I've hit that point. Where things are working. It's not in the customer's hands yet, but I think in about two months it will be. And I'm really excited about that, getting to that point. Anyway, and I'll provide a few updates along the way as I go. I'm just loving it. I love working on these kinds of things.
Wolf:I feel like the anxiety thing is, um… you know, I don't want to make you ring a bell or anything, but I feel like it's almost Bayesian, because when you're at zero, working hard to get to one. You don't know if you can get to one.
Jim McQuillan:Exactly! Right? Am I good enough? Right?
Wolf:And… and that's where the… or is it even possible? And uh… and that's where the anxiety lives. Uh, it's the… it's the worry about the thing you're doing right now.
Jim McQuillan:Yeah, right! Exactly. That's the stuff…
Wolf:And then you get to one and you know it is possible. Now it's just a game of how good can we make? It's like the old joke about would you do it for a dollar? Oh no. Would you do it for a million dollars?
Jim McQuillan:Yeah. And. Yeah.
Wolf:Absolutely. Uh, would you do it for $50? What do you think I am? Oh, we know what you are. Now we're just haggling. Right? Now you're just haggling.
Jim McQuillan:Yeah. Yeah. Yeah. Yeah. Well, I don't know how that applies to what we're talking about, but it's a funny story. Anyway, I'm enjoying the hell out of it, and I'm… you know what? I'm sleeping better because the anxiety is much, much lower, so that's always good. So, hey, we're 26 minutes into this thing. Should we get into the meat? What do you think? You ready?
Wolf:I think we should.
Jim McQuillan:All right, all right, take it away.
Wolf:So, we're gonna talk about Rust. Uh, a lot of people have wanted us to talk about Rust. And I think there's a lot of people in the world who never heard of the language Rust. Uh, there's a lot of people in the world who have never looked, but they're like, oh, screw that. There's a lot of people who are like, oh, that could be interesting. And there are a lot of people who don't understand what Rust is, but assume Rust probably can't address. any of the problems that they have. Um… I am always curious and when something. exhibits enough attributes worth looking at, I am just drawn inexorably towards it. So, for a while now, I've been looking into Rust to find out more about it. Um, and so I have questions for you immediately, Jim. The first one is, uh, I know this doesn't happen in Perl without really working beyond the abilities of almost anyone. But when you do stuff in C. Have you ever, um… Leaked? Have you leaked memory?
Jim McQuillan:Oh, sure. Sure.
Wolf:Have you? tried to dereference a null pointer.
Jim McQuillan:Yeah, I've written a lot of C, but it's always fairly small things. not mission-critical stuff, so when I try to dereference a null pointer, unexpected behavior happens.
Wolf:Uh-huh. Have you written stuff? And now we're expanding into the world of Pearl.
Jim McQuillan:Right?
Wolf:Where. You didn't call it exactly right. Uh, and the way the, uh, API was described, the, the function signature. actually just wasn't enough to explain how to call it, and you had to go look at the function definition, and maybe the comments that were in the function definition, to understand how to call it. Has that ever happened?
Jim McQuillan:Sure. Yeah, sure. And, and, and Pearl does not help you there. It does not guide you. I mean, yeah, I can go look at the source and see what's going on, you know, not the source to Pearl, but the source to my program, and I can see what it expects and stuff, but Pearl, it does nothing to help.
Wolf:Umm. So, what we are discussing is, if you drew a circle on a piece of paper. And inside the circle was how Rust works. And outside the circle was everything else. We're talking about everything else. Now we're going to talk about what's inside the circle.
Jim McQuillan:Okay.
Wolf:Um, and the most important thing about Rust. uh, is probably not what you think, because everybody thinks it's ownership, or they think it's the borrow checker. The most important thing about Rust is… It is a paradigm shift. Rust is not another C++. It's not another, um… I don't know, scheme, or… it's not any of those things. It is its own brand new thing with its own brand new way of thinking. And it does things differently than other things. There's huge overlap. There's lots of stuff. Um, for instance, uh, Rust is a sequential language. One statement executes, and then the next, and then the next. That's a lot like stuff you've used before. It has variables and those variables get values. That's a thing you've done before. There are types. There are functions. That's a thing. Functions take parameters. The parameters have names. That's a thing you could have if you wanted it, Jim. I know you get it in JavaScript. For Pearl, what do you take? Dollars? What do you take in Pearl? Nothing, and then you pop them off one at a time, or…
Jim McQuillan:Um, yeah, if you, if you pass arguments to a function, then you get, uh, uh, at sign underscore is the, the, the array of, uh, or the list of, of arguments. We've… we write, um, um, uh, defensively, and so our functions, uh, they have, like, a signature on them, and if you call something without passing the right things, you'll… you'll get a warning. So we… You know, we've tried to add things to the language to help us, but… Like I said, it doesn't help us on its own.
Wolf:Okay. Well… Rust is a big change. And… I'm not saying. You should go use Rust. I'm absolutely not saying. Jim, you've got some code. Boy, that would be good in Rust. Stop what you're doing now, go write it in Rust. Uh, everything I've ever said in any episode will tell you. Those are words that would never come from my mouth. Um, I… rewriting stuff in general is, um… if somebody says, oh, go write… go rewrite it wholesale, that… that person is either a liar or a psychopath. Um… I think Rushed can help you. I think one way Rust can help you involves you not writing Rust at all. But learn Rust and then come home. Because Rust has new ways of thinking. When there are multiple political groups, and they never talk to each other, they have very, very different thoughts, and they hate each other. When you get a group together that mixes those. very divergent populations. They do learn from each other, and they learn that the other side knows things they don't know, and that some of those things are valuable. Um… If you learn Rust. Even if you're not going to become a crustacean. Uh… You're going to have new knowledge that changes the way you think about and talk about. Problems you do solve. Um, so, I want you, or anyone, the listener. to go look at Rust, spend some time in it, and later I'm gonna talk about a thing called Rustlings, and how easy this is to try. Um… I'm not gonna say more about that now, but the point is, it's easy to dip your toe in rust. And you will learn some things, and those things will come back to you. in the language that is your daily driver. If you're writing JavaScript, this is going to help you write different, and I assert, better JavaScript. And maybe there are places in your total workflow where Rust is a win, where here's a piece, this one piece ought to be Rust. Rust is the right answer here. We did an episode a while ago called, um… Choosing the Right Language, that was episode number 28. Um… Rust is the, uh… the whole point is the model change costs more than a syntax change. Budget accordingly idea. What I'm suggesting now is that… Flipped. Understand the model change. But don't put yourself in a place where that's a requirement for you to move forward in writing your code. Figure out what it means. Why did they do it? That's like learning a new language. When you can speak French, suddenly you can talk about foods you never talked about before. Important to me. On the food front, maybe less important to you, Jim, but something.
Jim McQuillan:Yep.
Wolf:Have you, in your world, encountered a machine, a program, a tool, a language, anything? that… I don't care whether that… thing, whatever it was, ended up being the thing for you. But you learning about it. Changed. How you went on from there with other things. For instance, when you went from COBOL…
Jim McQuillan:No. Yeah.
Wolf:to COBOL plus a database. When I look back at your life, I feel like that was a change for you.
Jim McQuillan:It's a huge change, yeah. Yeah. It was huge. When we… we integrated Postgres into the, uh, COBOL runtime we were using at the time, and it changed everything for us. It opened up the world. To us and huge, huge change. And, you know, other things have, have altered my way of thinking too. You know, when I learned C, that was a long, long time ago. Um, but you know, that changed how I thought when I learned Swift. Big. Big change in how I think about programming and the tools that Swift gives you, I think are not that different from what Rust gives you. You don't deal with borrow checker and stuff like that, but the Swift programming language has an awful lot of features in it that. I don't see in other languages. So, yeah.
Wolf:Outside the scope of Rust, for just a second, I think the words you just said are critical. The mark in my mind of intelligence in general is. The ability to add new facts. to your internal model, learning. When you learn new things and change. the only kind of person who can do that is an intelligent person. I think that marks a lot of people as more intelligent than we give them credit for, because people are able to accept new facts. But I'm going to go a little bit further. I think when you accept new facts into your world. And they disagree with your existing opinions. And then you say, you know what? I was wrong. Here's my new opinion. And you let those facts change your ideas about how the world works? I think that puts you at the front of the line. Um, and when you let learning about databases change you. from a COBOL person into a person who can use databases? I think that means you're, you are what we all aspire to be. Uh, a person who takes the very best of what he knows, or she knows, and makes that be the point of their arrow from now on, until they learn better than that!
Jim McQuillan:Mmhm.
Wolf:Um… So, uh, first of all, good on you, and second of all. Here's some more sharp metal to put at the tip of your arrow. Now. The thing that everybody talks about, or knows about. Um, when they hear rust is, oh, rust. It's got that ownership model. That's the thing. And so let's talk about that first. Um… It's the actual reason Rust exists. And I'm gonna tell you the three different worlds that there are. Um, in C and C++. you manage memory by hand. Like in C, you use malloc and free, right?
Jim McQuillan:Huh-huh.
Wolf:Uh, and boy, is that easy to screw up. Um, in C++, ooh-hoo-hoo, they gave them better names! New and Delete. But they're just better names. Uh, it's all fast, um, but there's no checking. You can free something twice, you can use it after it's freed, you can forget to free it at all, um… There's a three-letter acronym CVE. I'm sure you've heard it before. CVEs come from this category of error more frequently than almost any other.
Jim McQuillan:Yes.
Wolf:Then, there's garbage-collected languages, and I'm kind of… uh, clumping together at least two things, maybe more. Um, and also there's lots of ways to do garbage collection. But Java, Python, Go, JavaScript. Um, lots of languages are garbage collected. You don't, uh, free things individually. What happens is, if… nobody points to them, they go away. One specific category of garbage collection, although I don't know people would specifically call this garbage collection, is reference counting. And reference counting is a thing that Objective-C and Swift can do. RC is reference counting. ARC is automatic reference counting. Which is slightly better. a thing called COM, the Common Object Model in Microsoft. required reference counting, but it was the worst of all worlds, because it required reference counting, but you also had to do it by hand when it needed a reference you had to specifically ink ref it. And when you were done with it, you had to explicitly deck wrap it. How awful was that? Um… Anyway… Then there is a new category. It's the rust category. And the Rust category is that the compiler. at compile time. Before it's ever run. Looks at for every single resource. Owns it. How long does it need to be valid and alive? Umm. How many people are going to use it at the same time? And is that reasonable? And when it's done. It should go away. Uh, it's all automatic, and there's stuff a normal other… in one of the other categories wouldn't detect. For instance, the idea of two different hunks of code writing to the same variable at the same time. Is there ever a time that's not a bug? I mean, if you wrote something where you meant for that to happen. and you did it in a way where that wasn't a bug, I would still argue that what you've done is a surprise, and the surprise is a bug. Whether it results in undefined program behavior or not, it's not the right thing to do. So, Rust says, for any object, there is exactly one writer. Or… There are no writers and some non-zero number of readers. This has so many powerful benefits. One is that coherency is always maintained. Two is that there's a lot more stuff that you can deduce about code that you're looking at. And three is, this feeds directly into, um… Both, uh… uh, parallelism and concurrency. Um, in the same way that Go solves the problem with, uh, channels. And when you send a piece of data across the channel. you're not getting a reference, typically. What you're getting is a new copy of the data on the other side. Rust solves the same problem, and in much the same way. An interesting thing about the communication aspect of this is that Rust tells you how it needs to work. But unlike Go, in Rust, it's the libraries that say, and not the standard libraries, the libraries that you actually bring in, that say. How it happens, as long as they obey those rules. Um, so this ownership thing. involves how many people can write to it, how long it lives. what happens when it goes away? Uh, and by the way, there aren't constructors or destructors in Rust. This is all done with traits that an object either has or doesn't. In the case of, I wanted a destructor, you can have it, you just include the drop trait. Which is fascinating to me. So. The rules are every value has exactly one owner at a time. One. You can either have one mutable reference to a value, or any number of read-only references, but never both at once. And when the owner goes out of scope, the value is cleaned up automatically. This is a drop. And if you have the drop trait, then you get the destructor version of drop. So. Fearless concurrency? Um… But also, this is where Rust gets this reputation for being so picky. Some people call it, uh, that the compiler is a hostile pair. programmer, because it's relentless in its error messages. And when you first face them, the error messages are impenetrable. But I promise you. If you spend some time, not only do the error messages gradually become clear. They are among the very best error messages you could reasonably get. Because Rust error messages. usually point much, much closer to where the real problem is than I've seen in any other language. They tell you better what's wrong, and once you understand all the parts, you'll understand it better. And they almost always tell you exactly how to fix it. And they tell you the right thing. So… I think that's.
Jim McQuillan:Yeah, can we… can we back up just a second here? The… the one rule about, uh, exactly one owner at a time? Ownership can change, though, right?
Wolf:Sure. Yes.
Jim McQuillan:Like, like if I own something, I can hand it off to a sub routine. That now owns it?
Wolf:That's correct.
Jim McQuillan:Is that right? Okay.
Wolf:But guess what? If you… Gave it to a subroutine? You aren't an owner during the execution of that subroutine, and also.
Jim McQuillan:Anymore, right. Okay.
Wolf:You don't automatically get it back when the subroutine returns?
Jim McQuillan:Okay.
Wolf:Unless the subroutine returns it, and you take it back.
Jim McQuillan:Okay. Thanks.
Wolf:Super? Like, I know that sounds… Clear as mud. Um… But once you start using it, you're like. Oh, that's great.
Jim McQuillan:I think I need to try that… I need to try that Rustlings thing.
Wolf:I really like that. So, there are escape hatches. up. Reference counting and automatic reference counting, RC, ARC, those aren't built into the language, but you can have them if you want them. And garbage collection isn't built in, but if that's the thing that is right for your problem, you can have that. Um… So… That that lets you have what you want. But by default. gives you laws that are gonna stop you. from shooting yourself in the foot as soon as you learn to cooperate with the error messages. Um, so GC pauses are, like, a huge thing in GC-collected languages.
Jim McQuillan:GC garbage collector pauses.
Wolf:GC means garbage collector, yes. So if you're in a garbage-collected language.
Jim McQuillan:Yeah.
Wolf:like, um, Perl and Java and JavaScript and TypeScript. These GC pauses can be a big deal. Has that ever hit you?
Jim McQuillan:No. I've never had a problem with it.
Wolf:I wonder if that's because you're not writing long running stuff.
Jim McQuillan:You know, Pearl does reference counting. Well, I do write some things that run very long, but, uh, you know, Pearl does reference counting, and it's not like a… it's not like the garbage collector starts running. and doing things blocking you. You know, when something goes outta scope, it goes away. That's all. It's never a problem for me.
Wolf:But you do, even if you're using reference counting, you absolutely need a garbage collector, because it's super easy, if you are using reference counting, to build a cycle, and cycles won't go away until they're garbage collected, so…
Jim McQuillan:Sure. Sure.
Wolf:Um… Anyway, uh…
Jim McQuillan:Yeah, it's never hit me before, though.
Wolf:When I first started using Rust. Um, I was super excited to learn all the cool new things it was gonna give me. I was NOT prepared for all the things that Rust was going to take away, and Jim was there. He can absolutely tell you that as soon as I started hitting these things, I was an unhappy camper, and I started crying like a little… I'm not gonna square… swear.
Jim McQuillan:Yeah.
Wolf:But, um, I started crying, uh, whining. I started whining. And, uh, he's like, how can it even be a language if it doesn't have that? Um, so I'm just gonna go over some of the things that hit me big. Um, for instance. Every language I've ever used has the equivalent. of null. C has null, C++ has null, other languages have nil, Python has none, uh, SQL has null, uh, numeric stuff, like.
Jim McQuillan:SQL has it. Yep.
Wolf:Pandas and whatnot have NAN, not a number, um… Uh, when do you use in Perl? Is it zero? When is it?
Jim McQuillan:I'm deaf.
Wolf:I'm deaf. Um… Russ doesn't have that. There isn't one. Like, but what if you want a pointer that doesn't point to anything? Guess what? Nope.
Jim McQuillan:You don't.
Wolf:Uh, so that, that hurt me. I was very confused by that. Um, I think exceptions is a super big deal. Having exceptions is giant. Uh, when I learned that. Go didn't have exceptions. Go went down a couple steps in my mind. Now, Go does have a standard kind of behavior for this. Which is that all Go functions, but not as a definition of the language, as a convention. All Go languages can return an error, and you always check for the error. This is… what you do. But Go doesn't make you do this. It's the fact that you're a Go user that makes you do it. Um, I didn't like it, and it made me shy away from Go. It doesn't make go bad, but it was a thing I wanted and I didn't have. Um… Another thing that I really enjoy is inheritance. Inheritance is great, especially when used. in two different ways. Uh, one way that inheritance is great is for expressing the is-a relationship, so it's about inheriting types, inheriting behavior.
Jim McQuillan:Mmhm.
Wolf:And another way inheritance is good is about inheriting and sharing code. It turns out that, uh, for a long, long time, anybody who does this for a job. has moved on to the notion that if you want to share code, composition is probably better than inheritance, and so you should focus on that. Guess what Rust doesn't have?
Jim McQuillan:inheritance.
Wolf:Uh, the primary collection of… the way to collect objects and behavior together in Rust is called a struct. There isn't a thing called class. In C++, class and struct are basically identical, except for the default assignment of visibility to the underlying pieces of. Uh, uh, the underlying members. Uh, in Rust, there's, there's only struct. And there's no inheritance. Now, I'm telling you a lie the same way that your physics teacher in school told you that gravity doesn't matter what the size of the thing is, so dropping a feather in a vacuum…
Jim McQuillan:Mmhm.
Wolf:and a bowling ball, they both fall at the same time. Sure, that's true, and the thing I just told you is true. But it is a lie, because if you're dropping a feather, and a bowling ball, and the moon. Those three things close the gap at different rates. And the reason they do is because the Moon has measurable gravity of its own, and so the Earth and the Moon close the gap faster because they act on each other, whereas the measurable gravity. caused by a feather is not measurable, and so it does fall at the same rate as a bowling ball. Of course your physics teacher is not going to tell you that, and in fact, you're going to be asked. to see the principal when you bring it up. But, um, it happens that…
Jim McQuillan:You speak from experience.
Wolf:Yes. It happens that in Rust, there is inheritance. And it is useful, but it's… it doesn't have to do with actual implementation code sharing, uh, which you're gonna get by, um… Uh, composition the same way you would anything else. It happens in traits and protocols and whatnot or it's not called whatever anyway. So. What do I get instead of those things? I can't return null. Uh, instead, Rust has this tremendous thing called enums, enumerations.
Jim McQuillan:Mmhm.
Wolf:They're much more powerful than they are in the languages where you mostly use them. I'm not gonna talk about, um, schemes and lisps here, but… You can return a thing called an. So. Either you get a T or you don't get a T as a result, for instance. So, we would return T, or we would return none, or null, or whatever it is for your language. In Rust, you make a type. That type happens to underline BNENUM, and it only has two possibilities. The values… the possibilities for that T are the value SUM. or the value none. The value sum is a T. And the value none isn't anything. So yes, you can't return none, except, kind of, you can. So, option T, there isn't a global none? But there is something, and when you actually start using it and thinking about it. It turns out to be better. So I kind of take that. There's no exceptions. But instead of an exception, um, if it might be that you could. Uh, not do the right thing. But the thing you can do is say, this is such and such an error, then just like option, where you could either find an answer or not, for instance, if it's get supplier, you would have said, oh, there isn't a supplier with that name, so I'm going to return none. Um… Your answer might be either you found the supplier or. you couldn't get a connection. And not being able to get a connection is an error. Well, instead of raising an exception, you make your result type be RESULT. and that's a parameterizable type, where it takes the T, the supplier type. And an error type. And so the thing that you return is either going to be that answer or it's going to be error and error has the value that is your error. It's another case of an enum. Now, it's not like, oh, I have to catch the exception, or maybe I forgot to catch, or whatever. You gotta look. What did you get? Did I get a supplier? You actually have to look. It's not unlike Go's model. Except that… You're forced to look, and it's designed into the language. Um… The payoff, uh, for some of these… maybe it's not the payoff for some of these, but… you get things out of a lot of the combination of what Rust gives you and doesn't give you. uh, that make a lot of this world kind of magical. Um, I'm gonna reference Swift here, because a lot of these languages, um. provide things that are… in C, we call it a switch statement. In, um… Uh… um… Python, we call it a MATCH statement. Uh, what do we call it in Swift?
Jim McQuillan:Uh, switch.
Wolf:Uh, and in… in Rust, we call it a match. uh, Swift does a really good thing, and Rust does that same thing. And that same thing is… Uh, this kind of statement, a match. Must be exhaustive.
Jim McQuillan:Yes.
Wolf:Um, so, for instance.
Jim McQuillan:I like that about Swift.
Wolf:If you say that an order has three possible states, uh, which is, uh, placed. Um… Prepared and shipped. Those are going to be your three cases in, I don't know, three or four match statements that exist throughout the body of your code. And. That is probably not a particular case that you would handle with it. Um, the, um… now I've forgotten the word, because I keep wanting to say anthropomorphism, but it's not that, it's the, um… it's the case where two different op- two objects of different classes handle the same function, but in different way- polymorphism, sorry. Um, this is probably not the kind of case you might handle with polymorphism, because.
Jim McQuillan:Polymorphism.
Wolf:The consequences are so different, but. you've got those 3 or 4 match statements, now you decide, you know what, I need a new, um, state, uh, it's not just. Um, placed… Um… Uh, preparing and shipped, there's also canceled. Suddenly, all 3 or 4 of those places where you used that match before? They don't silently fail. They all fail to compile.
Jim McQuillan:Right.
Wolf:because you weren't exhaustive.
Jim McQuillan:Right.
Wolf:Umm. That's fantastic. So. This leads me to a thing I have said over and over about so many languages, and that is… The type system? in Rust is powerful enough to let you. Design and build the planet. Promises. you intend for your code to make. Um… And there's sort of a… uh, escape hatch that I want to talk about, too. But the combination of traits and generics. Let the entire function signature become. become a complete contract. in a way that is not obvious from any other language. If your function takes an option, and that's parameterizable, type, and generic. On, um, order… Then that means you could have taken an order. or not. And that's the contract, and it's obvious from the signature. If your function returns a result, um, status, comma, and then some subcategory of errors. Um, that's a contract. It says it might not succeed, and here's the kind of failure it could have. Um… This is genuinely one of the strongest type systems in mainstream use. And the interplay… Although that means it's the hardest to learn, the combination of generics and trait bounds and a thing I'm not going to talk about further, but lifetime bounds. All those things together are part of the type system. Make this… Um, a genuinely powerful type system, maybe the most powerful I've seen. And that thing about being picky? That's where this comes in. It's picky. It wants you to understand and satisfy those constraints. And the really complicated error messages you won't understand at first? Tell you how. And finally, um, there's a special escape hatch for so much of this. Umm. I had mentioned before some of Rust's rules, like the number and kind of owners, a specific. variable can have and some of them here are about what kinds of types things can be. Well, there's an escape hatch. It's very badly named. Um, the escape hatch is named… unsafe. And… it's a block. You say, unsafe, open curly brace. You say some things, closed curly brace. Here's why it's badly named. There are actually seven traits, seven important promises. that, um, Rust requires to be enforced, and are enforced by the compiler and the Varro checker. Unsafe the word makes it sound like inside this block you don't have to do those things? That is not what it means. Unsafe means. I promise. that even though I'm about to say things in a way. The compiler wouldn't have the power to prove. Meet those seven criteria. They will. And by the time you get out of it. They still will and you can check again. That's what that says. So you use unsafe, for instance, if the thing you're about to do is you've got a giant array. And you need to move items out of the way to push something in the middle. That's an incredibly difficult thing to do if you also have to satisfy all of these promises. and let Rust make its, um, out-of-band runtime checks, proving it's all okay. What you want to do is say, I'm just going to do it. It has to be done. I promise this is going to be okay. That's what the unsafe block says.
Jim McQuillan:But that's… that's shifting the burden on this developer. Uh, and the compiler isn't gonna check that code for you?
Wolf:That's what Unsafe says.
Jim McQuillan:Like, you can do unsafe things. Yeah, you can really… you can do bad things, right?
Wolf:But the promise is… that you won't. Let me rephrase that. You can do things that could be made to be unsafe.
Jim McQuillan:Yeah, but the compiler isn't gonna… isn't gonna… Sure.
Wolf:You can do things Rust would never let you do. You have the power to twiddle bits in ways Rust just won't allow.
Jim McQuillan:Right.
Wolf:But your promise is that by the end it's all okay.
Jim McQuillan:Even though it might not be.
Wolf:Yes, it could be that your promise was a lie.
Jim McQuillan:Yeah, okay. Uh, okay. It's on you.
Wolf:It is on you. That's what unsafe means.
Jim McQuillan:Yeah, okay. Yeah, okay.
Wolf:Having an unsafe block. Inside a function? Does not mean that unsafe is, um… Uh, I used a word for this last time, uh, but it doesn't spread in that horrible way. An unsafe block doesn't make a function unsafe. An unsafe function doesn't make a module or package unsafe.
Jim McQuillan:It doesn't taint the module or the block.
Wolf:Exactly. But it is something that you can look for, and it absolutely is something you should test for. Now… I didn't really have a space to talk about this. But our friend Marlon mentions a really important third-party library package. Named Tokio, not spelled the way you think. T-O-K-I-O. It's one of the most important third-party libraries there are. It's as important to Rust. as Twister used to be to Python. It has to do with, um, concurrency and parallelism and, um, multiple processes and, uh, sharing variables and a ton of things. It does a lot. Um, and there is much to learn from it. Um, just seeing how it's defined and how it works is absolutely a learning experience. So, I want to, um, honor Tokyo, its utility and its design. And also, Honor Marlin, he's pointing out something very important. This is… this is super good knowledge. Um, and then I want to move on to a thing that Rust has that is completely outside the scope of everything that half of you use, and the rest of you are gonna be like, eh, so what? But first, some of you are gonna say, eh, so what, and you're wrong. And that is, Rust has macros. I hear you, C programmers. So what? No, no, no, no. Not that kind of macro.
Jim McQuillan:We've had those for years.
Wolf:That's… it's not that kind of macro. It's the kind of macro a Lisp programmer talks about. It's the kind of macro an Emacs programmer talks about. It's the kind of macro that doesn't take the word foo and turn it into underscore underscore foo underscore underscore. That's not the kind of macro it is. It's not said. This is the kind of macro that gets the already parsed token stream. And it knows things like types and number of parameters and the values that get passed into it. It's actual code, not a replace, not a grep, not a send. Umm. And it does things the compiler can do. It goes from tokens. and produces. something to go next in the world. It might be that thing is more token stream. But, um, there are a lot of things in… in Lisp, for instance. Huge hunks of the Lisp language are actually implemented with macros. There isn't a while loop in Lisp. Instead, um, there's a thing where you can know if something is true or not, and then there's a macro that says, well, given that you can know if it's true or not, I can invent a thing called WHILE. Umm. That you can't do that with a C macro, but you can do it in Lisp. And you can do it in Rust. Now, as it happens, Rust has all the ifs and whiles that you can care about. But there's tons of things that these macros implement. that are in the right place. Jim and I have a little disagreement about this. Um, I'm gonna say my words first. But here's some examples. Rust has some array initialization functionality affordances that let you instead of saying construct my array from. a, uh, generator, the equivalent, uh, or from another array, or from an existing, um. Umm. Uh, literal.
Jim McQuillan:a list. Okay.
Wolf:literal, constructed from a actual list. So, my array A, B, C, D, E. That's a thing that would be hard to do, maybe not impossible. with a C macro. Umm. And it makes a thing that lets you just say an array. With some parentheses, and that… collection of values comma-separated after it. And it figures out everything that's needed. The right size, the right type, the right… everything. My assertion is, and here's where Jim and I disagree, that some of those things that you, that you, uh, declare, define with. Rust macros, for instance, println and several others, this, uh, array construction thing. are. Rust. They are parts of the Rust language. And I don't want to misrepresent you, Jim. Why don't you give your side?
Jim McQuillan:I don't know. I think you're talking about initializing an array with a list of values. That just seems like a language thing to me, and you're saying you do that with a macro? I… I probably totally misunderstand.
Wolf:I'm saying… I'm saying. It was… designed into your system, and the implementation of it was a macro. It's not in the actual Rust grammar. But at the end, the thing you have, where you can. Make a new array in the way we just said.
Jim McQuillan:Mmhm.
Wolf:That that collection… is Rust. Okay, I got it by making a macro happen.
Jim McQuillan:Okay, yeah.
Wolf:That's what I'm saying. In our discussions earlier, you and me, um, it sounded a lot like you were saying, look, if you use a macro to get it.
Jim McQuillan:Okay.
Wolf:Then it's an add-on, it's not Rust, it's a thing that you added. That's what it sounded like, and I obviously misheard you, and I apologize.
Jim McQuillan:Okay. I, uh… I'm still confused, but that's alright. I've been confused for 45 minutes now.
Wolf:A nice thing about macros, though, is in Rust, by convention. A thing that actually is a macro has a pound sign in its name, so you'll know right away where to find it and maybe fix it or make your own, whatever that might be. So you don't say print line, you say print line pound sign, or…
Jim McQuillan:Mmhm.
Wolf:I think that pound sign goes at the end.
Jim McQuillan:Hum.
Wolf:So a really great thing. I'm on to a new topic. about Rust is that in a lot of languages, and Python has a quite annoying problem with this. Is that… Things fall into two worlds. Either a thing is an expression. Or, it's a statement. For instance, in Python. assignment. is a statement. So, in the old world, uh, or in some languages, like C, for instance, you can say A equals B equals C equals D.
Jim McQuillan:Mmhm.
Wolf:Because assignment is an expression. And that COMPLETE. sentence that I just said. ends with a semicolon, and that semicolon is a statement that happened to contain all those expressions. It goes from right to left. where C equals D is the expression that gets evaluated first.
Jim McQuillan:Okay.
Wolf:And the value of that expression is the value of D.
Jim McQuillan:Mmhm.
Wolf:And that value, which is now unnamed. is the right side of the expression B equals something, and now that expression is evaluated.
Jim McQuillan:That thing, right.
Wolf:In Python, when you would say… A equals B. That was an assignment. Or that was a yeah, that was that was a complete statement. And that statement was an assignment. So, if you said A equals B. You are done. Umm. And that was annoying. Uh, and a common beginner mistake. Is, people would say, if… Open parenthesis. A equals B, close parenthesis, is none. So there I've just written an assignment. And then a test for none.
Jim McQuillan:Uh-huh.
Wolf:But that can't happen in Python, or couldn't. Because assignment is a statement. Python fixed that. a while ago, I think in 3.10, using the walrus operator, colon equals. So if you want, uh, to say. the thing I just said in Python, now you put the A equals B in parentheses, but it's A colon equals B. And now it works! Well… In Rust. Almost all. Things that happen. are expressions. Even when to a programmer of C or Perl or Python, they look like statements. They return a value. And "if" doesn't just do its thing. It returns its value. And that means you can use it INSIDE something else. Is this always the right thing to do? Eh, no, no it's not. But that means that there are tons of little things you could have done, uh, that all compose. I'm not gonna go too deep into this, but it's a big change, and I think it's useful. Umm. The thing I want to talk about next, and we're getting closer to the end. is performance. Ah. Rust. It's kind of awesome because it does all the great stuff we've talked about so far. In the same performance league. as C and C++. Now, I was a little cautious there, maybe you could hear the asterisk. It turns out that, um… Rust isn't always as fast as C or C++. Rust, by default, does runtime checks, like bounds checks, and… Other things. It's in the same league. A Rust program is vastly closer to a C++ program than a Java program is, and that's vastly closer than a Python program is. But if you write it in C, there's lots of stuff you can not do at all. that the Rust program is going to do, and the C program is going to beat you. Now. If you try really hard. You can catch up. And Rust gives you ASM blocks if you want to go that far. Please don't. But you could.
Jim McQuillan:Umm.
Wolf:Um, Rust lets you turn off certain kinds of checks, which you could. As always, I'm going to say… Measure. Measure the system. Are you looking at the place where it's gonna make a difference? If you are, okay, maybe this is the answer, I don't know. you better measure first. Um… Another interesting thing is that rust um. has WASM as a direct compile target. It's built in. You, instead of compiling to a particular platform, you can compile to WASM. We've talked about that.
Jim McQuillan:The WebAssembly stuff, yeah.
Wolf:Uh, I don't know if you have an episode number handy, Jim, but maybe you'll put it in the show notes.
Jim McQuillan:That's that's cool. of a year. Yeah, I'll, uh… I'll find it.
Wolf:Um… And one interesting. Consequence of Rust's speed is… If you're writing in Python, or Perl, or whatever, and you come to the one spot that needs to go fast. And your language can't do it. And there wasn't a library for this, like in Python, I can lean heavily on NumPy for lots of stuff, or whatever it is. Here's a place where Rust might be able to hop in.
Jim McQuillan:Hmm.
Wolf:There is.
Jim McQuillan:Yah.
Wolf:A cost. Oh, by the way, the WebAssembly stuff we talked about a long time ago in episode number 3. That's why.
Jim McQuillan:Yeah, that's, that's a long, that's 30 episodes ago or, or so.
Wolf:Neither of us can remember the number. Yeah. Um, but just like, uh, originally was a big deal with C, and then with Python, and several other things, interoperability. uh, is a huge factor in Rust. Um… So, it has the foreign function interface to call C functions. Pi O3, which I've used and really love. Um, I worked with a great company that gave some workshops on that to learn how to use Pi O3. Essentially, the end product of that is. You are holding a Python module in your hand, or what in all ways looks like a Python module. But everything past the import is Rust. To you, it's Python. To the machine, it's rust. There's another one called Maturin. Mattern is a build tool and can help. Um… UV and Ruff are Python tools. They're both written in Rust. Atuin, I talked about, written in Rust. A lot of stuff there. So, that leads me directly to… The real world proof. Rust is out there. Discord wrote some hot internal services, read states. They had a GC problem. Rust didn't have that problem? Now, in the place where Discord had that problem, it doesn't. The Linux kernel now accepting Rust contributions. I heard words from Linux himself. That, um… The Linux kernel is moving towards Rust. I don't know what that means. I don't know if I actually heard those words from him, or if it was a misquote. But it sounds very promising. AWS, Firecracker, um, that's the micro-VM technology underneath Lambdas, that's now Rust. Um… There's tons of stuff. Cloudflare has Pingora. That's their Rust-built proxy. A huge amount of their NGINX footprint. at the edge are also the runtime is behind Cloudflare workers. Um, a smaller but notable, uh, Figma's multiplayer sync engine. Meta's Mononoke source control backend? 1Password's core? Um… I use a ton of CLI tools that are written in Rust. Like, I use ripgrep. Um, I use FD instead of FIND. I use EZA instead of LS. I use BAT instead of CAT. I use delta to see my git diffs. Um, I don't use Z oxide, but that's a good way to do CD. Um, I use Starship, as everyone should. That's a cross-shell prompt. I use Atoine. That's the better way to get through your shell history. There's a tool called Just. That is a replacement for Make, but a lot easier. I don't use it, but it's around. There's TOKAI, if I'm saying it right. Um, that's a code line counter. There's ZELEGE, which I've looked at. It's in the world of screen and TMUX. I'm still on TMUX, and there's Alacrity, and I don't know how to say this, but I think it's. Wheeze term? I know you've used alacrity.
Jim McQuillan:Or western? I have.
Wolf:Have you used Western too?
Jim McQuillan:I have not… I don't even believe I've heard of it.
Wolf:Huh. Um…
Jim McQuillan:I'll have to try it out.
Wolf:There's libraries like Polars. I use Pandas, but Polars is super interesting. It's column-based instead of row-based, and it's supposed to be a big. Spina, if that's your problem, um… Deno, uh, Turbo Pack, SWC, uh, TIKV, um. hugerent.
Jim McQuillan:Man, there's a lot of stuff.
Wolf:Wasmer. Tori. Tons of stuff. Um, and I've left out things. I left out all the blockchain crap, because… We have feelings about blockchains.
Jim McQuillan:Yep.
Wolf:So everything I've said so far is. You know, the happy path. Uh, but I can't… leave out. I must be completely transparent. I can't leave out the downsides. Um, Rust is complicated. Um, the ownership model, the trade system, generics, um… If you intend to actually know and use Rust yourself. And not just hand it over to some AI, and you already know how I feel about that. Oh, maybe you don't. Let me sum it up. Mistake. But if you're going to do it yourself. Um… AI can help you. Don't ask AI to solve the problem. Ask AI to explain it. Ask AI to guide you along the path to figure it out. Rust is picky. It wants you to do the right thing. And it's like a super pedantic PhD mother. Um, it is not going to, um… clean your plate for you, but it is going to tell you how to clean your plate. Um… The compile time… and coming from a Python guy where there IS no compile time… Rust has a slow compile time. There's lots of ways to address this. But in general, that's not gonna happen for you until you actually get there. This is a downside. Uh, big dependency trees. If you're a node user, you've already seen this. You write a 15-line node program, and you do the dependency thing, and a thousand. Packages flash by? Okay, I'm exaggerating. Rust isn't quite that bad. But quite is. load-bearing in that statement. Rust is young. In terms of a tortoise, Rust is about 10 years old. So, it's been around, but we are finding rough edges. We are learning new things. It's been maturing and fast and that also means there are changes happening. It's under active development. Which makes it as bad as C++. C++ with having a brand new addition everywhere. Now, Rust has answers to this. One is the Rust toolchain. Um, it lets you pick specifically. which Rust you're using. And lets you have multiple toolchains installed at the same time. and it includes a thing called the addition system. So there's additions, 2015, 2018, 2021. I'm using the latest, which is 2024. So your old code.
Jim McQuillan:Hum.
Wolf:knows what edition it is, and will keep compiling, so that's good, but yeah, it's developing. Um, so… I'm gonna give you a quote. The language might change under me. That's the quote. It's true of basically every actively developed language, C++, Python, whatever, you name it. Rust is one of the few that engineered an actual mechanism. So that only matters when you decide it matters. I think there's only one thing left to talk about. And that is…
Jim McQuillan:Yeah, how do I get started?
Wolf:So there's good news?
Jim McQuillan:Yep.
Wolf:And there's good news! Which do you want first?
Jim McQuillan:Well, give me the good news.
Wolf:Uh, the good news is… You can do it in under a minute. Um, there is one command to start you up, and once you've used that one command. There's one more command. to do absolutely everything else. So yeah, you gotta go to the Rust place, and go get Rustup. R-U-S-T-U-P, one word, Rustup. Maybe you brew install it, maybe you… whatever. However you get it, you get it. Um, probably we can provide a link in the show notes.
Jim McQuillan:Sure.
Wolf:Um… And once you've got rust up. You can install Rust. uh, by installing Cargo, or, or whatever. Um, and you can build your first Rust project. If you, like, Cargo is the other tool, the thing that does everything else. Um, and you'll use RustUp to install cargo. And then you can say. cargo. New. Hello World. Uh… And then you go into that project, and say cargo run, and it will compile and run your brand new project. and your project will print, Hello World, and it'll do everything it takes to do that. The dependency management, the every everything.
Jim McQuillan:Hmmm.
Wolf:It'll do all of that, the whole thing, from I don't have Rust up to finished. In under a minute.
Jim McQuillan:Hum.
Wolf:Um, and now you're saying hello world. That's how you start. Now, would you like to know the other good news?
Jim McQuillan:Yes, yes, I'm waiting on pins and needles. Wondering what it could be.
Wolf:The other good news is that Cargo lets you install packages whenever you need them. And one package that you can install, and there's a website, we'll link to that in the show notes as well, called Rustlings. Rustlings is a series of tiny programs. You know, and they start, like, four lines long or whatever. And the programs don't compile. They're Rust. Rust that doesn't compile. And you open multiple terminal windows. In one, you run Rustlings. And in the other, your editor is looking at the bad file. You… Make, you learn about that Rust concept. Maybe by reading the Rust book, which we're also going to link to, which is the fundamental authority. Or whatever, but they start small, so a lot of them are answers, and by the way, the compiler errors are super, uh, helpful to figuring it out, so maybe you don't even look at the book. You fix the error. You save the file. Rust in the terminal window notices it. compiles it. decides that you got it right. and at that moment, in another place nearby, generates the correct, or what it thinks the answer was, version of the file. It doesn't open it. The point is. When you started, you didn't know what was right. When you're done. You know your version was right enough to compile. And you can look at the classic definition of right. And then you move on to the next one.
Jim McQuillan:Hum.
Wolf:I love rustlings. I do it myself. They're bite-sized pieces. You learn exactly the right thing, in the right place, at the right pace. If you want to skip a bunch of them because you already know stuff, go ahead, you can do that. Umm. End. In the same way. The AI could have helped you understand something better. On an arbitrary Rust problem? Just as helpful here. So use AI. Umm. I'm gonna bring it back. Two. The original. thesis. Um, and question to Jim. The thesis is… For everyone listening. Even if you never ship a line of Rust in production. I believe, and my thesis is. Time spent with rust. changes how you will see ownership, error handling, and type design everywhere else. So that opens the question back to you, Jim. with what I've said, even though you jokingly characterized your… your side of the conversation as, I didn't understand anything for the last 45 minutes. What is your thinking about that statement?
Jim McQuillan:Oh, yeah, I think it's absolutely true that if I learned Rust, I would learn fundamental things that would apply to my everyday work, even if I'm not programming in Rust. It's, you know, I found that with Swift. I think differently after playing in Swift. And I think Rust is even more.
Wolf:And there are several languages like this.
Jim McQuillan:Sure.
Wolf:Um, like, for instance, um… Haskell or Lisp. Or, um… There's another one that starts with H, I always… anyway! But the difference between Rust and those languages are… A large body of people might learn Lisp. But a very tiny fraction of that group. would actually be interested in writing a Lisp program? I think… that the more Rust you learn. the more interested in writing a Rust program you will become. That's what I think. Um… And. I think that's all I've got to say. In case it wasn't clear from the beginning. I really like Rust. Umm. Python… Is my daily driver? And until recently. I would describe it as my absolute favorite language, maybe even still. But boy, rust is very strong competition. Um…
Jim McQuillan:Yeah, I remember watching you as you were going through this, because there were points where you weren't… It wasn't going to be your favorite language. It was fun watching.
Wolf:It wasn't going to be a language I worried about in 10 more days.
Jim McQuillan:Yeah, it was…
Wolf:It has no null?
Jim McQuillan:Yeah, right. No exceptions? What? Yeah, but it was fun watching you go through those stages of learning and come out the other side.
Wolf:I'll give it five more days.
Jim McQuillan:I'm really liking the language. I should learn it. Um… you know, I'm so busy with my… my daily job, uh, but I can see there would be an advantage to learning it. So I should… I should at least try that rustlings thing and check out the book. Damn.
Wolf:Can we add one more link to the show notes?
Jim McQuillan:Sure.
Wolf:When we're about to publish the show notes, let's stick on a link that points to… engineering philosophy.
Jim McQuillan:Your thing?
Wolf:Yes.
Jim McQuillan:Yeah, absolutely. Give me the link, or put it in the show notes, or put it in the outline, I'll add it to the show notes.
Wolf:Will do.
Jim McQuillan:Yeah. I'm, I'm excited for that. And, and I wanna, I wanna read through that and, uh, and possibly, uh, contribute the, uh, whatever knowledge I have in SQL or any other language.
Wolf:I would love to work with you on an SQL section, um, because I know SQL!
Jim McQuillan:Oh. Yep. Yeah, that'd be great. Huh-huh.
Wolf:Um, but the difference between, uh, you and me with respect to SQL is I don't yet have those giant, um… Uh, scorch marks on my arms from moving the big heavy pot.
Jim McQuillan:Yeah.
Wolf:I don't know if our listeners will remember, that was one of the opening scenes, maybe, of…
Jim McQuillan:Yeah, I've. Yeah, so.
Wolf:Kung Fu, the TV series. Wait, when was that, the 70s?
Jim McQuillan:Uh, wise, wise, wise choice, weed hopper, uh, grasshopper. I think Weed Hopper was the, was the Mad Magazine, uh, spoof on, uh, Kung Fu. Yeah. What a wise choice, grasshopper. Yeah, you're dating us. Yeah, because that was back in the 70s.
Wolf:Oh, and me saying four decades of hard-won engineering experience doesn't date me?
Jim McQuillan:Yeah. Yeah, right.
Wolf:Yeah, I started when I was two.
Jim McQuillan:Yeah, I get, I get it. All right. Well, that was some very interesting information. I encourage everybody to check out the show notes to learn more, where you'll also find the links for sending us feedback. Please, send us feedback. Send us questions. Send us about… send us email about nothing to do with this episode. If you want, just… if you have questions, send them to us, and we'll… we'll take a look at it. Uh, and it might turn into an episode at some point. So, yeah. You can find us wherever fine podcasts are found. I mean, you already found us, so why am I telling you how to find our podcast? But we do have a website, runtimearguments.fm. We do have email addresses. Um, and we're on Mastodon, and uh, yeah, check, check us out. Uh, tell your friends about it. Uh, you know, we want to get out there to, uh, to as many people as we possibly can. Um… So, Wolf, I just want to say, thank you for potting with me. I'm enjoying this. We've been doing this for a while, and I enjoy it every single time.
Wolf:This was like a double scoop Sunday for me, because I got to spend, um, you know, a little… we spend a bit longer on the… on Zoom together than the actual podcast recording takes. So I got to spend, you know, two and a half hours with you, and that is an ice cream scoop. And two. I got to talk about Rust! Uh, boy was that fun. I love talking about Rust. I love writing code in Rust. And, uh, so let me add on to that. Thanks to Jim Peterson for the suggestion, because, uh, you made possible.
Jim McQuillan:Yeah. Yes.
Wolf:a double scoop. So this was great for me. And I guess I want to say to everybody, thanks and goodbye.
Jim McQuillan:Yah. Yeah, goodbye.
Podcasts we love
Check out these other fine podcasts recommended by us, not an algorithm.
CoRecursive: Coding Stories
Adam Gordon Bell - Software Developer
Two's Complement
Ben Rady and Matt GodboltAccidental Tech Podcast
Marco Arment, Casey Liss, John Siracusa
Python Bytes
Michael Kennedy and Calvin Hendryx-Parker