WEBVTT
00:00:00.000 --> 00:00:07.000
Welcome to another episode of Runtime Arguments. I'm Jim McQuillan, and here's Wolf.
00:00:07.000 --> 00:00:16.000
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.
00:00:16.000 --> 00:00:24.000
Hey. Hey, thanks. This is episode 32, our 33rd episode. Am I doing the math right?
00:00:24.000 --> 00:00:25.000
I think here.
00:00:25.000 --> 00:00:40.000
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.
00:00:40.000 --> 00:00:51.000
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.
00:00:52.000 --> 00:01:08.000
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.
00:01:08.000 --> 00:01:26.000
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.
00:01:26.000 --> 00:01:37.000
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.
00:01:37.000 --> 00:01:53.000
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.
00:01:53.000 --> 00:02:08.000
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.
00:02:08.000 --> 00:02:21.000
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?
00:02:20.000 --> 00:02:23.000
Well known to YouTubers.
00:02:21.000 --> 00:02:22.000
PewDiePie?
00:02:23.000 --> 00:02:26.000
Okay, not to me, but…
00:02:24.000 --> 00:02:27.000
Well, a certain category of YouTubers.
00:02:26.000 --> 00:02:41.000
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.
00:02:41.000 --> 00:02:49.000
Several months ago, we did an episode on databases, and I talked a lot about SQL.
00:02:49.000 --> 00:03:04.000
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.
00:03:04.000 --> 00:03:17.000
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.
00:03:17.000 --> 00:03:38.000
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.
00:03:38.000 --> 00:03:43.000
uh, exclude to that. So you could say, uh, select list.
00:03:43.000 --> 00:03:58.000
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.
00:03:58.000 --> 00:04:04.000
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.
00:04:02.000 --> 00:04:08.000
Would it really be a list? Or would it be select star exclude something?
00:04:07.000 --> 00:04:16.000
Well, you say select star, and that, by default, gets all of them, and then… You say excluding, or exclude.
00:04:16.000 --> 00:04:23.000
one or more columns. So you'd get all the columns except those that are in your exclude list, which.
00:04:23.000 --> 00:04:27.000
Just seems really, really useful for me.
00:04:25.000 --> 00:04:38.000
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.
00:04:28.000 --> 00:04:30.000
Yeah, yep, yep.
00:04:34.000 --> 00:04:38.000
Oh yeah, this is all interactive. Yeah.
00:04:38.000 --> 00:04:40.000
Yeah.
00:04:38.000 --> 00:04:48.000
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.
00:04:45.000 --> 00:04:54.000
Absolutely. In fact, we, we have a rule at my company when you, when you embed SQL into the program.
00:04:54.000 --> 00:04:56.000
We don't use wild cards.
00:04:56.000 --> 00:05:18.000
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.
00:05:11.000 --> 00:05:12.000
Uh-huh.
00:05:18.000 --> 00:05:24.000
qualify your column names with the table name. So, you know, if you have a patient.
00:05:24.000 --> 00:05:30.000
dot name, you always say select patient dot name. You never just say select name from patients.
00:05:30.000 --> 00:05:37.000
or select them from patient, in this case. Uh, we always qualify our column names with table names.
00:05:37.000 --> 00:05:38.000
Good.
00:05:39.000 --> 00:05:56.000
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.
00:05:57.000 --> 00:06:12.000
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.
00:06:12.000 --> 00:06:25.000
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.
00:06:23.000 --> 00:06:25.000
Yeah, it's valuable.
00:06:25.000 --> 00:06:41.000
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.
00:06:41.000 --> 00:06:54.000
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.
00:06:54.000 --> 00:07:07.000
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.
00:07:07.000 --> 00:07:14.000
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.
00:07:14.000 --> 00:07:21.000
This is what I want. So, yeah, um, that, do you have any feedback, Wolf?
00:07:16.000 --> 00:07:17.000
Yeah.
00:07:21.000 --> 00:07:24.000
Anything you want to say about that?
00:07:22.000 --> 00:07:23.000
up.
00:07:24.000 --> 00:07:28.000
Uh, about that specific item?
00:07:26.000 --> 00:07:29.000
No, anything, any kind of feedback.
00:07:29.000 --> 00:07:32.000
Or that item. I don't care.
00:07:31.000 --> 00:07:49.000
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.
00:07:40.000 --> 00:07:43.000
Yep. Yeah, you saw it.
00:07:43.000 --> 00:07:45.000
Okay, well.
00:07:49.000 --> 00:08:04.000
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.
00:07:54.000 --> 00:07:56.000
Yah.
00:08:04.000 --> 00:08:06.000
But apparently we talk too much.
00:08:06.000 --> 00:08:10.000
Well… One of us talks too much.
00:08:09.000 --> 00:08:13.000
I wonder which one.
00:08:11.000 --> 00:08:16.000
Sometimes, sometimes I talk too much.
00:08:16.000 --> 00:08:21.000
But, yeah. Anyway, how was your wolf? How was your week, wolf?
00:08:21.000 --> 00:08:28.000
Um, well, I've been exhausted, but man, this has been a really, really good week.
00:08:28.000 --> 00:08:34.000
Um, I have had… first of all, I've accomplished a lot at work.
00:08:34.000 --> 00:08:45.000
Second of all, I have had, uh, another open source PR, uh, accepted and merged. That one was to Helix.
00:08:45.000 --> 00:08:49.000
And I have had some reviewers.
00:08:47.000 --> 00:08:50.000
Oh, the Helix one got merged in?
00:08:49.000 --> 00:08:53.000
My my helix one got merged in.
00:08:51.000 --> 00:08:54.000
That's… That's cool.
00:08:54.000 --> 00:09:02.000
And I also, speaking of helix, by the way, hear that we are super close to a helix with.
00:09:02.000 --> 00:09:08.000
Steel, which is the scheme-based language.
00:09:08.000 --> 00:09:19.000
For, um… Uh, building plugins and whatnot, that'd be a big deal. Uh, I have a PR out.
00:09:10.000 --> 00:09:13.000
Oh, for doing plugins or extensions?
00:09:13.000 --> 00:09:15.000
Nice.
00:09:19.000 --> 00:09:29.000
for DirEnv, which I use all the time, that adds layout UV. It hasn't been accepted, but I have actual people.
00:09:29.000 --> 00:10:14.000
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.
00:10:02.000 --> 00:10:03.000
Umm.
00:10:14.000 --> 00:10:24.000
But in a case like this, the real hierarchy is FCEDIT, which is the editor you have set for the FC command.
00:10:21.000 --> 00:10:23.000
Huh-huh.
00:10:24.000 --> 00:10:43.000
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.
00:10:40.000 --> 00:10:44.000
Oh, uh, yeah, the alternate system? Yeah.
00:10:43.000 --> 00:10:53.000
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.
00:10:52.000 --> 00:11:03.000
And just so everybody knows, add toing is the command line, shell history, edit commands, all that kind of stuff.
00:11:03.000 --> 00:11:15.000
Right, so when you're in a shell, almost every shell does this. If you use Ctrl+R, you can search backwards in time.
00:11:15.000 --> 00:11:27.000
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.
00:11:27.000 --> 00:11:32.000
is a fast, Rust-based, smart.
00:11:32.000 --> 00:11:48.000
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.
00:11:48.000 --> 00:12:07.000
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.
00:12:07.000 --> 00:12:09.000
It doesn't.
00:12:09.000 --> 00:12:21.000
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.
00:12:21.000 --> 00:12:27.000
Uh, Atoine calls this edit mode. You're now able to edit the command.
00:12:26.000 --> 00:12:29.000
It's a one-line edit mode.
00:12:29.000 --> 00:12:39.000
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!
00:12:37.000 --> 00:12:38.000
Yeah.
00:12:39.000 --> 00:12:50.000
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.
00:12:39.000 --> 00:12:40.000
Right.
00:12:49.000 --> 00:12:52.000
Yeah, it launches the editor and…
00:12:52.000 --> 00:12:54.000
And now you're editing it.
00:12:52.000 --> 00:12:55.000
Giving you your command line, yeah.
00:12:54.000 --> 00:13:05.000
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.
00:13:05.000 --> 00:13:21.000
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.
00:13:21.000 --> 00:13:34.000
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.
00:13:34.000 --> 00:13:44.000
then, uh, I think you say, um, Ctrl-E, Ctrl-X, maybe, and boom, you're in your editor, whatever you've set.
00:13:42.000 --> 00:13:44.000
Okay.
00:13:44.000 --> 00:13:55.000
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.
00:13:55.000 --> 00:14:10.000
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.
00:14:10.000 --> 00:14:26.000
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.
00:14:26.000 --> 00:14:27.000
type.
00:14:27.000 --> 00:14:29.000
Control V.
00:14:29.000 --> 00:14:36.000
And now, it's just like you did FC already. You're in your favorite editor, do whatever you want.
00:14:37.000 --> 00:14:48.000
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.
00:14:48.000 --> 00:15:02.000
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.
00:14:52.000 --> 00:14:53.000
Sure.
00:14:59.000 --> 00:15:10.000
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.
00:15:02.000 --> 00:15:03.000
Yeah.
00:15:11.000 --> 00:15:14.000
Is there a way to abort that?
00:15:11.000 --> 00:15:13.000
Yes.
00:15:14.000 --> 00:15:27.000
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.
00:15:27.000 --> 00:15:28.000
Mmhm.
00:15:27.000 --> 00:15:32.000
In Vim, if you say colon Q exclamation point.
00:15:31.000 --> 00:15:33.000
Mmhm.
00:15:32.000 --> 00:15:35.000
You abandoned it, and it doesn't execute.
00:15:34.000 --> 00:15:35.000
Okay.
00:15:36.000 --> 00:15:49.000
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.
00:15:49.000 --> 00:16:01.000
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…
00:15:49.000 --> 00:15:51.000
But if you did a quit.
00:16:01.000 --> 00:16:02.000
Oh, sure.
00:16:01.000 --> 00:16:05.000
Save and execute that, and nothing would happen.
00:16:05.000 --> 00:16:07.000
Okay.
00:16:06.000 --> 00:16:08.000
So.
00:16:07.000 --> 00:16:09.000
So.
00:16:08.000 --> 00:16:18.000
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.
00:16:10.000 --> 00:16:11.000
Yeah.
00:16:18.000 --> 00:16:25.000
when you make that decision, you're already in the editor, and I'm not… there's no code from me, I don't…
00:16:22.000 --> 00:16:23.000
Yes.
00:16:23.000 --> 00:16:28.000
Right. Editor has control. Yeah. You're not going to send a signal or something. Yeah.
00:16:26.000 --> 00:16:27.000
Right.
00:16:28.000 --> 00:16:30.000
I get it. Okay, cool.
00:16:28.000 --> 00:16:32.000
Okay, but here's the important thing.
00:16:31.000 --> 00:16:33.000
Yes.
00:16:32.000 --> 00:16:36.000
It is not pushed to GitHub.
00:16:36.000 --> 00:16:37.000
At this moment.
00:16:37.000 --> 00:16:43.000
But by the time you are listening to this podcast, it will be.
00:16:43.000 --> 00:16:55.000
Um, I am about to push… what I am, at this moment, considering to be maybe the most meaningful.
00:16:55.000 --> 00:17:09.000
repo, new repo of mine, content from me, to GitHub. And the name of this repo is… Engineering Philosophy. Engineering-Philosophy.
00:17:06.000 --> 00:17:08.000
Oh, right.
00:17:09.000 --> 00:17:14.000
Um, and it's kinda big. I'd start at the README.
00:17:14.000 --> 00:17:21.000
Um, it's not all that big, but if you were to read every file there, it's about 2 hours worth of reading.
00:17:21.000 --> 00:17:22.000
Two.
00:17:22.000 --> 00:17:31.000
But it's about… Um… The battle-tested knowledge I have.
00:17:31.000 --> 00:17:33.000
on writing software.
00:17:34.000 --> 00:17:38.000
This is the stuff I feel is worth it.
00:17:38.000 --> 00:17:39.000
Knowing.
00:17:39.000 --> 00:17:50.000
It was super hard won. I've been doing this for four decades. And, you know, this isn't… All made up or discovered.
00:17:50.000 --> 00:18:05.000
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.
00:17:53.000 --> 00:17:55.000
Sure.
00:18:05.000 --> 00:18:20.000
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.
00:18:20.000 --> 00:18:28.000
Um… But this is a thing, including ways to audit your code.
00:18:28.000 --> 00:18:32.000
with an actual audit list to see if it's good enough.
00:18:32.000 --> 00:18:33.000
Umm.
00:18:33.000 --> 00:18:41.000
I think this is valuable. I think this is maybe the most valuable thing.
00:18:41.000 --> 00:18:52.000
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.
00:18:50.000 --> 00:18:55.000
So this is… so this is your… your version of the art of programming.
00:18:56.000 --> 00:19:00.000
That you're going to get out there and share.
00:18:57.000 --> 00:19:00.000
Although much, much shorter, yes.
00:19:00.000 --> 00:19:02.000
Well… Shorter now?
00:19:03.000 --> 00:19:09.000
Right? You think the first version of The Art of Programming was long?
00:19:08.000 --> 00:19:10.000
I do.
00:19:10.000 --> 00:19:22.000
The fact that it's 7 volumes now, and I'm not sure if I'm counting a thing he calls fascicles as volumes?
00:19:10.000 --> 00:19:14.000
Okay. All right.
00:19:16.000 --> 00:19:18.000
Yeah.
00:19:22.000 --> 00:19:26.000
But I kinda am. Damn, that thing's big.
00:19:26.000 --> 00:19:27.000
Yes.
00:19:26.000 --> 00:19:30.000
Anyway, that was my my week.
00:19:27.000 --> 00:19:35.000
All right, well… I've been working on a project.
00:19:38.000 --> 00:19:45.000
When, Wolf, when you, when you work on a new thing, maybe it's a new, really big thing.
00:19:45.000 --> 00:19:53.000
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?
00:19:53.000 --> 00:19:55.000
And then you execute.
00:19:53.000 --> 00:19:56.000
Nope, because that's waterfall.
00:19:56.000 --> 00:19:59.000
Here's what I do.
00:19:59.000 --> 00:20:04.000
I have a general idea of.
00:20:04.000 --> 00:20:16.000
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.
00:20:06.000 --> 00:20:08.000
Yah.
00:20:16.000 --> 00:20:28.000
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.
00:20:28.000 --> 00:20:29.000
Mmhm.
00:20:28.000 --> 00:20:31.000
Right? And that…
00:20:29.000 --> 00:20:32.000
Yeah, that's… that's… yeah.
00:20:32.000 --> 00:20:42.000
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.
00:20:42.000 --> 00:20:53.000
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…
00:20:47.000 --> 00:20:49.000
Sure, sure.
00:20:51.000 --> 00:20:54.000
Okay, good.
00:20:53.000 --> 00:20:55.000
is I say to myself.
00:20:56.000 --> 00:21:02.000
Well, this looks really important, this one right here. How many appointments do I have this week?
00:21:02.000 --> 00:21:10.000
What's the right way to show it to him, and how can I write something that proves that's useful?
00:21:10.000 --> 00:21:12.000
Minimum viable product.
00:21:12.000 --> 00:21:16.000
And then I do it. The minimum viable product.
00:21:14.000 --> 00:21:16.000
Okay, well.
00:21:16.000 --> 00:21:32.000
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.
00:21:32.000 --> 00:21:37.000
And it's an amazing system, but it's 20 years old.
00:21:37.000 --> 00:21:50.000
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.
00:21:50.000 --> 00:21:53.000
But ever since then, I've been wanting to rewrite it.
00:21:54.000 --> 00:22:09.000
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.
00:22:09.000 --> 00:22:24.000
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.
00:22:24.000 --> 00:22:45.000
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.
00:22:45.000 --> 00:23:00.000
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.
00:23:01.000 --> 00:23:17.000
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.
00:23:17.000 --> 00:23:21.000
But having done it is a whole different thing.
00:23:21.000 --> 00:23:31.000
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.
00:23:32.000 --> 00:23:42.000
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.
00:23:42.000 --> 00:23:53.000
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…
00:23:51.000 --> 00:24:07.000
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.
00:24:05.000 --> 00:24:06.000
Yah.
00:24:07.000 --> 00:24:14.000
Not to a mathematician, obviously, but to anybody who's not using numbers as numbers.
00:24:07.000 --> 00:24:09.000
Right.
00:24:14.000 --> 00:24:16.000
and not working.
00:24:16.000 --> 00:24:30.000
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.
00:24:30.000 --> 00:24:45.000
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.
00:24:30.000 --> 00:24:32.000
Yeah, yeah.
00:24:45.000 --> 00:24:51.000
possible? It's not a quantum change. It's THE change.
00:24:45.000 --> 00:24:48.000
Yeah, yeah, yeah.
00:24:49.000 --> 00:24:50.000
No.
00:24:51.000 --> 00:24:52.000
Yah.
00:24:52.000 --> 00:25:05.000
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.
00:25:05.000 --> 00:25:21.000
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.
00:25:18.000 --> 00:25:35.000
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.
00:25:35.000 --> 00:25:39.000
You don't know if you can get to one.
00:25:38.000 --> 00:25:44.000
Exactly! Right? Am I good enough? Right?
00:25:41.000 --> 00:25:54.000
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.
00:25:45.000 --> 00:25:51.000
Yeah, right! Exactly.
00:25:53.000 --> 00:25:55.000
That's the stuff…
00:25:54.000 --> 00:26:09.000
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?
00:25:58.000 --> 00:25:59.000
Yeah.
00:26:02.000 --> 00:26:03.000
And.
00:26:07.000 --> 00:26:08.000
Yeah.
00:26:09.000 --> 00:26:17.000
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.
00:26:17.000 --> 00:26:21.000
Right? Now you're just haggling.
00:26:18.000 --> 00:26:26.000
Yeah. Yeah. Yeah. Yeah. Well, I don't know how that applies to what we're talking about, but it's a funny story.
00:26:28.000 --> 00:26:41.000
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?
00:26:41.000 --> 00:26:43.000
You ready?
00:26:41.000 --> 00:26:44.000
I think we should.
00:26:43.000 --> 00:26:46.000
All right, all right, take it away.
00:26:44.000 --> 00:26:51.000
So, we're gonna talk about Rust. Uh, a lot of people have wanted us to talk about Rust.
00:26:51.000 --> 00:27:00.000
And I think there's a lot of people in the world who never heard of the language Rust.
00:27:00.000 --> 00:27:07.000
Uh, there's a lot of people in the world who have never looked, but they're like, oh, screw that.
00:27:07.000 --> 00:27:19.000
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.
00:27:19.000 --> 00:27:22.000
any of the problems that they have.
00:27:22.000 --> 00:27:30.000
Um… I am always curious and when something.
00:27:30.000 --> 00:27:43.000
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.
00:27:43.000 --> 00:27:59.000
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.
00:27:59.000 --> 00:28:02.000
But when you do stuff in C.
00:28:02.000 --> 00:28:07.000
Have you ever, um… Leaked? Have you leaked memory?
00:28:07.000 --> 00:28:08.000
Oh, sure.
00:28:08.000 --> 00:28:10.000
Sure.
00:28:09.000 --> 00:28:10.000
Have you?
00:28:10.000 --> 00:28:14.000
tried to dereference a null pointer.
00:28:14.000 --> 00:28:22.000
Yeah, I've written a lot of C, but it's always fairly small things.
00:28:22.000 --> 00:28:30.000
not mission-critical stuff, so when I try to dereference a null pointer, unexpected behavior happens.
00:28:30.000 --> 00:28:38.000
Uh-huh. Have you written stuff? And now we're expanding into the world of Pearl.
00:28:31.000 --> 00:28:33.000
Right?
00:28:38.000 --> 00:28:40.000
Where.
00:28:40.000 --> 00:28:44.000
You didn't call it exactly right.
00:28:44.000 --> 00:28:52.000
Uh, and the way the, uh, API was described, the, the function signature.
00:28:52.000 --> 00:29:07.000
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?
00:29:05.000 --> 00:29:07.000
Sure.
00:29:07.000 --> 00:29:10.000
Yeah, sure. And, and, and Pearl does not help you there.
00:29:10.000 --> 00:29:24.000
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.
00:29:25.000 --> 00:29:26.000
Umm.
00:29:26.000 --> 00:29:33.000
So, what we are discussing is, if you drew a circle on a piece of paper.
00:29:33.000 --> 00:29:41.000
And inside the circle was how Rust works. And outside the circle was everything else.
00:29:41.000 --> 00:29:48.000
We're talking about everything else. Now we're going to talk about what's inside the circle.
00:29:44.000 --> 00:29:45.000
Okay.
00:29:48.000 --> 00:29:54.000
Um, and the most important thing about Rust.
00:29:54.000 --> 00:30:06.000
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.
00:30:06.000 --> 00:30:18.000
Rust is not another C++. It's not another, um… I don't know, scheme, or… it's not any of those things.
00:30:18.000 --> 00:30:27.000
It is its own brand new thing with its own brand new way of thinking.
00:30:27.000 --> 00:30:46.000
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.
00:30:46.000 --> 00:31:03.000
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.
00:31:04.000 --> 00:31:13.000
That's a thing you could have if you wanted it, Jim. I know you get it in JavaScript.
00:31:13.000 --> 00:31:20.000
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…
00:31:20.000 --> 00:31:56.000
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.
00:31:56.000 --> 00:31:58.000
Okay.
00:31:58.000 --> 00:32:03.000
Well… Rust is a big change.
00:32:03.000 --> 00:32:07.000
And… I'm not saying.
00:32:07.000 --> 00:32:10.000
You should go use Rust.
00:32:10.000 --> 00:32:13.000
I'm absolutely not saying.
00:32:13.000 --> 00:32:24.000
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.
00:32:24.000 --> 00:32:42.000
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.
00:32:42.000 --> 00:32:48.000
I think one way Rust can help you involves you not writing Rust at all.
00:32:48.000 --> 00:32:53.000
But learn Rust and then come home.
00:32:53.000 --> 00:32:57.000
Because Rust has new ways of thinking.
00:32:57.000 --> 00:33:07.000
When there are multiple political groups, and they never talk to each other, they have very, very different thoughts, and they hate each other.
00:33:08.000 --> 00:33:13.000
When you get a group together that mixes those.
00:33:13.000 --> 00:33:16.000
very divergent populations.
00:33:16.000 --> 00:33:27.000
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.
00:33:27.000 --> 00:33:31.000
Um… If you learn Rust.
00:33:31.000 --> 00:33:35.000
Even if you're not going to become a crustacean.
00:33:35.000 --> 00:33:44.000
Uh… You're going to have new knowledge that changes the way you think about and talk about.
00:33:45.000 --> 00:33:48.000
Problems you do solve.
00:33:48.000 --> 00:33:54.000
Um, so, I want you, or anyone, the listener.
00:33:54.000 --> 00:34:10.000
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.
00:34:10.000 --> 00:34:17.000
And you will learn some things, and those things will come back to you.
00:34:17.000 --> 00:34:20.000
in the language that is your daily driver.
00:34:20.000 --> 00:34:28.000
If you're writing JavaScript, this is going to help you write different, and I assert, better JavaScript.
00:34:28.000 --> 00:34:41.000
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.
00:34:41.000 --> 00:34:51.000
We did an episode a while ago called, um… Choosing the Right Language, that was episode number 28.
00:34:51.000 --> 00:35:04.000
Um… Rust is the, uh… the whole point is the model change costs more than a syntax change. Budget accordingly idea.
00:35:04.000 --> 00:35:08.000
What I'm suggesting now is that… Flipped.
00:35:08.000 --> 00:35:12.000
Understand the model change.
00:35:12.000 --> 00:35:19.000
But don't put yourself in a place where that's a requirement for you to move forward in writing your code.
00:35:19.000 --> 00:35:23.000
Figure out what it means. Why did they do it?
00:35:23.000 --> 00:35:32.000
That's like learning a new language. When you can speak French, suddenly you can talk about foods you never talked about before.
00:35:32.000 --> 00:35:38.000
Important to me. On the food front, maybe less important to you, Jim, but something.
00:35:38.000 --> 00:35:40.000
Yep.
00:35:40.000 --> 00:35:50.000
Have you, in your world, encountered a machine, a program, a tool, a language, anything?
00:35:50.000 --> 00:36:02.000
that… I don't care whether that… thing, whatever it was, ended up being the thing for you. But you learning about it.
00:36:02.000 --> 00:36:03.000
Changed.
00:36:04.000 --> 00:36:08.000
How you went on from there with other things.
00:36:09.000 --> 00:36:13.000
For instance, when you went from COBOL…
00:36:09.000 --> 00:36:11.000
No.
00:36:11.000 --> 00:36:12.000
Yeah.
00:36:13.000 --> 00:36:17.000
to COBOL plus a database.
00:36:17.000 --> 00:36:22.000
When I look back at your life, I feel like that was a change for you.
00:36:21.000 --> 00:36:23.000
It's a huge change, yeah.
00:36:23.000 --> 00:36:24.000
Yeah.
00:36:24.000 --> 00:36:36.000
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.
00:36:36.000 --> 00:36:52.000
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.
00:36:53.000 --> 00:36:55.000
Big.
00:36:55.000 --> 00:37:10.000
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.
00:37:10.000 --> 00:37:12.000
I don't see in other languages.
00:37:12.000 --> 00:37:13.000
So, yeah.
00:37:12.000 --> 00:37:22.000
Outside the scope of Rust, for just a second, I think the words you just said are critical.
00:37:22.000 --> 00:37:30.000
The mark in my mind of intelligence in general is.
00:37:30.000 --> 00:37:33.000
The ability to add new facts.
00:37:33.000 --> 00:37:39.000
to your internal model, learning. When you learn new things and change.
00:37:40.000 --> 00:37:53.000
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.
00:37:54.000 --> 00:37:56.000
But I'm going to go a little bit further.
00:37:56.000 --> 00:38:02.000
I think when you accept new facts into your world.
00:38:02.000 --> 00:38:07.000
And they disagree with your existing opinions.
00:38:07.000 --> 00:38:20.000
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?
00:38:21.000 --> 00:38:30.000
I think that puts you at the front of the line. Um, and when you let learning about databases change you.
00:38:30.000 --> 00:38:35.000
from a COBOL person into a person who can use databases?
00:38:35.000 --> 00:38:42.000
I think that means you're, you are what we all aspire to be.
00:38:42.000 --> 00:38:55.000
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!
00:38:55.000 --> 00:38:56.000
Mmhm.
00:38:55.000 --> 00:39:02.000
Um… So, uh, first of all, good on you, and second of all.
00:39:02.000 --> 00:39:06.000
Here's some more sharp metal to put at the tip of your arrow.
00:39:07.000 --> 00:39:08.000
Now.
00:39:08.000 --> 00:39:13.000
The thing that everybody talks about, or knows about.
00:39:13.000 --> 00:39:18.000
Um, when they hear rust is, oh, rust.
00:39:18.000 --> 00:39:21.000
It's got that ownership model.
00:39:22.000 --> 00:39:23.000
That's the thing.
00:39:23.000 --> 00:39:27.000
And so let's talk about that first.
00:39:27.000 --> 00:39:34.000
Um… It's the actual reason Rust exists.
00:39:34.000 --> 00:39:45.000
And I'm gonna tell you the three different worlds that there are. Um, in C and C++.
00:39:45.000 --> 00:39:51.000
you manage memory by hand. Like in C, you use malloc and free, right?
00:39:51.000 --> 00:39:52.000
Huh-huh.
00:39:52.000 --> 00:40:01.000
Uh, and boy, is that easy to screw up. Um, in C++, ooh-hoo-hoo, they gave them better names! New and Delete.
00:40:01.000 --> 00:40:22.000
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.
00:40:22.000 --> 00:40:25.000
I'm sure you've heard it before.
00:40:25.000 --> 00:40:34.000
CVEs come from this category of error more frequently than almost any other.
00:40:25.000 --> 00:40:26.000
Yes.
00:40:34.000 --> 00:40:50.000
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.
00:40:50.000 --> 00:41:16.000
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.
00:41:16.000 --> 00:41:31.000
And reference counting is a thing that Objective-C and Swift can do. RC is reference counting. ARC is automatic reference counting.
00:41:31.000 --> 00:41:33.000
Which is slightly better.
00:41:34.000 --> 00:41:39.000
a thing called COM, the Common Object Model in Microsoft.
00:41:39.000 --> 00:41:54.000
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.
00:41:54.000 --> 00:42:00.000
And when you were done with it, you had to explicitly deck wrap it. How awful was that?
00:42:00.000 --> 00:42:11.000
Um… Anyway… Then there is a new category. It's the rust category.
00:42:11.000 --> 00:42:16.000
And the Rust category is that the compiler.
00:42:16.000 --> 00:42:19.000
at compile time.
00:42:19.000 --> 00:42:22.000
Before it's ever run.
00:42:22.000 --> 00:42:28.000
Looks at for every single resource.
00:42:28.000 --> 00:42:30.000
Owns it.
00:42:30.000 --> 00:42:36.000
How long does it need to be valid and alive?
00:42:36.000 --> 00:42:37.000
Umm.
00:42:38.000 --> 00:42:43.000
How many people are going to use it at the same time?
00:42:43.000 --> 00:42:48.000
And is that reasonable? And when it's done.
00:42:48.000 --> 00:42:50.000
It should go away.
00:42:50.000 --> 00:42:59.000
Uh, it's all automatic, and there's stuff a normal other… in one of the other categories wouldn't detect.
00:42:59.000 --> 00:43:08.000
For instance, the idea of two different hunks of code writing to the same variable at the same time.
00:43:09.000 --> 00:43:13.000
Is there ever a time that's not a bug?
00:43:14.000 --> 00:43:20.000
I mean, if you wrote something where you meant for that to happen.
00:43:20.000 --> 00:43:31.000
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.
00:43:31.000 --> 00:43:37.000
Whether it results in undefined program behavior or not, it's not the right thing to do.
00:43:37.000 --> 00:43:45.000
So, Rust says, for any object, there is exactly one writer.
00:43:45.000 --> 00:43:56.000
Or… There are no writers and some non-zero number of readers.
00:43:56.000 --> 00:44:06.000
This has so many powerful benefits. One is that coherency is always maintained.
00:44:06.000 --> 00:44:17.000
Two is that there's a lot more stuff that you can deduce about code that you're looking at.
00:44:17.000 --> 00:44:35.000
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.
00:44:35.000 --> 00:44:40.000
And when you send a piece of data across the channel.
00:44:40.000 --> 00:44:49.000
you're not getting a reference, typically. What you're getting is a new copy of the data on the other side.
00:44:49.000 --> 00:45:02.000
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.
00:45:03.000 --> 00:45:15.000
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.
00:45:15.000 --> 00:45:20.000
How it happens, as long as they obey those rules.
00:45:20.000 --> 00:45:23.000
Um, so this ownership thing.
00:45:23.000 --> 00:45:28.000
involves how many people can write to it, how long it lives.
00:45:28.000 --> 00:45:36.000
what happens when it goes away? Uh, and by the way, there aren't constructors or destructors in Rust.
00:45:36.000 --> 00:45:47.000
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.
00:45:47.000 --> 00:45:52.000
Which is fascinating to me. So.
00:45:53.000 --> 00:46:00.000
The rules are every value has exactly one owner at a time. One.
00:46:00.000 --> 00:46:15.000
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.
00:46:16.000 --> 00:46:22.000
And if you have the drop trait, then you get the destructor version of drop.
00:46:23.000 --> 00:46:24.000
So.
00:46:24.000 --> 00:46:44.000
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.
00:46:44.000 --> 00:46:54.000
programmer, because it's relentless in its error messages. And when you first face them, the error messages are impenetrable.
00:46:54.000 --> 00:46:56.000
But I promise you.
00:46:56.000 --> 00:47:03.000
If you spend some time, not only do the error messages gradually become clear.
00:47:03.000 --> 00:47:08.000
They are among the very best error messages you could reasonably get.
00:47:08.000 --> 00:47:11.000
Because Rust error messages.
00:47:11.000 --> 00:47:19.000
usually point much, much closer to where the real problem is than I've seen in any other language.
00:47:19.000 --> 00:47:27.000
They tell you better what's wrong, and once you understand all the parts, you'll understand it better.
00:47:27.000 --> 00:47:32.000
And they almost always tell you exactly how to fix it.
00:47:32.000 --> 00:47:35.000
And they tell you the right thing.
00:47:35.000 --> 00:47:38.000
So… I think that's.
00:47:36.000 --> 00:47:47.000
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?
00:47:40.000 --> 00:47:42.000
Sure.
00:47:48.000 --> 00:47:49.000
Yes.
00:47:48.000 --> 00:47:53.000
Like, like if I own something, I can hand it off to a sub routine.
00:47:53.000 --> 00:47:54.000
That now owns it?
00:47:54.000 --> 00:47:56.000
That's correct.
00:47:54.000 --> 00:47:57.000
Is that right? Okay.
00:47:56.000 --> 00:47:58.000
But guess what?
00:47:58.000 --> 00:48:03.000
If you… Gave it to a subroutine?
00:48:03.000 --> 00:48:10.000
You aren't an owner during the execution of that subroutine, and also.
00:48:06.000 --> 00:48:08.000
Anymore, right.
00:48:09.000 --> 00:48:10.000
Okay.
00:48:10.000 --> 00:48:16.000
You don't automatically get it back when the subroutine returns?
00:48:15.000 --> 00:48:17.000
Okay.
00:48:16.000 --> 00:48:21.000
Unless the subroutine returns it, and you take it back.
00:48:23.000 --> 00:48:25.000
Okay.
00:48:27.000 --> 00:48:29.000
Thanks.
00:48:31.000 --> 00:48:36.000
Super? Like, I know that sounds… Clear as mud.
00:48:36.000 --> 00:48:40.000
Um… But once you start using it, you're like.
00:48:40.000 --> 00:48:42.000
Oh, that's great.
00:48:42.000 --> 00:48:46.000
I think I need to try that… I need to try that Rustlings thing.
00:48:42.000 --> 00:48:44.000
I really like that.
00:48:46.000 --> 00:48:51.000
So, there are escape hatches.
00:48:51.000 --> 00:48:53.000
up.
00:48:53.000 --> 00:49:10.000
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.
00:49:10.000 --> 00:49:18.000
Um… So… That that lets you have what you want.
00:49:18.000 --> 00:49:20.000
But by default.
00:49:20.000 --> 00:49:24.000
gives you laws that are gonna stop you.
00:49:24.000 --> 00:49:30.000
from shooting yourself in the foot as soon as you learn to cooperate with the error messages.
00:49:30.000 --> 00:49:37.000
Um, so GC pauses are, like, a huge thing in GC-collected languages.
00:49:34.000 --> 00:49:38.000
GC garbage collector pauses.
00:49:38.000 --> 00:49:43.000
GC means garbage collector, yes. So if you're in a garbage-collected language.
00:49:39.000 --> 00:49:41.000
Yeah.
00:49:43.000 --> 00:49:50.000
like, um, Perl and Java and JavaScript and TypeScript.
00:49:50.000 --> 00:49:54.000
These GC pauses can be a big deal. Has that ever hit you?
00:49:55.000 --> 00:49:58.000
No. I've never had a problem with it.
00:49:58.000 --> 00:50:02.000
I wonder if that's because you're not writing long running stuff.
00:49:58.000 --> 00:50:02.000
You know, Pearl does reference counting.
00:50:02.000 --> 00:50:15.000
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.
00:50:15.000 --> 00:50:18.000
and doing things blocking you.
00:50:18.000 --> 00:50:21.000
You know, when something goes outta scope, it goes away. That's all.
00:50:22.000 --> 00:50:24.000
It's never a problem for me.
00:50:22.000 --> 00:50:39.000
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…
00:50:37.000 --> 00:50:38.000
Sure.
00:50:38.000 --> 00:50:40.000
Sure.
00:50:39.000 --> 00:50:43.000
Um… Anyway, uh…
00:50:41.000 --> 00:50:44.000
Yeah, it's never hit me before, though.
00:50:44.000 --> 00:50:48.000
When I first started using Rust.
00:50:48.000 --> 00:50:54.000
Um, I was super excited to learn all the cool new things it was gonna give me.
00:50:54.000 --> 00:51:12.000
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.
00:51:04.000 --> 00:51:05.000
Yeah.
00:51:12.000 --> 00:51:17.000
But, um, I started crying, uh, whining. I started whining.
00:51:17.000 --> 00:51:26.000
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.
00:51:26.000 --> 00:51:28.000
Um, for instance.
00:51:28.000 --> 00:51:34.000
Every language I've ever used has the equivalent.
00:51:34.000 --> 00:51:35.000
of null.
00:51:36.000 --> 00:51:49.000
C has null, C++ has null, other languages have nil, Python has none, uh, SQL has null, uh, numeric stuff, like.
00:51:43.000 --> 00:51:45.000
SQL has it.
00:51:45.000 --> 00:51:46.000
Yep.
00:51:49.000 --> 00:51:59.000
Pandas and whatnot have NAN, not a number, um… Uh, when do you use in Perl? Is it zero? When is it?
00:51:58.000 --> 00:52:00.000
I'm deaf.
00:52:00.000 --> 00:52:02.000
I'm deaf.
00:52:02.000 --> 00:52:08.000
Um… Russ doesn't have that. There isn't one.
00:52:09.000 --> 00:52:13.000
Like, but what if you want a pointer that doesn't point to anything?
00:52:13.000 --> 00:52:15.000
Guess what?
00:52:15.000 --> 00:52:16.000
Nope.
00:52:15.000 --> 00:52:17.000
You don't.
00:52:17.000 --> 00:52:32.000
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.
00:52:32.000 --> 00:52:45.000
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.
00:52:45.000 --> 00:52:53.000
Which is that all Go functions, but not as a definition of the language, as a convention.
00:52:53.000 --> 00:53:06.000
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.
00:53:06.000 --> 00:53:09.000
It's the fact that you're a Go user that makes you do it.
00:53:09.000 --> 00:53:14.000
Um, I didn't like it, and it made me shy away from Go.
00:53:14.000 --> 00:53:19.000
It doesn't make go bad, but it was a thing I wanted and I didn't have.
00:53:19.000 --> 00:53:29.000
Um… Another thing that I really enjoy is inheritance. Inheritance is great, especially when used.
00:53:29.000 --> 00:53:43.000
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.
00:53:39.000 --> 00:53:41.000
Mmhm.
00:53:43.000 --> 00:53:51.000
And another way inheritance is good is about inheriting and sharing code.
00:53:52.000 --> 00:53:58.000
It turns out that, uh, for a long, long time, anybody who does this for a job.
00:53:58.000 --> 00:54:08.000
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.
00:54:08.000 --> 00:54:11.000
Guess what Rust doesn't have?
00:54:11.000 --> 00:54:14.000
inheritance.
00:54:11.000 --> 00:54:24.000
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.
00:54:24.000 --> 00:54:33.000
In C++, class and struct are basically identical, except for the default assignment of visibility to the underlying pieces of.
00:54:33.000 --> 00:54:38.000
Uh, uh, the underlying members. Uh, in Rust, there's, there's only struct.
00:54:38.000 --> 00:54:40.000
And there's no inheritance.
00:54:40.000 --> 00:54:56.000
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…
00:54:55.000 --> 00:54:56.000
Mmhm.
00:54:56.000 --> 00:54:59.000
and a bowling ball, they both fall at the same time.
00:54:59.000 --> 00:55:03.000
Sure, that's true, and the thing I just told you is true.
00:55:03.000 --> 00:55:12.000
But it is a lie, because if you're dropping a feather, and a bowling ball, and the moon.
00:55:13.000 --> 00:55:18.000
Those three things close the gap at different rates.
00:55:18.000 --> 00:55:34.000
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.
00:55:34.000 --> 00:55:43.000
caused by a feather is not measurable, and so it does fall at the same rate as a bowling ball.
00:55:43.000 --> 00:55:48.000
Of course your physics teacher is not going to tell you that, and in fact, you're going to be asked.
00:55:48.000 --> 00:55:55.000
to see the principal when you bring it up. But, um, it happens that…
00:55:52.000 --> 00:55:56.000
You speak from experience.
00:55:55.000 --> 00:55:56.000
Yes.
00:55:56.000 --> 00:56:02.000
It happens that in Rust, there is inheritance.
00:56:02.000 --> 00:56:16.000
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.
00:56:16.000 --> 00:56:23.000
It happens in traits and protocols and whatnot or it's not called whatever anyway.
00:56:23.000 --> 00:56:25.000
So.
00:56:25.000 --> 00:56:30.000
What do I get instead of those things? I can't return null.
00:56:30.000 --> 00:56:37.000
Uh, instead, Rust has this tremendous thing called enums, enumerations.
00:56:37.000 --> 00:56:38.000
Mmhm.
00:56:37.000 --> 00:56:51.000
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.
00:56:51.000 --> 00:56:52.000
So.
00:56:52.000 --> 00:56:58.000
Either you get a T or you don't get a T as a result, for instance.
00:56:59.000 --> 00:57:07.000
So, we would return T, or we would return none, or null, or whatever it is for your language.
00:57:07.000 --> 00:57:10.000
In Rust, you make a type.
00:57:10.000 --> 00:57:18.000
That type happens to underline BNENUM, and it only has two possibilities.
00:57:18.000 --> 00:57:24.000
The values… the possibilities for that T are the value SUM.
00:57:24.000 --> 00:57:28.000
or the value none.
00:57:28.000 --> 00:57:31.000
The value sum is a T.
00:57:32.000 --> 00:57:41.000
And the value none isn't anything. So yes, you can't return none, except, kind of, you can.
00:57:41.000 --> 00:57:46.000
So, option T, there isn't a global none?
00:57:46.000 --> 00:57:52.000
But there is something, and when you actually start using it and thinking about it.
00:57:52.000 --> 00:57:57.000
It turns out to be better. So I kind of take that.
00:57:57.000 --> 00:58:00.000
There's no exceptions.
00:58:00.000 --> 00:58:07.000
But instead of an exception, um, if it might be that you could.
00:58:07.000 --> 00:58:10.000
Uh, not do the right thing.
00:58:11.000 --> 00:58:27.000
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.
00:58:27.000 --> 00:58:38.000
Um… Your answer might be either you found the supplier or.
00:58:38.000 --> 00:58:44.000
you couldn't get a connection. And not being able to get a connection is an error.
00:58:44.000 --> 00:58:53.000
Well, instead of raising an exception, you make your result type be RESULT.
00:58:53.000 --> 00:59:01.000
and that's a parameterizable type, where it takes the T, the supplier type.
00:59:01.000 --> 00:59:03.000
And an error type.
00:59:03.000 --> 00:59:15.000
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.
00:59:15.000 --> 00:59:19.000
It's another case of an enum.
00:59:19.000 --> 00:59:30.000
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?
00:59:30.000 --> 00:59:36.000
You actually have to look. It's not unlike Go's model.
00:59:36.000 --> 00:59:43.000
Except that… You're forced to look, and it's designed into the language.
00:59:43.000 --> 01:00:01.000
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.
01:00:01.000 --> 01:00:12.000
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.
01:00:12.000 --> 01:00:29.000
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?
01:00:30.000 --> 01:00:32.000
Uh, switch.
01:00:32.000 --> 01:00:36.000
Uh, and in… in Rust, we call it a match.
01:00:37.000 --> 01:00:43.000
uh, Swift does a really good thing, and Rust does that same thing.
01:00:43.000 --> 01:00:49.000
And that same thing is… Uh, this kind of statement, a match.
01:00:49.000 --> 01:00:51.000
Must be exhaustive.
01:00:51.000 --> 01:00:53.000
Yes.
01:00:51.000 --> 01:00:54.000
Um, so, for instance.
01:00:53.000 --> 01:00:55.000
I like that about Swift.
01:00:55.000 --> 01:01:03.000
If you say that an order has three possible states, uh, which is, uh, placed.
01:01:03.000 --> 01:01:08.000
Um… Prepared and shipped.
01:01:09.000 --> 01:01:18.000
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.
01:01:18.000 --> 01:01:19.000
And.
01:01:19.000 --> 01:01:24.000
That is probably not a particular case that you would handle with it.
01:01:24.000 --> 01:01:48.000
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.
01:01:42.000 --> 01:01:44.000
Polymorphism.
01:01:48.000 --> 01:01:51.000
The consequences are so different, but.
01:01:51.000 --> 01:02:01.000
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.
01:02:01.000 --> 01:02:09.000
Um, placed… Um… Uh, preparing and shipped, there's also canceled.
01:02:09.000 --> 01:02:15.000
Suddenly, all 3 or 4 of those places where you used that match before?
01:02:15.000 --> 01:02:17.000
They don't silently fail.
01:02:17.000 --> 01:02:21.000
They all fail to compile.
01:02:21.000 --> 01:02:22.000
Right.
01:02:21.000 --> 01:02:24.000
because you weren't exhaustive.
01:02:24.000 --> 01:02:25.000
Right.
01:02:24.000 --> 01:02:25.000
Umm.
01:02:25.000 --> 01:02:27.000
That's fantastic.
01:02:27.000 --> 01:02:28.000
So.
01:02:29.000 --> 01:02:41.000
This leads me to a thing I have said over and over about so many languages, and that is… The type system?
01:02:41.000 --> 01:02:46.000
in Rust is powerful enough to let you.
01:02:46.000 --> 01:02:49.000
Design and build the planet.
01:02:49.000 --> 01:02:51.000
Promises.
01:02:51.000 --> 01:02:56.000
you intend for your code to make.
01:02:56.000 --> 01:03:03.000
Um… And there's sort of a… uh, escape hatch that I want to talk about, too.
01:03:03.000 --> 01:03:08.000
But the combination of traits and generics.
01:03:08.000 --> 01:03:12.000
Let the entire function signature become.
01:03:12.000 --> 01:03:15.000
become a complete contract.
01:03:15.000 --> 01:03:29.000
in a way that is not obvious from any other language. If your function takes an option, and that's parameterizable, type, and generic.
01:03:29.000 --> 01:03:36.000
On, um, order… Then that means you could have taken an order.
01:03:36.000 --> 01:03:42.000
or not. And that's the contract, and it's obvious from the signature.
01:03:42.000 --> 01:03:52.000
If your function returns a result, um, status, comma, and then some subcategory of errors.
01:03:52.000 --> 01:04:01.000
Um, that's a contract. It says it might not succeed, and here's the kind of failure it could have.
01:04:01.000 --> 01:04:11.000
Um… This is genuinely one of the strongest type systems in mainstream use.
01:04:11.000 --> 01:04:28.000
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.
01:04:28.000 --> 01:04:32.000
All those things together are part of the type system.
01:04:32.000 --> 01:04:42.000
Make this… Um, a genuinely powerful type system, maybe the most powerful I've seen.
01:04:43.000 --> 01:04:47.000
And that thing about being picky?
01:04:47.000 --> 01:04:56.000
That's where this comes in. It's picky. It wants you to understand and satisfy those constraints.
01:04:56.000 --> 01:05:01.000
And the really complicated error messages you won't understand at first?
01:05:02.000 --> 01:05:04.000
Tell you how.
01:05:04.000 --> 01:05:11.000
And finally, um, there's a special escape hatch for so much of this.
01:05:11.000 --> 01:05:13.000
Umm.
01:05:13.000 --> 01:05:23.000
I had mentioned before some of Rust's rules, like the number and kind of owners, a specific.
01:05:23.000 --> 01:05:33.000
variable can have and some of them here are about what kinds of types things can be.
01:05:33.000 --> 01:05:37.000
Well, there's an escape hatch. It's very badly named.
01:05:37.000 --> 01:05:42.000
Um, the escape hatch is named… unsafe.
01:05:43.000 --> 01:05:52.000
And… it's a block. You say, unsafe, open curly brace. You say some things, closed curly brace.
01:05:53.000 --> 01:05:55.000
Here's why it's badly named.
01:05:56.000 --> 01:06:03.000
There are actually seven traits, seven important promises.
01:06:03.000 --> 01:06:11.000
that, um, Rust requires to be enforced, and are enforced by the compiler and the Varro checker.
01:06:11.000 --> 01:06:19.000
Unsafe the word makes it sound like inside this block you don't have to do those things?
01:06:19.000 --> 01:06:22.000
That is not what it means.
01:06:22.000 --> 01:06:24.000
Unsafe means.
01:06:25.000 --> 01:06:27.000
I promise.
01:06:27.000 --> 01:06:33.000
that even though I'm about to say things in a way.
01:06:33.000 --> 01:06:37.000
The compiler wouldn't have the power to prove.
01:06:38.000 --> 01:06:41.000
Meet those seven criteria.
01:06:42.000 --> 01:06:44.000
They will.
01:06:44.000 --> 01:06:47.000
And by the time you get out of it.
01:06:47.000 --> 01:06:52.000
They still will and you can check again.
01:06:52.000 --> 01:06:54.000
That's what that says.
01:06:54.000 --> 01:07:04.000
So you use unsafe, for instance, if the thing you're about to do is you've got a giant array.
01:07:04.000 --> 01:07:09.000
And you need to move items out of the way to push something in the middle.
01:07:09.000 --> 01:07:19.000
That's an incredibly difficult thing to do if you also have to satisfy all of these promises.
01:07:19.000 --> 01:07:29.000
and let Rust make its, um, out-of-band runtime checks, proving it's all okay.
01:07:29.000 --> 01:07:35.000
What you want to do is say, I'm just going to do it. It has to be done.
01:07:35.000 --> 01:07:38.000
I promise this is going to be okay.
01:07:38.000 --> 01:07:41.000
That's what the unsafe block says.
01:07:39.000 --> 01:07:44.000
But that's… that's shifting the burden on this developer.
01:07:44.000 --> 01:07:49.000
Uh, and the compiler isn't gonna check that code for you?
01:07:49.000 --> 01:07:51.000
That's what Unsafe says.
01:07:49.000 --> 01:07:54.000
Like, you can do unsafe things. Yeah, you can really… you can do bad things, right?
01:07:55.000 --> 01:07:59.000
But the promise is… that you won't.
01:07:59.000 --> 01:08:06.000
Let me rephrase that. You can do things that could be made to be unsafe.
01:07:59.000 --> 01:08:07.000
Yeah, but the compiler isn't gonna… isn't gonna… Sure.
01:08:06.000 --> 01:08:16.000
You can do things Rust would never let you do. You have the power to twiddle bits in ways Rust just won't allow.
01:08:10.000 --> 01:08:11.000
Right.
01:08:16.000 --> 01:08:22.000
But your promise is that by the end it's all okay.
01:08:24.000 --> 01:08:26.000
Even though it might not be.
01:08:27.000 --> 01:08:32.000
Yes, it could be that your promise was a lie.
01:08:29.000 --> 01:08:30.000
Yeah, okay.
01:08:32.000 --> 01:08:35.000
Uh, okay. It's on you.
01:08:35.000 --> 01:08:38.000
It is on you. That's what unsafe means.
01:08:36.000 --> 01:08:38.000
Yeah, okay.
01:08:38.000 --> 01:08:39.000
Yeah, okay.
01:08:40.000 --> 01:08:44.000
Having an unsafe block.
01:08:44.000 --> 01:08:46.000
Inside a function?
01:08:46.000 --> 01:09:02.000
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.
01:09:02.000 --> 01:09:07.000
An unsafe function doesn't make a module or package unsafe.
01:09:05.000 --> 01:09:08.000
It doesn't taint the module or the block.
01:09:08.000 --> 01:09:17.000
Exactly. But it is something that you can look for, and it absolutely is something you should test for.
01:09:17.000 --> 01:09:23.000
Now… I didn't really have a space to talk about this.
01:09:24.000 --> 01:09:34.000
But our friend Marlon mentions a really important third-party library package.
01:09:34.000 --> 01:09:46.000
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.
01:09:46.000 --> 01:10:00.000
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.
01:10:00.000 --> 01:10:18.000
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.
01:10:18.000 --> 01:10:24.000
And also, Honor Marlin, he's pointing out something very important. This is… this is super good knowledge.
01:10:25.000 --> 01:10:40.000
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?
01:10:41.000 --> 01:10:49.000
But first, some of you are gonna say, eh, so what, and you're wrong. And that is, Rust has macros.
01:10:50.000 --> 01:10:53.000
I hear you, C programmers.
01:10:53.000 --> 01:10:55.000
So what?
01:10:55.000 --> 01:10:58.000
No, no, no, no. Not that kind of macro.
01:10:56.000 --> 01:10:58.000
We've had those for years.
01:10:58.000 --> 01:11:10.000
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.
01:11:10.000 --> 01:11:24.000
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.
01:11:24.000 --> 01:11:33.000
This is the kind of macro that gets the already parsed token stream.
01:11:33.000 --> 01:11:49.000
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.
01:11:49.000 --> 01:11:50.000
Umm.
01:11:50.000 --> 01:11:56.000
And it does things the compiler can do.
01:11:56.000 --> 01:11:59.000
It goes from tokens.
01:11:59.000 --> 01:12:01.000
and produces.
01:12:01.000 --> 01:12:08.000
something to go next in the world. It might be that thing is more token stream.
01:12:08.000 --> 01:12:14.000
But, um, there are a lot of things in… in Lisp, for instance.
01:12:14.000 --> 01:12:25.000
Huge hunks of the Lisp language are actually implemented with macros. There isn't a while loop in Lisp.
01:12:25.000 --> 01:12:38.000
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.
01:12:38.000 --> 01:12:39.000
Umm.
01:12:39.000 --> 01:12:44.000
That you can't do that with a C macro, but you can do it in Lisp.
01:12:44.000 --> 01:12:47.000
And you can do it in Rust.
01:12:47.000 --> 01:12:53.000
Now, as it happens, Rust has all the ifs and whiles that you can care about.
01:12:53.000 --> 01:12:57.000
But there's tons of things that these macros implement.
01:12:57.000 --> 01:13:01.000
that are in the right place.
01:13:01.000 --> 01:13:07.000
Jim and I have a little disagreement about this. Um, I'm gonna say my words first.
01:13:07.000 --> 01:13:11.000
But here's some examples.
01:13:11.000 --> 01:13:26.000
Rust has some array initialization functionality affordances that let you instead of saying construct my array from.
01:13:26.000 --> 01:13:35.000
a, uh, generator, the equivalent, uh, or from another array, or from an existing, um.
01:13:39.000 --> 01:13:40.000
Umm.
01:13:40.000 --> 01:13:42.000
Uh, literal.
01:13:41.000 --> 01:13:42.000
a list.
01:13:42.000 --> 01:13:44.000
Okay.
01:13:42.000 --> 01:13:52.000
literal, constructed from a actual list. So, my array A, B, C, D, E.
01:13:52.000 --> 01:13:58.000
That's a thing that would be hard to do, maybe not impossible.
01:13:58.000 --> 01:14:01.000
with a C macro.
01:14:01.000 --> 01:14:03.000
Umm.
01:14:03.000 --> 01:14:08.000
And it makes a thing that lets you just say an array.
01:14:08.000 --> 01:14:22.000
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.
01:14:23.000 --> 01:14:35.000
My assertion is, and here's where Jim and I disagree, that some of those things that you, that you, uh, declare, define with.
01:14:35.000 --> 01:14:43.000
Rust macros, for instance, println and several others, this, uh, array construction thing.
01:14:43.000 --> 01:14:45.000
are.
01:14:45.000 --> 01:14:46.000
Rust.
01:14:46.000 --> 01:14:49.000
They are parts of the Rust language.
01:14:49.000 --> 01:14:54.000
And I don't want to misrepresent you, Jim. Why don't you give your side?
01:14:59.000 --> 01:15:02.000
I don't know.
01:15:02.000 --> 01:15:10.000
I think you're talking about initializing an array with a list of values.
01:15:10.000 --> 01:15:15.000
That just seems like a language thing to me, and you're saying you do that with a macro?
01:15:15.000 --> 01:15:22.000
I… I probably totally misunderstand.
01:15:20.000 --> 01:15:23.000
I'm saying… I'm saying.
01:15:23.000 --> 01:15:37.000
It was… designed into your system, and the implementation of it was a macro. It's not in the actual Rust grammar.
01:15:38.000 --> 01:15:44.000
But at the end, the thing you have, where you can.
01:15:44.000 --> 01:15:49.000
Make a new array in the way we just said.
01:15:48.000 --> 01:15:49.000
Mmhm.
01:15:49.000 --> 01:15:57.000
That that collection… is Rust. Okay, I got it by making a macro happen.
01:15:54.000 --> 01:15:56.000
Okay, yeah.
01:15:57.000 --> 01:16:09.000
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.
01:15:58.000 --> 01:15:59.000
Okay.
01:16:09.000 --> 01:16:18.000
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.
01:16:15.000 --> 01:16:16.000
Okay.
01:16:18.000 --> 01:16:22.000
I, uh… I'm still confused, but that's alright.
01:16:23.000 --> 01:16:27.000
I've been confused for 45 minutes now.
01:16:27.000 --> 01:16:34.000
A nice thing about macros, though, is in Rust, by convention.
01:16:34.000 --> 01:16:51.000
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…
01:16:46.000 --> 01:16:48.000
Mmhm.
01:16:51.000 --> 01:16:54.000
I think that pound sign goes at the end.
01:16:54.000 --> 01:16:55.000
Hum.
01:16:55.000 --> 01:17:00.000
So a really great thing. I'm on to a new topic.
01:17:00.000 --> 01:17:08.000
about Rust is that in a lot of languages, and Python has a quite annoying problem with this.
01:17:08.000 --> 01:17:13.000
Is that… Things fall into two worlds.
01:17:13.000 --> 01:17:16.000
Either a thing is an expression.
01:17:17.000 --> 01:17:19.000
Or, it's a statement.
01:17:19.000 --> 01:17:22.000
For instance, in Python.
01:17:23.000 --> 01:17:25.000
assignment.
01:17:25.000 --> 01:17:27.000
is a statement.
01:17:28.000 --> 01:17:39.000
So, in the old world, uh, or in some languages, like C, for instance, you can say A equals B equals C equals D.
01:17:38.000 --> 01:17:40.000
Mmhm.
01:17:39.000 --> 01:17:42.000
Because assignment is an expression.
01:17:42.000 --> 01:17:44.000
And that COMPLETE.
01:17:44.000 --> 01:17:47.000
sentence that I just said.
01:17:47.000 --> 01:17:55.000
ends with a semicolon, and that semicolon is a statement that happened to contain all those expressions.
01:17:55.000 --> 01:17:58.000
It goes from right to left.
01:17:58.000 --> 01:18:05.000
where C equals D is the expression that gets evaluated first.
01:18:04.000 --> 01:18:05.000
Okay.
01:18:05.000 --> 01:18:10.000
And the value of that expression is the value of D.
01:18:10.000 --> 01:18:11.000
Mmhm.
01:18:10.000 --> 01:18:14.000
And that value, which is now unnamed.
01:18:14.000 --> 01:18:22.000
is the right side of the expression B equals something, and now that expression is evaluated.
01:18:19.000 --> 01:18:20.000
That thing, right.
01:18:22.000 --> 01:18:28.000
In Python, when you would say… A equals B.
01:18:28.000 --> 01:18:30.000
That was an assignment.
01:18:30.000 --> 01:18:35.000
Or that was a yeah, that was that was a complete statement.
01:18:35.000 --> 01:18:40.000
And that statement was an assignment. So, if you said A equals B.
01:18:40.000 --> 01:18:41.000
You are done.
01:18:41.000 --> 01:18:43.000
Umm.
01:18:44.000 --> 01:18:46.000
And that was annoying.
01:18:46.000 --> 01:18:49.000
Uh, and a common beginner mistake.
01:18:49.000 --> 01:18:56.000
Is, people would say, if… Open parenthesis.
01:18:56.000 --> 01:19:00.000
A equals B, close parenthesis, is none.
01:19:00.000 --> 01:19:05.000
So there I've just written an assignment.
01:19:05.000 --> 01:19:07.000
And then a test for none.
01:19:05.000 --> 01:19:07.000
Uh-huh.
01:19:08.000 --> 01:19:12.000
But that can't happen in Python, or couldn't.
01:19:12.000 --> 01:19:14.000
Because assignment is a statement.
01:19:16.000 --> 01:19:19.000
Python fixed that.
01:19:19.000 --> 01:19:29.000
a while ago, I think in 3.10, using the walrus operator, colon equals. So if you want, uh, to say.
01:19:29.000 --> 01:19:38.000
the thing I just said in Python, now you put the A equals B in parentheses, but it's A colon equals B.
01:19:38.000 --> 01:19:43.000
And now it works! Well… In Rust.
01:19:43.000 --> 01:19:45.000
Almost all.
01:19:45.000 --> 01:19:47.000
Things that happen.
01:19:47.000 --> 01:19:57.000
are expressions. Even when to a programmer of C or Perl or Python, they look like statements.
01:19:57.000 --> 01:20:01.000
They return a value.
01:20:01.000 --> 01:20:05.000
And "if" doesn't just do its thing.
01:20:05.000 --> 01:20:08.000
It returns its value.
01:20:08.000 --> 01:20:18.000
And that means you can use it INSIDE something else. Is this always the right thing to do? Eh, no, no it's not.
01:20:18.000 --> 01:20:29.000
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.
01:20:29.000 --> 01:20:30.000
Umm.
01:20:32.000 --> 01:20:36.000
The thing I want to talk about next, and we're getting closer to the end.
01:20:36.000 --> 01:20:39.000
is performance.
01:20:39.000 --> 01:20:40.000
Ah.
01:20:40.000 --> 01:20:41.000
Rust.
01:20:41.000 --> 01:20:48.000
It's kind of awesome because it does all the great stuff we've talked about so far.
01:20:48.000 --> 01:20:52.000
In the same performance league.
01:20:52.000 --> 01:20:59.000
as C and C++. Now, I was a little cautious there, maybe you could hear the asterisk.
01:20:59.000 --> 01:21:08.000
It turns out that, um… Rust isn't always as fast as C or C++.
01:21:08.000 --> 01:21:17.000
Rust, by default, does runtime checks, like bounds checks, and… Other things.
01:21:17.000 --> 01:21:32.000
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.
01:21:33.000 --> 01:21:38.000
But if you write it in C, there's lots of stuff you can not do at all.
01:21:38.000 --> 01:21:44.000
that the Rust program is going to do, and the C program is going to beat you.
01:21:44.000 --> 01:21:45.000
Now.
01:21:45.000 --> 01:21:49.000
If you try really hard.
01:21:49.000 --> 01:21:59.000
You can catch up. And Rust gives you ASM blocks if you want to go that far. Please don't. But you could.
01:21:56.000 --> 01:21:58.000
Umm.
01:21:59.000 --> 01:22:04.000
Um, Rust lets you turn off certain kinds of checks, which you could.
01:22:04.000 --> 01:22:11.000
As always, I'm going to say… Measure. Measure the system.
01:22:11.000 --> 01:22:16.000
Are you looking at the place where it's gonna make a difference?
01:22:16.000 --> 01:22:21.000
If you are, okay, maybe this is the answer, I don't know.
01:22:21.000 --> 01:22:23.000
you better measure first.
01:22:23.000 --> 01:22:30.000
Um… Another interesting thing is that rust um.
01:22:30.000 --> 01:22:35.000
has WASM as a direct compile target. It's built in.
01:22:35.000 --> 01:22:41.000
You, instead of compiling to a particular platform, you can compile to WASM.
01:22:41.000 --> 01:22:44.000
We've talked about that.
01:22:42.000 --> 01:22:45.000
The WebAssembly stuff, yeah.
01:22:45.000 --> 01:22:52.000
Uh, I don't know if you have an episode number handy, Jim, but maybe you'll put it in the show notes.
01:22:45.000 --> 01:22:48.000
That's that's cool.
01:22:50.000 --> 01:22:52.000
of a year.
01:22:52.000 --> 01:22:55.000
Yeah, I'll, uh… I'll find it.
01:22:57.000 --> 01:23:01.000
Um… And one interesting.
01:23:01.000 --> 01:23:16.000
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.
01:23:16.000 --> 01:23:28.000
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.
01:23:28.000 --> 01:23:33.000
Here's a place where Rust might be able to hop in.
01:23:33.000 --> 01:23:34.000
Hmm.
01:23:34.000 --> 01:23:36.000
There is.
01:23:34.000 --> 01:23:36.000
Yah.
01:23:36.000 --> 01:23:37.000
A cost.
01:23:37.000 --> 01:23:45.000
Oh, by the way, the WebAssembly stuff we talked about a long time ago in episode number 3. That's why.
01:23:44.000 --> 01:23:50.000
Yeah, that's, that's a long, that's 30 episodes ago or, or so.
01:23:45.000 --> 01:23:48.000
Neither of us can remember the number.
01:23:48.000 --> 01:23:49.000
Yeah.
01:23:51.000 --> 01:24:02.000
Um, but just like, uh, originally was a big deal with C, and then with Python, and several other things, interoperability.
01:24:02.000 --> 01:24:06.000
uh, is a huge factor in Rust.
01:24:06.000 --> 01:24:13.000
Um… So, it has the foreign function interface to call C functions.
01:24:13.000 --> 01:24:28.000
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.
01:24:28.000 --> 01:24:37.000
You are holding a Python module in your hand, or what in all ways looks like a Python module.
01:24:37.000 --> 01:24:41.000
But everything past the import is Rust.
01:24:41.000 --> 01:24:44.000
To you, it's Python.
01:24:44.000 --> 01:24:46.000
To the machine, it's rust.
01:24:46.000 --> 01:24:50.000
There's another one called Maturin.
01:24:50.000 --> 01:24:54.000
Mattern is a build tool and can help.
01:24:54.000 --> 01:25:04.000
Um… UV and Ruff are Python tools. They're both written in Rust.
01:25:04.000 --> 01:25:08.000
Atuin, I talked about, written in Rust.
01:25:08.000 --> 01:25:12.000
A lot of stuff there.
01:25:14.000 --> 01:25:31.000
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.
01:25:31.000 --> 01:25:33.000
Rust didn't have that problem?
01:25:33.000 --> 01:25:39.000
Now, in the place where Discord had that problem, it doesn't.
01:25:39.000 --> 01:25:48.000
The Linux kernel now accepting Rust contributions. I heard words from Linux himself.
01:25:48.000 --> 01:25:56.000
That, um… The Linux kernel is moving towards Rust.
01:25:56.000 --> 01:26:03.000
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.
01:26:03.000 --> 01:26:06.000
But it sounds very promising.
01:26:06.000 --> 01:26:14.000
AWS, Firecracker, um, that's the micro-VM technology underneath Lambdas, that's now Rust.
01:26:14.000 --> 01:26:29.000
Um… There's tons of stuff. Cloudflare has Pingora. That's their Rust-built proxy. A huge amount of their NGINX footprint.
01:26:29.000 --> 01:26:36.000
at the edge are also the runtime is behind Cloudflare workers.
01:26:36.000 --> 01:26:44.000
Um, a smaller but notable, uh, Figma's multiplayer sync engine.
01:26:44.000 --> 01:26:50.000
Meta's Mononoke source control backend? 1Password's core?
01:26:50.000 --> 01:27:00.000
Um… I use a ton of CLI tools that are written in Rust. Like, I use ripgrep.
01:27:00.000 --> 01:27:10.000
Um, I use FD instead of FIND. I use EZA instead of LS. I use BAT instead of CAT.
01:27:10.000 --> 01:27:14.000
I use delta to see my git diffs.
01:27:14.000 --> 01:27:19.000
Um, I don't use Z oxide, but that's a good way to do CD.
01:27:19.000 --> 01:27:26.000
Um, I use Starship, as everyone should. That's a cross-shell prompt.
01:27:26.000 --> 01:27:34.000
I use Atoine. That's the better way to get through your shell history. There's a tool called Just.
01:27:34.000 --> 01:27:40.000
That is a replacement for Make, but a lot easier. I don't use it, but it's around.
01:27:40.000 --> 01:27:55.000
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.
01:27:55.000 --> 01:28:01.000
I'm still on TMUX, and there's Alacrity, and I don't know how to say this, but I think it's.
01:28:01.000 --> 01:28:06.000
Wheeze term? I know you've used alacrity.
01:28:04.000 --> 01:28:06.000
Or western?
01:28:06.000 --> 01:28:08.000
I have.
01:28:06.000 --> 01:28:09.000
Have you used Western too?
01:28:08.000 --> 01:28:12.000
I have not… I don't even believe I've heard of it.
01:28:12.000 --> 01:28:15.000
Huh. Um…
01:28:13.000 --> 01:28:15.000
I'll have to try it out.
01:28:15.000 --> 01:28:30.000
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.
01:28:30.000 --> 01:28:43.000
Spina, if that's your problem, um… Deno, uh, Turbo Pack, SWC, uh, TIKV, um.
01:28:44.000 --> 01:28:46.000
hugerent.
01:28:46.000 --> 01:28:48.000
Man, there's a lot of stuff.
01:28:46.000 --> 01:28:47.000
Wasmer.
01:28:47.000 --> 01:28:49.000
Tori.
01:28:50.000 --> 01:28:51.000
Tons of stuff.
01:28:52.000 --> 01:29:01.000
Um, and I've left out things. I left out all the blockchain crap, because… We have feelings about blockchains.
01:29:00.000 --> 01:29:01.000
Yep.
01:29:01.000 --> 01:29:06.000
So everything I've said so far is.
01:29:06.000 --> 01:29:08.000
You know, the happy path.
01:29:09.000 --> 01:29:20.000
Uh, but I can't… leave out. I must be completely transparent. I can't leave out the downsides. Um, Rust is complicated.
01:29:20.000 --> 01:29:32.000
Um, the ownership model, the trade system, generics, um… If you intend to actually know and use Rust yourself.
01:29:32.000 --> 01:29:38.000
And not just hand it over to some AI, and you already know how I feel about that.
01:29:38.000 --> 01:29:42.000
Oh, maybe you don't. Let me sum it up.
01:29:42.000 --> 01:29:43.000
Mistake.
01:29:44.000 --> 01:29:47.000
But if you're going to do it yourself.
01:29:47.000 --> 01:29:53.000
Um… AI can help you. Don't ask AI to solve the problem.
01:29:54.000 --> 01:30:01.000
Ask AI to explain it. Ask AI to guide you along the path to figure it out.
01:30:01.000 --> 01:30:06.000
Rust is picky. It wants you to do the right thing.
01:30:06.000 --> 01:30:11.000
And it's like a super pedantic PhD mother.
01:30:11.000 --> 01:30:21.000
Um, it is not going to, um… clean your plate for you, but it is going to tell you how to clean your plate.
01:30:21.000 --> 01:30:37.000
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.
01:30:37.000 --> 01:30:43.000
But in general, that's not gonna happen for you until you actually get there.
01:30:43.000 --> 01:30:45.000
This is a downside.
01:30:45.000 --> 01:30:58.000
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.
01:30:58.000 --> 01:31:01.000
Packages flash by? Okay, I'm exaggerating.
01:31:01.000 --> 01:31:04.000
Rust isn't quite that bad.
01:31:04.000 --> 01:31:06.000
But quite is.
01:31:06.000 --> 01:31:09.000
load-bearing in that statement.
01:31:09.000 --> 01:31:12.000
Rust is young.
01:31:12.000 --> 01:31:18.000
In terms of a tortoise, Rust is about 10 years old.
01:31:18.000 --> 01:31:26.000
So, it's been around, but we are finding rough edges. We are learning new things.
01:31:26.000 --> 01:31:36.000
It's been maturing and fast and that also means there are changes happening. It's under active development.
01:31:36.000 --> 01:31:49.000
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.
01:31:49.000 --> 01:31:53.000
Um, it lets you pick specifically.
01:31:53.000 --> 01:31:56.000
which Rust you're using.
01:31:56.000 --> 01:32:02.000
And lets you have multiple toolchains installed at the same time.
01:32:02.000 --> 01:32:15.000
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.
01:32:09.000 --> 01:32:10.000
Hum.
01:32:15.000 --> 01:32:25.000
knows what edition it is, and will keep compiling, so that's good, but yeah, it's developing.
01:32:25.000 --> 01:32:32.000
Um, so… I'm gonna give you a quote. The language might change under me.
01:32:32.000 --> 01:32:41.000
That's the quote. It's true of basically every actively developed language, C++, Python, whatever, you name it.
01:32:41.000 --> 01:32:46.000
Rust is one of the few that engineered an actual mechanism.
01:32:46.000 --> 01:32:51.000
So that only matters when you decide it matters.
01:32:51.000 --> 01:32:56.000
I think there's only one thing left to talk about.
01:32:56.000 --> 01:32:58.000
And that is…
01:32:57.000 --> 01:33:00.000
Yeah, how do I get started?
01:33:01.000 --> 01:33:04.000
So there's good news?
01:33:03.000 --> 01:33:05.000
Yep.
01:33:04.000 --> 01:33:09.000
And there's good news! Which do you want first?
01:33:07.000 --> 01:33:09.000
Well, give me the good news.
01:33:09.000 --> 01:33:17.000
Uh, the good news is… You can do it in under a minute.
01:33:17.000 --> 01:33:25.000
Um, there is one command to start you up, and once you've used that one command.
01:33:25.000 --> 01:33:27.000
There's one more command.
01:33:27.000 --> 01:33:29.000
to do absolutely everything else.
01:33:29.000 --> 01:33:40.000
So yeah, you gotta go to the Rust place, and go get Rustup. R-U-S-T-U-P, one word, Rustup.
01:33:40.000 --> 01:33:46.000
Maybe you brew install it, maybe you… whatever. However you get it, you get it.
01:33:46.000 --> 01:33:50.000
Um, probably we can provide a link in the show notes.
01:33:49.000 --> 01:33:51.000
Sure.
01:33:50.000 --> 01:33:55.000
Um… And once you've got rust up.
01:33:55.000 --> 01:33:57.000
You can install Rust.
01:33:57.000 --> 01:34:11.000
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.
01:34:11.000 --> 01:34:16.000
Um, and you'll use RustUp to install cargo.
01:34:16.000 --> 01:34:19.000
And then you can say.
01:34:19.000 --> 01:34:20.000
cargo.
01:34:20.000 --> 01:34:22.000
New.
01:34:22.000 --> 01:34:24.000
Hello World.
01:34:24.000 --> 01:34:35.000
Uh… And then you go into that project, and say cargo run, and it will compile and run your brand new project.
01:34:35.000 --> 01:34:41.000
and your project will print, Hello World, and it'll do everything it takes to do that.
01:34:41.000 --> 01:34:45.000
The dependency management, the every everything.
01:34:43.000 --> 01:34:44.000
Hmmm.
01:34:45.000 --> 01:34:50.000
It'll do all of that, the whole thing, from I don't have Rust up to finished.
01:34:50.000 --> 01:34:52.000
In under a minute.
01:34:52.000 --> 01:34:53.000
Hum.
01:34:52.000 --> 01:34:56.000
Um, and now you're saying hello world. That's how you start.
01:34:56.000 --> 01:35:02.000
Now, would you like to know the other good news?
01:35:01.000 --> 01:35:06.000
Yes, yes, I'm waiting on pins and needles.
01:35:06.000 --> 01:35:07.000
Wondering what it could be.
01:35:06.000 --> 01:35:22.000
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.
01:35:22.000 --> 01:35:28.000
Rustlings is a series of tiny programs.
01:35:28.000 --> 01:35:32.000
You know, and they start, like, four lines long or whatever.
01:35:32.000 --> 01:35:38.000
And the programs don't compile. They're Rust. Rust that doesn't compile.
01:35:38.000 --> 01:35:44.000
And you open multiple terminal windows. In one, you run Rustlings.
01:35:44.000 --> 01:35:49.000
And in the other, your editor is looking at the bad file.
01:35:51.000 --> 01:35:56.000
You… Make, you learn about that Rust concept.
01:35:56.000 --> 01:36:03.000
Maybe by reading the Rust book, which we're also going to link to, which is the fundamental authority.
01:36:03.000 --> 01:36:15.000
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.
01:36:15.000 --> 01:36:17.000
You fix the error.
01:36:17.000 --> 01:36:20.000
You save the file.
01:36:20.000 --> 01:36:24.000
Rust in the terminal window notices it.
01:36:25.000 --> 01:36:27.000
compiles it.
01:36:27.000 --> 01:36:30.000
decides that you got it right.
01:36:30.000 --> 01:36:43.000
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.
01:36:43.000 --> 01:36:47.000
When you started, you didn't know what was right.
01:36:47.000 --> 01:36:50.000
When you're done.
01:36:50.000 --> 01:36:55.000
You know your version was right enough to compile.
01:36:55.000 --> 01:37:00.000
And you can look at the classic definition of right.
01:37:00.000 --> 01:37:03.000
And then you move on to the next one.
01:37:02.000 --> 01:37:03.000
Hum.
01:37:03.000 --> 01:37:08.000
I love rustlings. I do it myself.
01:37:08.000 --> 01:37:10.000
They're bite-sized pieces.
01:37:10.000 --> 01:37:16.000
You learn exactly the right thing, in the right place, at the right pace.
01:37:16.000 --> 01:37:23.000
If you want to skip a bunch of them because you already know stuff, go ahead, you can do that.
01:37:23.000 --> 01:37:24.000
Umm.
01:37:24.000 --> 01:37:26.000
End.
01:37:26.000 --> 01:37:28.000
In the same way.
01:37:28.000 --> 01:37:34.000
The AI could have helped you understand something better.
01:37:34.000 --> 01:37:38.000
On an arbitrary Rust problem? Just as helpful here.
01:37:38.000 --> 01:37:40.000
So use AI.
01:37:40.000 --> 01:37:42.000
Umm.
01:37:42.000 --> 01:37:44.000
I'm gonna bring it back.
01:37:44.000 --> 01:37:45.000
Two.
01:37:45.000 --> 01:37:47.000
The original.
01:37:47.000 --> 01:37:49.000
thesis.
01:37:49.000 --> 01:37:56.000
Um, and question to Jim. The thesis is… For everyone listening.
01:37:56.000 --> 01:38:02.000
Even if you never ship a line of Rust in production.
01:38:03.000 --> 01:38:06.000
I believe, and my thesis is.
01:38:06.000 --> 01:38:09.000
Time spent with rust.
01:38:09.000 --> 01:38:17.000
changes how you will see ownership, error handling, and type design everywhere else.
01:38:18.000 --> 01:38:22.000
So that opens the question back to you, Jim.
01:38:22.000 --> 01:38:34.000
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.
01:38:34.000 --> 01:38:37.000
What is your thinking about that statement?
01:38:36.000 --> 01:38:50.000
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.
01:38:50.000 --> 01:38:55.000
It's, you know, I found that with Swift. I think differently after playing in Swift.
01:38:55.000 --> 01:38:59.000
And I think Rust is even more.
01:38:56.000 --> 01:39:01.000
And there are several languages like this.
01:39:00.000 --> 01:39:02.000
Sure.
01:39:01.000 --> 01:39:08.000
Um, like, for instance, um… Haskell or Lisp.
01:39:08.000 --> 01:39:27.000
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.
01:39:27.000 --> 01:39:31.000
But a very tiny fraction of that group.
01:39:31.000 --> 01:39:36.000
would actually be interested in writing a Lisp program?
01:39:36.000 --> 01:39:41.000
I think… that the more Rust you learn.
01:39:41.000 --> 01:39:46.000
the more interested in writing a Rust program you will become.
01:39:46.000 --> 01:39:48.000
That's what I think.
01:39:48.000 --> 01:39:52.000
Um… And.
01:39:52.000 --> 01:39:57.000
I think that's all I've got to say. In case it wasn't clear from the beginning.
01:39:58.000 --> 01:40:02.000
I really like Rust.
01:40:02.000 --> 01:40:03.000
Umm.
01:40:03.000 --> 01:40:08.000
Python… Is my daily driver?
01:40:08.000 --> 01:40:12.000
And until recently.
01:40:12.000 --> 01:40:17.000
I would describe it as my absolute favorite language, maybe even still.
01:40:17.000 --> 01:40:21.000
But boy, rust is very strong competition.
01:40:21.000 --> 01:40:22.000
Um…
01:40:21.000 --> 01:40:31.000
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.
01:40:31.000 --> 01:40:35.000
It was fun watching.
01:40:32.000 --> 01:40:37.000
It wasn't going to be a language I worried about in 10 more days.
01:40:36.000 --> 01:40:39.000
Yeah, it was…
01:40:37.000 --> 01:40:39.000
It has no null?
01:40:39.000 --> 01:40:50.000
Yeah, right. No exceptions? What? Yeah, but it was fun watching you go through those stages of learning and come out the other side.
01:40:39.000 --> 01:40:42.000
I'll give it five more days.
01:40:50.000 --> 01:40:55.000
I'm really liking the language. I should learn it.
01:40:55.000 --> 01:41:08.000
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.
01:41:08.000 --> 01:41:09.000
Damn.
01:41:08.000 --> 01:41:14.000
Can we add one more link to the show notes?
01:41:13.000 --> 01:41:15.000
Sure.
01:41:15.000 --> 01:41:24.000
When we're about to publish the show notes, let's stick on a link that points to… engineering philosophy.
01:41:25.000 --> 01:41:27.000
Your thing?
01:41:27.000 --> 01:41:28.000
Yes.
01:41:27.000 --> 01:41:35.000
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.
01:41:34.000 --> 01:41:36.000
Will do.
01:41:35.000 --> 01:41:47.000
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.
01:41:46.000 --> 01:41:54.000
I would love to work with you on an SQL section, um, because I know SQL!
01:41:48.000 --> 01:41:49.000
Oh.
01:41:49.000 --> 01:41:51.000
Yep.
01:41:51.000 --> 01:41:53.000
Yeah, that'd be great.
01:41:54.000 --> 01:41:55.000
Huh-huh.
01:41:54.000 --> 01:42:10.000
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.
01:42:09.000 --> 01:42:11.000
Yeah.
01:42:11.000 --> 01:42:17.000
I don't know if our listeners will remember, that was one of the opening scenes, maybe, of…
01:42:11.000 --> 01:42:12.000
Yeah, I've.
01:42:12.000 --> 01:42:13.000
Yeah, so.
01:42:17.000 --> 01:42:20.000
Kung Fu, the TV series.
01:42:20.000 --> 01:42:23.000
Wait, when was that, the 70s?
01:42:21.000 --> 01:42:27.000
Uh, wise, wise, wise choice, weed hopper, uh, grasshopper.
01:42:27.000 --> 01:42:34.000
I think Weed Hopper was the, was the Mad Magazine, uh, spoof on, uh, Kung Fu. Yeah.
01:42:34.000 --> 01:42:37.000
What a wise choice, grasshopper.
01:42:38.000 --> 01:42:43.000
Yeah, you're dating us. Yeah, because that was back in the 70s.
01:42:43.000 --> 01:42:50.000
Oh, and me saying four decades of hard-won engineering experience doesn't date me?
01:42:50.000 --> 01:42:52.000
Yeah. Yeah, right.
01:42:52.000 --> 01:42:58.000
Yeah, I started when I was two.
01:42:54.000 --> 01:42:59.000
Yeah, I get, I get it.
01:43:00.000 --> 01:43:15.000
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.
01:43:15.000 --> 01:43:30.000
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.
01:43:30.000 --> 01:43:45.000
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.
01:43:45.000 --> 01:44:00.000
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.
01:44:00.000 --> 01:44:10.000
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.
01:44:10.000 --> 01:44:25.000
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.
01:44:25.000 --> 01:44:31.000
So I got to spend, you know, two and a half hours with you, and that is an ice cream scoop.
01:44:31.000 --> 01:44:33.000
And two.
01:44:33.000 --> 01:44:49.000
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.
01:44:35.000 --> 01:44:36.000
Yeah.
01:44:46.000 --> 01:44:47.000
Yes.
01:44:49.000 --> 01:44:57.000
a double scoop. So this was great for me. And I guess I want to say to everybody, thanks and goodbye.
01:44:53.000 --> 01:44:55.000
Yah.
01:44:57.000 --> 01:44:59.000
Yeah, goodbye.
00:00:00.000 --> 00:00:07.000
Welcome to another episode of Runtime Arguments. I'm Jim McQuillan, and here's Wolf.
00:00:07.000 --> 00:00:16.000
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.
00:00:16.000 --> 00:00:24.000
Hey. Hey, thanks. This is episode 32, our 33rd episode. Am I doing the math right?
00:00:24.000 --> 00:00:25.000
I think here.
00:00:25.000 --> 00:00:40.000
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.
00:00:40.000 --> 00:00:51.000
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.
00:00:52.000 --> 00:01:08.000
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.
00:01:08.000 --> 00:01:26.000
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.
00:01:26.000 --> 00:01:37.000
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.
00:01:37.000 --> 00:01:53.000
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.
00:01:53.000 --> 00:02:08.000
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.
00:02:08.000 --> 00:02:21.000
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?
00:02:20.000 --> 00:02:23.000
Well known to YouTubers.
00:02:21.000 --> 00:02:22.000
PewDiePie?
00:02:23.000 --> 00:02:26.000
Okay, not to me, but…
00:02:24.000 --> 00:02:27.000
Well, a certain category of YouTubers.
00:02:26.000 --> 00:02:41.000
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.
00:02:41.000 --> 00:02:49.000
Several months ago, we did an episode on databases, and I talked a lot about SQL.
00:02:49.000 --> 00:03:04.000
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.
00:03:04.000 --> 00:03:17.000
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.
00:03:17.000 --> 00:03:38.000
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.
00:03:38.000 --> 00:03:43.000
uh, exclude to that. So you could say, uh, select list.
00:03:43.000 --> 00:03:58.000
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.
00:03:58.000 --> 00:04:04.000
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.
00:04:02.000 --> 00:04:08.000
Would it really be a list? Or would it be select star exclude something?
00:04:07.000 --> 00:04:16.000
Well, you say select star, and that, by default, gets all of them, and then… You say excluding, or exclude.
00:04:16.000 --> 00:04:23.000
one or more columns. So you'd get all the columns except those that are in your exclude list, which.
00:04:23.000 --> 00:04:27.000
Just seems really, really useful for me.
00:04:25.000 --> 00:04:38.000
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.
00:04:28.000 --> 00:04:30.000
Yeah, yep, yep.
00:04:34.000 --> 00:04:38.000
Oh yeah, this is all interactive. Yeah.
00:04:38.000 --> 00:04:40.000
Yeah.
00:04:38.000 --> 00:04:48.000
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.
00:04:45.000 --> 00:04:54.000
Absolutely. In fact, we, we have a rule at my company when you, when you embed SQL into the program.
00:04:54.000 --> 00:04:56.000
We don't use wild cards.
00:04:56.000 --> 00:05:18.000
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.
00:05:11.000 --> 00:05:12.000
Uh-huh.
00:05:18.000 --> 00:05:24.000
qualify your column names with the table name. So, you know, if you have a patient.
00:05:24.000 --> 00:05:30.000
dot name, you always say select patient dot name. You never just say select name from patients.
00:05:30.000 --> 00:05:37.000
or select them from patient, in this case. Uh, we always qualify our column names with table names.
00:05:37.000 --> 00:05:38.000
Good.
00:05:39.000 --> 00:05:56.000
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.
00:05:57.000 --> 00:06:12.000
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.
00:06:12.000 --> 00:06:25.000
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.
00:06:23.000 --> 00:06:25.000
Yeah, it's valuable.
00:06:25.000 --> 00:06:41.000
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.
00:06:41.000 --> 00:06:54.000
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.
00:06:54.000 --> 00:07:07.000
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.
00:07:07.000 --> 00:07:14.000
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.
00:07:14.000 --> 00:07:21.000
This is what I want. So, yeah, um, that, do you have any feedback, Wolf?
00:07:16.000 --> 00:07:17.000
Yeah.
00:07:21.000 --> 00:07:24.000
Anything you want to say about that?
00:07:22.000 --> 00:07:23.000
up.
00:07:24.000 --> 00:07:28.000
Uh, about that specific item?
00:07:26.000 --> 00:07:29.000
No, anything, any kind of feedback.
00:07:29.000 --> 00:07:32.000
Or that item. I don't care.
00:07:31.000 --> 00:07:49.000
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.
00:07:40.000 --> 00:07:43.000
Yep. Yeah, you saw it.
00:07:43.000 --> 00:07:45.000
Okay, well.
00:07:49.000 --> 00:08:04.000
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.
00:07:54.000 --> 00:07:56.000
Yah.
00:08:04.000 --> 00:08:06.000
But apparently we talk too much.
00:08:06.000 --> 00:08:10.000
Well… One of us talks too much.
00:08:09.000 --> 00:08:13.000
I wonder which one.
00:08:11.000 --> 00:08:16.000
Sometimes, sometimes I talk too much.
00:08:16.000 --> 00:08:21.000
But, yeah. Anyway, how was your wolf? How was your week, wolf?
00:08:21.000 --> 00:08:28.000
Um, well, I've been exhausted, but man, this has been a really, really good week.
00:08:28.000 --> 00:08:34.000
Um, I have had… first of all, I've accomplished a lot at work.
00:08:34.000 --> 00:08:45.000
Second of all, I have had, uh, another open source PR, uh, accepted and merged. That one was to Helix.
00:08:45.000 --> 00:08:49.000
And I have had some reviewers.
00:08:47.000 --> 00:08:50.000
Oh, the Helix one got merged in?
00:08:49.000 --> 00:08:53.000
My my helix one got merged in.
00:08:51.000 --> 00:08:54.000
That's… That's cool.
00:08:54.000 --> 00:09:02.000
And I also, speaking of helix, by the way, hear that we are super close to a helix with.
00:09:02.000 --> 00:09:08.000
Steel, which is the scheme-based language.
00:09:08.000 --> 00:09:19.000
For, um… Uh, building plugins and whatnot, that'd be a big deal. Uh, I have a PR out.
00:09:10.000 --> 00:09:13.000
Oh, for doing plugins or extensions?
00:09:13.000 --> 00:09:15.000
Nice.
00:09:19.000 --> 00:09:29.000
for DirEnv, which I use all the time, that adds layout UV. It hasn't been accepted, but I have actual people.
00:09:29.000 --> 00:10:14.000
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.
00:10:02.000 --> 00:10:03.000
Umm.
00:10:14.000 --> 00:10:24.000
But in a case like this, the real hierarchy is FCEDIT, which is the editor you have set for the FC command.
00:10:21.000 --> 00:10:23.000
Huh-huh.
00:10:24.000 --> 00:10:43.000
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.
00:10:40.000 --> 00:10:44.000
Oh, uh, yeah, the alternate system? Yeah.
00:10:43.000 --> 00:10:53.000
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.
00:10:52.000 --> 00:11:03.000
And just so everybody knows, add toing is the command line, shell history, edit commands, all that kind of stuff.
00:11:03.000 --> 00:11:15.000
Right, so when you're in a shell, almost every shell does this. If you use Ctrl+R, you can search backwards in time.
00:11:15.000 --> 00:11:27.000
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.
00:11:27.000 --> 00:11:32.000
is a fast, Rust-based, smart.
00:11:32.000 --> 00:11:48.000
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.
00:11:48.000 --> 00:12:07.000
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.
00:12:07.000 --> 00:12:09.000
It doesn't.
00:12:09.000 --> 00:12:21.000
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.
00:12:21.000 --> 00:12:27.000
Uh, Atoine calls this edit mode. You're now able to edit the command.
00:12:26.000 --> 00:12:29.000
It's a one-line edit mode.
00:12:29.000 --> 00:12:39.000
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!
00:12:37.000 --> 00:12:38.000
Yeah.
00:12:39.000 --> 00:12:50.000
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.
00:12:39.000 --> 00:12:40.000
Right.
00:12:49.000 --> 00:12:52.000
Yeah, it launches the editor and…
00:12:52.000 --> 00:12:54.000
And now you're editing it.
00:12:52.000 --> 00:12:55.000
Giving you your command line, yeah.
00:12:54.000 --> 00:13:05.000
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.
00:13:05.000 --> 00:13:21.000
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.
00:13:21.000 --> 00:13:34.000
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.
00:13:34.000 --> 00:13:44.000
then, uh, I think you say, um, Ctrl-E, Ctrl-X, maybe, and boom, you're in your editor, whatever you've set.
00:13:42.000 --> 00:13:44.000
Okay.
00:13:44.000 --> 00:13:55.000
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.
00:13:55.000 --> 00:14:10.000
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.
00:14:10.000 --> 00:14:26.000
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.
00:14:26.000 --> 00:14:27.000
type.
00:14:27.000 --> 00:14:29.000
Control V.
00:14:29.000 --> 00:14:36.000
And now, it's just like you did FC already. You're in your favorite editor, do whatever you want.
00:14:37.000 --> 00:14:48.000
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.
00:14:48.000 --> 00:15:02.000
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.
00:14:52.000 --> 00:14:53.000
Sure.
00:14:59.000 --> 00:15:10.000
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.
00:15:02.000 --> 00:15:03.000
Yeah.
00:15:11.000 --> 00:15:14.000
Is there a way to abort that?
00:15:11.000 --> 00:15:13.000
Yes.
00:15:14.000 --> 00:15:27.000
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.
00:15:27.000 --> 00:15:28.000
Mmhm.
00:15:27.000 --> 00:15:32.000
In Vim, if you say colon Q exclamation point.
00:15:31.000 --> 00:15:33.000
Mmhm.
00:15:32.000 --> 00:15:35.000
You abandoned it, and it doesn't execute.
00:15:34.000 --> 00:15:35.000
Okay.
00:15:36.000 --> 00:15:49.000
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.
00:15:49.000 --> 00:16:01.000
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…
00:15:49.000 --> 00:15:51.000
But if you did a quit.
00:16:01.000 --> 00:16:02.000
Oh, sure.
00:16:01.000 --> 00:16:05.000
Save and execute that, and nothing would happen.
00:16:05.000 --> 00:16:07.000
Okay.
00:16:06.000 --> 00:16:08.000
So.
00:16:07.000 --> 00:16:09.000
So.
00:16:08.000 --> 00:16:18.000
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.
00:16:10.000 --> 00:16:11.000
Yeah.
00:16:18.000 --> 00:16:25.000
when you make that decision, you're already in the editor, and I'm not… there's no code from me, I don't…
00:16:22.000 --> 00:16:23.000
Yes.
00:16:23.000 --> 00:16:28.000
Right. Editor has control. Yeah. You're not going to send a signal or something. Yeah.
00:16:26.000 --> 00:16:27.000
Right.
00:16:28.000 --> 00:16:30.000
I get it. Okay, cool.
00:16:28.000 --> 00:16:32.000
Okay, but here's the important thing.
00:16:31.000 --> 00:16:33.000
Yes.
00:16:32.000 --> 00:16:36.000
It is not pushed to GitHub.
00:16:36.000 --> 00:16:37.000
At this moment.
00:16:37.000 --> 00:16:43.000
But by the time you are listening to this podcast, it will be.
00:16:43.000 --> 00:16:55.000
Um, I am about to push… what I am, at this moment, considering to be maybe the most meaningful.
00:16:55.000 --> 00:17:09.000
repo, new repo of mine, content from me, to GitHub. And the name of this repo is… Engineering Philosophy. Engineering-Philosophy.
00:17:06.000 --> 00:17:08.000
Oh, right.
00:17:09.000 --> 00:17:14.000
Um, and it's kinda big. I'd start at the README.
00:17:14.000 --> 00:17:21.000
Um, it's not all that big, but if you were to read every file there, it's about 2 hours worth of reading.
00:17:21.000 --> 00:17:22.000
Two.
00:17:22.000 --> 00:17:31.000
But it's about… Um… The battle-tested knowledge I have.
00:17:31.000 --> 00:17:33.000
on writing software.
00:17:34.000 --> 00:17:38.000
This is the stuff I feel is worth it.
00:17:38.000 --> 00:17:39.000
Knowing.
00:17:39.000 --> 00:17:50.000
It was super hard won. I've been doing this for four decades. And, you know, this isn't… All made up or discovered.
00:17:50.000 --> 00:18:05.000
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.
00:17:53.000 --> 00:17:55.000
Sure.
00:18:05.000 --> 00:18:20.000
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.
00:18:20.000 --> 00:18:28.000
Um… But this is a thing, including ways to audit your code.
00:18:28.000 --> 00:18:32.000
with an actual audit list to see if it's good enough.
00:18:32.000 --> 00:18:33.000
Umm.
00:18:33.000 --> 00:18:41.000
I think this is valuable. I think this is maybe the most valuable thing.
00:18:41.000 --> 00:18:52.000
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.
00:18:50.000 --> 00:18:55.000
So this is… so this is your… your version of the art of programming.
00:18:56.000 --> 00:19:00.000
That you're going to get out there and share.
00:18:57.000 --> 00:19:00.000
Although much, much shorter, yes.
00:19:00.000 --> 00:19:02.000
Well… Shorter now?
00:19:03.000 --> 00:19:09.000
Right? You think the first version of The Art of Programming was long?
00:19:08.000 --> 00:19:10.000
I do.
00:19:10.000 --> 00:19:22.000
The fact that it's 7 volumes now, and I'm not sure if I'm counting a thing he calls fascicles as volumes?
00:19:10.000 --> 00:19:14.000
Okay. All right.
00:19:16.000 --> 00:19:18.000
Yeah.
00:19:22.000 --> 00:19:26.000
But I kinda am. Damn, that thing's big.
00:19:26.000 --> 00:19:27.000
Yes.
00:19:26.000 --> 00:19:30.000
Anyway, that was my my week.
00:19:27.000 --> 00:19:35.000
All right, well… I've been working on a project.
00:19:38.000 --> 00:19:45.000
When, Wolf, when you, when you work on a new thing, maybe it's a new, really big thing.
00:19:45.000 --> 00:19:53.000
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?
00:19:53.000 --> 00:19:55.000
And then you execute.
00:19:53.000 --> 00:19:56.000
Nope, because that's waterfall.
00:19:56.000 --> 00:19:59.000
Here's what I do.
00:19:59.000 --> 00:20:04.000
I have a general idea of.
00:20:04.000 --> 00:20:16.000
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.
00:20:06.000 --> 00:20:08.000
Yah.
00:20:16.000 --> 00:20:28.000
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.
00:20:28.000 --> 00:20:29.000
Mmhm.
00:20:28.000 --> 00:20:31.000
Right? And that…
00:20:29.000 --> 00:20:32.000
Yeah, that's… that's… yeah.
00:20:32.000 --> 00:20:42.000
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.
00:20:42.000 --> 00:20:53.000
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…
00:20:47.000 --> 00:20:49.000
Sure, sure.
00:20:51.000 --> 00:20:54.000
Okay, good.
00:20:53.000 --> 00:20:55.000
is I say to myself.
00:20:56.000 --> 00:21:02.000
Well, this looks really important, this one right here. How many appointments do I have this week?
00:21:02.000 --> 00:21:10.000
What's the right way to show it to him, and how can I write something that proves that's useful?
00:21:10.000 --> 00:21:12.000
Minimum viable product.
00:21:12.000 --> 00:21:16.000
And then I do it. The minimum viable product.
00:21:14.000 --> 00:21:16.000
Okay, well.
00:21:16.000 --> 00:21:32.000
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.
00:21:32.000 --> 00:21:37.000
And it's an amazing system, but it's 20 years old.
00:21:37.000 --> 00:21:50.000
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.
00:21:50.000 --> 00:21:53.000
But ever since then, I've been wanting to rewrite it.
00:21:54.000 --> 00:22:09.000
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.
00:22:09.000 --> 00:22:24.000
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.
00:22:24.000 --> 00:22:45.000
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.
00:22:45.000 --> 00:23:00.000
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.
00:23:01.000 --> 00:23:17.000
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.
00:23:17.000 --> 00:23:21.000
But having done it is a whole different thing.
00:23:21.000 --> 00:23:31.000
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.
00:23:32.000 --> 00:23:42.000
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.
00:23:42.000 --> 00:23:53.000
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…
00:23:51.000 --> 00:24:07.000
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.
00:24:05.000 --> 00:24:06.000
Yah.
00:24:07.000 --> 00:24:14.000
Not to a mathematician, obviously, but to anybody who's not using numbers as numbers.
00:24:07.000 --> 00:24:09.000
Right.
00:24:14.000 --> 00:24:16.000
and not working.
00:24:16.000 --> 00:24:30.000
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.
00:24:30.000 --> 00:24:45.000
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.
00:24:30.000 --> 00:24:32.000
Yeah, yeah.
00:24:45.000 --> 00:24:51.000
possible? It's not a quantum change. It's THE change.
00:24:45.000 --> 00:24:48.000
Yeah, yeah, yeah.
00:24:49.000 --> 00:24:50.000
No.
00:24:51.000 --> 00:24:52.000
Yah.
00:24:52.000 --> 00:25:05.000
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.
00:25:05.000 --> 00:25:21.000
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.
00:25:18.000 --> 00:25:35.000
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.
00:25:35.000 --> 00:25:39.000
You don't know if you can get to one.
00:25:38.000 --> 00:25:44.000
Exactly! Right? Am I good enough? Right?
00:25:41.000 --> 00:25:54.000
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.
00:25:45.000 --> 00:25:51.000
Yeah, right! Exactly.
00:25:53.000 --> 00:25:55.000
That's the stuff…
00:25:54.000 --> 00:26:09.000
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?
00:25:58.000 --> 00:25:59.000
Yeah.
00:26:02.000 --> 00:26:03.000
And.
00:26:07.000 --> 00:26:08.000
Yeah.
00:26:09.000 --> 00:26:17.000
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.
00:26:17.000 --> 00:26:21.000
Right? Now you're just haggling.
00:26:18.000 --> 00:26:26.000
Yeah. Yeah. Yeah. Yeah. Well, I don't know how that applies to what we're talking about, but it's a funny story.
00:26:28.000 --> 00:26:41.000
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?
00:26:41.000 --> 00:26:43.000
You ready?
00:26:41.000 --> 00:26:44.000
I think we should.
00:26:43.000 --> 00:26:46.000
All right, all right, take it away.
00:26:44.000 --> 00:26:51.000
So, we're gonna talk about Rust. Uh, a lot of people have wanted us to talk about Rust.
00:26:51.000 --> 00:27:00.000
And I think there's a lot of people in the world who never heard of the language Rust.
00:27:00.000 --> 00:27:07.000
Uh, there's a lot of people in the world who have never looked, but they're like, oh, screw that.
00:27:07.000 --> 00:27:19.000
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.
00:27:19.000 --> 00:27:22.000
any of the problems that they have.
00:27:22.000 --> 00:27:30.000
Um… I am always curious and when something.
00:27:30.000 --> 00:27:43.000
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.
00:27:43.000 --> 00:27:59.000
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.
00:27:59.000 --> 00:28:02.000
But when you do stuff in C.
00:28:02.000 --> 00:28:07.000
Have you ever, um… Leaked? Have you leaked memory?
00:28:07.000 --> 00:28:08.000
Oh, sure.
00:28:08.000 --> 00:28:10.000
Sure.
00:28:09.000 --> 00:28:10.000
Have you?
00:28:10.000 --> 00:28:14.000
tried to dereference a null pointer.
00:28:14.000 --> 00:28:22.000
Yeah, I've written a lot of C, but it's always fairly small things.
00:28:22.000 --> 00:28:30.000
not mission-critical stuff, so when I try to dereference a null pointer, unexpected behavior happens.
00:28:30.000 --> 00:28:38.000
Uh-huh. Have you written stuff? And now we're expanding into the world of Pearl.
00:28:31.000 --> 00:28:33.000
Right?
00:28:38.000 --> 00:28:40.000
Where.
00:28:40.000 --> 00:28:44.000
You didn't call it exactly right.
00:28:44.000 --> 00:28:52.000
Uh, and the way the, uh, API was described, the, the function signature.
00:28:52.000 --> 00:29:07.000
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?
00:29:05.000 --> 00:29:07.000
Sure.
00:29:07.000 --> 00:29:10.000
Yeah, sure. And, and, and Pearl does not help you there.
00:29:10.000 --> 00:29:24.000
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.
00:29:25.000 --> 00:29:26.000
Umm.
00:29:26.000 --> 00:29:33.000
So, what we are discussing is, if you drew a circle on a piece of paper.
00:29:33.000 --> 00:29:41.000
And inside the circle was how Rust works. And outside the circle was everything else.
00:29:41.000 --> 00:29:48.000
We're talking about everything else. Now we're going to talk about what's inside the circle.
00:29:44.000 --> 00:29:45.000
Okay.
00:29:48.000 --> 00:29:54.000
Um, and the most important thing about Rust.
00:29:54.000 --> 00:30:06.000
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.
00:30:06.000 --> 00:30:18.000
Rust is not another C++. It's not another, um… I don't know, scheme, or… it's not any of those things.
00:30:18.000 --> 00:30:27.000
It is its own brand new thing with its own brand new way of thinking.
00:30:27.000 --> 00:30:46.000
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.
00:30:46.000 --> 00:31:03.000
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.
00:31:04.000 --> 00:31:13.000
That's a thing you could have if you wanted it, Jim. I know you get it in JavaScript.
00:31:13.000 --> 00:31:20.000
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…
00:31:20.000 --> 00:31:56.000
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.
00:31:56.000 --> 00:31:58.000
Okay.
00:31:58.000 --> 00:32:03.000
Well… Rust is a big change.
00:32:03.000 --> 00:32:07.000
And… I'm not saying.
00:32:07.000 --> 00:32:10.000
You should go use Rust.
00:32:10.000 --> 00:32:13.000
I'm absolutely not saying.
00:32:13.000 --> 00:32:24.000
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.
00:32:24.000 --> 00:32:42.000
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.
00:32:42.000 --> 00:32:48.000
I think one way Rust can help you involves you not writing Rust at all.
00:32:48.000 --> 00:32:53.000
But learn Rust and then come home.
00:32:53.000 --> 00:32:57.000
Because Rust has new ways of thinking.
00:32:57.000 --> 00:33:07.000
When there are multiple political groups, and they never talk to each other, they have very, very different thoughts, and they hate each other.
00:33:08.000 --> 00:33:13.000
When you get a group together that mixes those.
00:33:13.000 --> 00:33:16.000
very divergent populations.
00:33:16.000 --> 00:33:27.000
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.
00:33:27.000 --> 00:33:31.000
Um… If you learn Rust.
00:33:31.000 --> 00:33:35.000
Even if you're not going to become a crustacean.
00:33:35.000 --> 00:33:44.000
Uh… You're going to have new knowledge that changes the way you think about and talk about.
00:33:45.000 --> 00:33:48.000
Problems you do solve.
00:33:48.000 --> 00:33:54.000
Um, so, I want you, or anyone, the listener.
00:33:54.000 --> 00:34:10.000
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.
00:34:10.000 --> 00:34:17.000
And you will learn some things, and those things will come back to you.
00:34:17.000 --> 00:34:20.000
in the language that is your daily driver.
00:34:20.000 --> 00:34:28.000
If you're writing JavaScript, this is going to help you write different, and I assert, better JavaScript.
00:34:28.000 --> 00:34:41.000
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.
00:34:41.000 --> 00:34:51.000
We did an episode a while ago called, um… Choosing the Right Language, that was episode number 28.
00:34:51.000 --> 00:35:04.000
Um… Rust is the, uh… the whole point is the model change costs more than a syntax change. Budget accordingly idea.
00:35:04.000 --> 00:35:08.000
What I'm suggesting now is that… Flipped.
00:35:08.000 --> 00:35:12.000
Understand the model change.
00:35:12.000 --> 00:35:19.000
But don't put yourself in a place where that's a requirement for you to move forward in writing your code.
00:35:19.000 --> 00:35:23.000
Figure out what it means. Why did they do it?
00:35:23.000 --> 00:35:32.000
That's like learning a new language. When you can speak French, suddenly you can talk about foods you never talked about before.
00:35:32.000 --> 00:35:38.000
Important to me. On the food front, maybe less important to you, Jim, but something.
00:35:38.000 --> 00:35:40.000
Yep.
00:35:40.000 --> 00:35:50.000
Have you, in your world, encountered a machine, a program, a tool, a language, anything?
00:35:50.000 --> 00:36:02.000
that… I don't care whether that… thing, whatever it was, ended up being the thing for you. But you learning about it.
00:36:02.000 --> 00:36:03.000
Changed.
00:36:04.000 --> 00:36:08.000
How you went on from there with other things.
00:36:09.000 --> 00:36:13.000
For instance, when you went from COBOL…
00:36:09.000 --> 00:36:11.000
No.
00:36:11.000 --> 00:36:12.000
Yeah.
00:36:13.000 --> 00:36:17.000
to COBOL plus a database.
00:36:17.000 --> 00:36:22.000
When I look back at your life, I feel like that was a change for you.
00:36:21.000 --> 00:36:23.000
It's a huge change, yeah.
00:36:23.000 --> 00:36:24.000
Yeah.
00:36:24.000 --> 00:36:36.000
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.
00:36:36.000 --> 00:36:52.000
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.
00:36:53.000 --> 00:36:55.000
Big.
00:36:55.000 --> 00:37:10.000
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.
00:37:10.000 --> 00:37:12.000
I don't see in other languages.
00:37:12.000 --> 00:37:13.000
So, yeah.
00:37:12.000 --> 00:37:22.000
Outside the scope of Rust, for just a second, I think the words you just said are critical.
00:37:22.000 --> 00:37:30.000
The mark in my mind of intelligence in general is.
00:37:30.000 --> 00:37:33.000
The ability to add new facts.
00:37:33.000 --> 00:37:39.000
to your internal model, learning. When you learn new things and change.
00:37:40.000 --> 00:37:53.000
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.
00:37:54.000 --> 00:37:56.000
But I'm going to go a little bit further.
00:37:56.000 --> 00:38:02.000
I think when you accept new facts into your world.
00:38:02.000 --> 00:38:07.000
And they disagree with your existing opinions.
00:38:07.000 --> 00:38:20.000
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?
00:38:21.000 --> 00:38:30.000
I think that puts you at the front of the line. Um, and when you let learning about databases change you.
00:38:30.000 --> 00:38:35.000
from a COBOL person into a person who can use databases?
00:38:35.000 --> 00:38:42.000
I think that means you're, you are what we all aspire to be.
00:38:42.000 --> 00:38:55.000
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!
00:38:55.000 --> 00:38:56.000
Mmhm.
00:38:55.000 --> 00:39:02.000
Um… So, uh, first of all, good on you, and second of all.
00:39:02.000 --> 00:39:06.000
Here's some more sharp metal to put at the tip of your arrow.
00:39:07.000 --> 00:39:08.000
Now.
00:39:08.000 --> 00:39:13.000
The thing that everybody talks about, or knows about.
00:39:13.000 --> 00:39:18.000
Um, when they hear rust is, oh, rust.
00:39:18.000 --> 00:39:21.000
It's got that ownership model.
00:39:22.000 --> 00:39:23.000
That's the thing.
00:39:23.000 --> 00:39:27.000
And so let's talk about that first.
00:39:27.000 --> 00:39:34.000
Um… It's the actual reason Rust exists.
00:39:34.000 --> 00:39:45.000
And I'm gonna tell you the three different worlds that there are. Um, in C and C++.
00:39:45.000 --> 00:39:51.000
you manage memory by hand. Like in C, you use malloc and free, right?
00:39:51.000 --> 00:39:52.000
Huh-huh.
00:39:52.000 --> 00:40:01.000
Uh, and boy, is that easy to screw up. Um, in C++, ooh-hoo-hoo, they gave them better names! New and Delete.
00:40:01.000 --> 00:40:22.000
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.
00:40:22.000 --> 00:40:25.000
I'm sure you've heard it before.
00:40:25.000 --> 00:40:34.000
CVEs come from this category of error more frequently than almost any other.
00:40:25.000 --> 00:40:26.000
Yes.
00:40:34.000 --> 00:40:50.000
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.
00:40:50.000 --> 00:41:16.000
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.
00:41:16.000 --> 00:41:31.000
And reference counting is a thing that Objective-C and Swift can do. RC is reference counting. ARC is automatic reference counting.
00:41:31.000 --> 00:41:33.000
Which is slightly better.
00:41:34.000 --> 00:41:39.000
a thing called COM, the Common Object Model in Microsoft.
00:41:39.000 --> 00:41:54.000
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.
00:41:54.000 --> 00:42:00.000
And when you were done with it, you had to explicitly deck wrap it. How awful was that?
00:42:00.000 --> 00:42:11.000
Um… Anyway… Then there is a new category. It's the rust category.
00:42:11.000 --> 00:42:16.000
And the Rust category is that the compiler.
00:42:16.000 --> 00:42:19.000
at compile time.
00:42:19.000 --> 00:42:22.000
Before it's ever run.
00:42:22.000 --> 00:42:28.000
Looks at for every single resource.
00:42:28.000 --> 00:42:30.000
Owns it.
00:42:30.000 --> 00:42:36.000
How long does it need to be valid and alive?
00:42:36.000 --> 00:42:37.000
Umm.
00:42:38.000 --> 00:42:43.000
How many people are going to use it at the same time?
00:42:43.000 --> 00:42:48.000
And is that reasonable? And when it's done.
00:42:48.000 --> 00:42:50.000
It should go away.
00:42:50.000 --> 00:42:59.000
Uh, it's all automatic, and there's stuff a normal other… in one of the other categories wouldn't detect.
00:42:59.000 --> 00:43:08.000
For instance, the idea of two different hunks of code writing to the same variable at the same time.
00:43:09.000 --> 00:43:13.000
Is there ever a time that's not a bug?
00:43:14.000 --> 00:43:20.000
I mean, if you wrote something where you meant for that to happen.
00:43:20.000 --> 00:43:31.000
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.
00:43:31.000 --> 00:43:37.000
Whether it results in undefined program behavior or not, it's not the right thing to do.
00:43:37.000 --> 00:43:45.000
So, Rust says, for any object, there is exactly one writer.
00:43:45.000 --> 00:43:56.000
Or… There are no writers and some non-zero number of readers.
00:43:56.000 --> 00:44:06.000
This has so many powerful benefits. One is that coherency is always maintained.
00:44:06.000 --> 00:44:17.000
Two is that there's a lot more stuff that you can deduce about code that you're looking at.
00:44:17.000 --> 00:44:35.000
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.
00:44:35.000 --> 00:44:40.000
And when you send a piece of data across the channel.
00:44:40.000 --> 00:44:49.000
you're not getting a reference, typically. What you're getting is a new copy of the data on the other side.
00:44:49.000 --> 00:45:02.000
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.
00:45:03.000 --> 00:45:15.000
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.
00:45:15.000 --> 00:45:20.000
How it happens, as long as they obey those rules.
00:45:20.000 --> 00:45:23.000
Um, so this ownership thing.
00:45:23.000 --> 00:45:28.000
involves how many people can write to it, how long it lives.
00:45:28.000 --> 00:45:36.000
what happens when it goes away? Uh, and by the way, there aren't constructors or destructors in Rust.
00:45:36.000 --> 00:45:47.000
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.
00:45:47.000 --> 00:45:52.000
Which is fascinating to me. So.
00:45:53.000 --> 00:46:00.000
The rules are every value has exactly one owner at a time. One.
00:46:00.000 --> 00:46:15.000
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.
00:46:16.000 --> 00:46:22.000
And if you have the drop trait, then you get the destructor version of drop.
00:46:23.000 --> 00:46:24.000
So.
00:46:24.000 --> 00:46:44.000
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.
00:46:44.000 --> 00:46:54.000
programmer, because it's relentless in its error messages. And when you first face them, the error messages are impenetrable.
00:46:54.000 --> 00:46:56.000
But I promise you.
00:46:56.000 --> 00:47:03.000
If you spend some time, not only do the error messages gradually become clear.
00:47:03.000 --> 00:47:08.000
They are among the very best error messages you could reasonably get.
00:47:08.000 --> 00:47:11.000
Because Rust error messages.
00:47:11.000 --> 00:47:19.000
usually point much, much closer to where the real problem is than I've seen in any other language.
00:47:19.000 --> 00:47:27.000
They tell you better what's wrong, and once you understand all the parts, you'll understand it better.
00:47:27.000 --> 00:47:32.000
And they almost always tell you exactly how to fix it.
00:47:32.000 --> 00:47:35.000
And they tell you the right thing.
00:47:35.000 --> 00:47:38.000
So… I think that's.
00:47:36.000 --> 00:47:47.000
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?
00:47:40.000 --> 00:47:42.000
Sure.
00:47:48.000 --> 00:47:49.000
Yes.
00:47:48.000 --> 00:47:53.000
Like, like if I own something, I can hand it off to a sub routine.
00:47:53.000 --> 00:47:54.000
That now owns it?
00:47:54.000 --> 00:47:56.000
That's correct.
00:47:54.000 --> 00:47:57.000
Is that right? Okay.
00:47:56.000 --> 00:47:58.000
But guess what?
00:47:58.000 --> 00:48:03.000
If you… Gave it to a subroutine?
00:48:03.000 --> 00:48:10.000
You aren't an owner during the execution of that subroutine, and also.
00:48:06.000 --> 00:48:08.000
Anymore, right.
00:48:09.000 --> 00:48:10.000
Okay.
00:48:10.000 --> 00:48:16.000
You don't automatically get it back when the subroutine returns?
00:48:15.000 --> 00:48:17.000
Okay.
00:48:16.000 --> 00:48:21.000
Unless the subroutine returns it, and you take it back.
00:48:23.000 --> 00:48:25.000
Okay.
00:48:27.000 --> 00:48:29.000
Thanks.
00:48:31.000 --> 00:48:36.000
Super? Like, I know that sounds… Clear as mud.
00:48:36.000 --> 00:48:40.000
Um… But once you start using it, you're like.
00:48:40.000 --> 00:48:42.000
Oh, that's great.
00:48:42.000 --> 00:48:46.000
I think I need to try that… I need to try that Rustlings thing.
00:48:42.000 --> 00:48:44.000
I really like that.
00:48:46.000 --> 00:48:51.000
So, there are escape hatches.
00:48:51.000 --> 00:48:53.000
up.
00:48:53.000 --> 00:49:10.000
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.
00:49:10.000 --> 00:49:18.000
Um… So… That that lets you have what you want.
00:49:18.000 --> 00:49:20.000
But by default.
00:49:20.000 --> 00:49:24.000
gives you laws that are gonna stop you.
00:49:24.000 --> 00:49:30.000
from shooting yourself in the foot as soon as you learn to cooperate with the error messages.
00:49:30.000 --> 00:49:37.000
Um, so GC pauses are, like, a huge thing in GC-collected languages.
00:49:34.000 --> 00:49:38.000
GC garbage collector pauses.
00:49:38.000 --> 00:49:43.000
GC means garbage collector, yes. So if you're in a garbage-collected language.
00:49:39.000 --> 00:49:41.000
Yeah.
00:49:43.000 --> 00:49:50.000
like, um, Perl and Java and JavaScript and TypeScript.
00:49:50.000 --> 00:49:54.000
These GC pauses can be a big deal. Has that ever hit you?
00:49:55.000 --> 00:49:58.000
No. I've never had a problem with it.
00:49:58.000 --> 00:50:02.000
I wonder if that's because you're not writing long running stuff.
00:49:58.000 --> 00:50:02.000
You know, Pearl does reference counting.
00:50:02.000 --> 00:50:15.000
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.
00:50:15.000 --> 00:50:18.000
and doing things blocking you.
00:50:18.000 --> 00:50:21.000
You know, when something goes outta scope, it goes away. That's all.
00:50:22.000 --> 00:50:24.000
It's never a problem for me.
00:50:22.000 --> 00:50:39.000
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…
00:50:37.000 --> 00:50:38.000
Sure.
00:50:38.000 --> 00:50:40.000
Sure.
00:50:39.000 --> 00:50:43.000
Um… Anyway, uh…
00:50:41.000 --> 00:50:44.000
Yeah, it's never hit me before, though.
00:50:44.000 --> 00:50:48.000
When I first started using Rust.
00:50:48.000 --> 00:50:54.000
Um, I was super excited to learn all the cool new things it was gonna give me.
00:50:54.000 --> 00:51:12.000
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.
00:51:04.000 --> 00:51:05.000
Yeah.
00:51:12.000 --> 00:51:17.000
But, um, I started crying, uh, whining. I started whining.
00:51:17.000 --> 00:51:26.000
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.
00:51:26.000 --> 00:51:28.000
Um, for instance.
00:51:28.000 --> 00:51:34.000
Every language I've ever used has the equivalent.
00:51:34.000 --> 00:51:35.000
of null.
00:51:36.000 --> 00:51:49.000
C has null, C++ has null, other languages have nil, Python has none, uh, SQL has null, uh, numeric stuff, like.
00:51:43.000 --> 00:51:45.000
SQL has it.
00:51:45.000 --> 00:51:46.000
Yep.
00:51:49.000 --> 00:51:59.000
Pandas and whatnot have NAN, not a number, um… Uh, when do you use in Perl? Is it zero? When is it?
00:51:58.000 --> 00:52:00.000
I'm deaf.
00:52:00.000 --> 00:52:02.000
I'm deaf.
00:52:02.000 --> 00:52:08.000
Um… Russ doesn't have that. There isn't one.
00:52:09.000 --> 00:52:13.000
Like, but what if you want a pointer that doesn't point to anything?
00:52:13.000 --> 00:52:15.000
Guess what?
00:52:15.000 --> 00:52:16.000
Nope.
00:52:15.000 --> 00:52:17.000
You don't.
00:52:17.000 --> 00:52:32.000
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.
00:52:32.000 --> 00:52:45.000
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.
00:52:45.000 --> 00:52:53.000
Which is that all Go functions, but not as a definition of the language, as a convention.
00:52:53.000 --> 00:53:06.000
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.
00:53:06.000 --> 00:53:09.000
It's the fact that you're a Go user that makes you do it.
00:53:09.000 --> 00:53:14.000
Um, I didn't like it, and it made me shy away from Go.
00:53:14.000 --> 00:53:19.000
It doesn't make go bad, but it was a thing I wanted and I didn't have.
00:53:19.000 --> 00:53:29.000
Um… Another thing that I really enjoy is inheritance. Inheritance is great, especially when used.
00:53:29.000 --> 00:53:43.000
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.
00:53:39.000 --> 00:53:41.000
Mmhm.
00:53:43.000 --> 00:53:51.000
And another way inheritance is good is about inheriting and sharing code.
00:53:52.000 --> 00:53:58.000
It turns out that, uh, for a long, long time, anybody who does this for a job.
00:53:58.000 --> 00:54:08.000
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.
00:54:08.000 --> 00:54:11.000
Guess what Rust doesn't have?
00:54:11.000 --> 00:54:14.000
inheritance.
00:54:11.000 --> 00:54:24.000
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.
00:54:24.000 --> 00:54:33.000
In C++, class and struct are basically identical, except for the default assignment of visibility to the underlying pieces of.
00:54:33.000 --> 00:54:38.000
Uh, uh, the underlying members. Uh, in Rust, there's, there's only struct.
00:54:38.000 --> 00:54:40.000
And there's no inheritance.
00:54:40.000 --> 00:54:56.000
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…
00:54:55.000 --> 00:54:56.000
Mmhm.
00:54:56.000 --> 00:54:59.000
and a bowling ball, they both fall at the same time.
00:54:59.000 --> 00:55:03.000
Sure, that's true, and the thing I just told you is true.
00:55:03.000 --> 00:55:12.000
But it is a lie, because if you're dropping a feather, and a bowling ball, and the moon.
00:55:13.000 --> 00:55:18.000
Those three things close the gap at different rates.
00:55:18.000 --> 00:55:34.000
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.
00:55:34.000 --> 00:55:43.000
caused by a feather is not measurable, and so it does fall at the same rate as a bowling ball.
00:55:43.000 --> 00:55:48.000
Of course your physics teacher is not going to tell you that, and in fact, you're going to be asked.
00:55:48.000 --> 00:55:55.000
to see the principal when you bring it up. But, um, it happens that…
00:55:52.000 --> 00:55:56.000
You speak from experience.
00:55:55.000 --> 00:55:56.000
Yes.
00:55:56.000 --> 00:56:02.000
It happens that in Rust, there is inheritance.
00:56:02.000 --> 00:56:16.000
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.
00:56:16.000 --> 00:56:23.000
It happens in traits and protocols and whatnot or it's not called whatever anyway.
00:56:23.000 --> 00:56:25.000
So.
00:56:25.000 --> 00:56:30.000
What do I get instead of those things? I can't return null.
00:56:30.000 --> 00:56:37.000
Uh, instead, Rust has this tremendous thing called enums, enumerations.
00:56:37.000 --> 00:56:38.000
Mmhm.
00:56:37.000 --> 00:56:51.000
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.
00:56:51.000 --> 00:56:52.000
So.
00:56:52.000 --> 00:56:58.000
Either you get a T or you don't get a T as a result, for instance.
00:56:59.000 --> 00:57:07.000
So, we would return T, or we would return none, or null, or whatever it is for your language.
00:57:07.000 --> 00:57:10.000
In Rust, you make a type.
00:57:10.000 --> 00:57:18.000
That type happens to underline BNENUM, and it only has two possibilities.
00:57:18.000 --> 00:57:24.000
The values… the possibilities for that T are the value SUM.
00:57:24.000 --> 00:57:28.000
or the value none.
00:57:28.000 --> 00:57:31.000
The value sum is a T.
00:57:32.000 --> 00:57:41.000
And the value none isn't anything. So yes, you can't return none, except, kind of, you can.
00:57:41.000 --> 00:57:46.000
So, option T, there isn't a global none?
00:57:46.000 --> 00:57:52.000
But there is something, and when you actually start using it and thinking about it.
00:57:52.000 --> 00:57:57.000
It turns out to be better. So I kind of take that.
00:57:57.000 --> 00:58:00.000
There's no exceptions.
00:58:00.000 --> 00:58:07.000
But instead of an exception, um, if it might be that you could.
00:58:07.000 --> 00:58:10.000
Uh, not do the right thing.
00:58:11.000 --> 00:58:27.000
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.
00:58:27.000 --> 00:58:38.000
Um… Your answer might be either you found the supplier or.
00:58:38.000 --> 00:58:44.000
you couldn't get a connection. And not being able to get a connection is an error.
00:58:44.000 --> 00:58:53.000
Well, instead of raising an exception, you make your result type be RESULT.
00:58:53.000 --> 00:59:01.000
and that's a parameterizable type, where it takes the T, the supplier type.
00:59:01.000 --> 00:59:03.000
And an error type.
00:59:03.000 --> 00:59:15.000
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.
00:59:15.000 --> 00:59:19.000
It's another case of an enum.
00:59:19.000 --> 00:59:30.000
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?
00:59:30.000 --> 00:59:36.000
You actually have to look. It's not unlike Go's model.
00:59:36.000 --> 00:59:43.000
Except that… You're forced to look, and it's designed into the language.
00:59:43.000 --> 01:00:01.000
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.
01:00:01.000 --> 01:00:12.000
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.
01:00:12.000 --> 01:00:29.000
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?
01:00:30.000 --> 01:00:32.000
Uh, switch.
01:00:32.000 --> 01:00:36.000
Uh, and in… in Rust, we call it a match.
01:00:37.000 --> 01:00:43.000
uh, Swift does a really good thing, and Rust does that same thing.
01:00:43.000 --> 01:00:49.000
And that same thing is… Uh, this kind of statement, a match.
01:00:49.000 --> 01:00:51.000
Must be exhaustive.
01:00:51.000 --> 01:00:53.000
Yes.
01:00:51.000 --> 01:00:54.000
Um, so, for instance.
01:00:53.000 --> 01:00:55.000
I like that about Swift.
01:00:55.000 --> 01:01:03.000
If you say that an order has three possible states, uh, which is, uh, placed.
01:01:03.000 --> 01:01:08.000
Um… Prepared and shipped.
01:01:09.000 --> 01:01:18.000
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.
01:01:18.000 --> 01:01:19.000
And.
01:01:19.000 --> 01:01:24.000
That is probably not a particular case that you would handle with it.
01:01:24.000 --> 01:01:48.000
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.
01:01:42.000 --> 01:01:44.000
Polymorphism.
01:01:48.000 --> 01:01:51.000
The consequences are so different, but.
01:01:51.000 --> 01:02:01.000
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.
01:02:01.000 --> 01:02:09.000
Um, placed… Um… Uh, preparing and shipped, there's also canceled.
01:02:09.000 --> 01:02:15.000
Suddenly, all 3 or 4 of those places where you used that match before?
01:02:15.000 --> 01:02:17.000
They don't silently fail.
01:02:17.000 --> 01:02:21.000
They all fail to compile.
01:02:21.000 --> 01:02:22.000
Right.
01:02:21.000 --> 01:02:24.000
because you weren't exhaustive.
01:02:24.000 --> 01:02:25.000
Right.
01:02:24.000 --> 01:02:25.000
Umm.
01:02:25.000 --> 01:02:27.000
That's fantastic.
01:02:27.000 --> 01:02:28.000
So.
01:02:29.000 --> 01:02:41.000
This leads me to a thing I have said over and over about so many languages, and that is… The type system?
01:02:41.000 --> 01:02:46.000
in Rust is powerful enough to let you.
01:02:46.000 --> 01:02:49.000
Design and build the planet.
01:02:49.000 --> 01:02:51.000
Promises.
01:02:51.000 --> 01:02:56.000
you intend for your code to make.
01:02:56.000 --> 01:03:03.000
Um… And there's sort of a… uh, escape hatch that I want to talk about, too.
01:03:03.000 --> 01:03:08.000
But the combination of traits and generics.
01:03:08.000 --> 01:03:12.000
Let the entire function signature become.
01:03:12.000 --> 01:03:15.000
become a complete contract.
01:03:15.000 --> 01:03:29.000
in a way that is not obvious from any other language. If your function takes an option, and that's parameterizable, type, and generic.
01:03:29.000 --> 01:03:36.000
On, um, order… Then that means you could have taken an order.
01:03:36.000 --> 01:03:42.000
or not. And that's the contract, and it's obvious from the signature.
01:03:42.000 --> 01:03:52.000
If your function returns a result, um, status, comma, and then some subcategory of errors.
01:03:52.000 --> 01:04:01.000
Um, that's a contract. It says it might not succeed, and here's the kind of failure it could have.
01:04:01.000 --> 01:04:11.000
Um… This is genuinely one of the strongest type systems in mainstream use.
01:04:11.000 --> 01:04:28.000
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.
01:04:28.000 --> 01:04:32.000
All those things together are part of the type system.
01:04:32.000 --> 01:04:42.000
Make this… Um, a genuinely powerful type system, maybe the most powerful I've seen.
01:04:43.000 --> 01:04:47.000
And that thing about being picky?
01:04:47.000 --> 01:04:56.000
That's where this comes in. It's picky. It wants you to understand and satisfy those constraints.
01:04:56.000 --> 01:05:01.000
And the really complicated error messages you won't understand at first?
01:05:02.000 --> 01:05:04.000
Tell you how.
01:05:04.000 --> 01:05:11.000
And finally, um, there's a special escape hatch for so much of this.
01:05:11.000 --> 01:05:13.000
Umm.
01:05:13.000 --> 01:05:23.000
I had mentioned before some of Rust's rules, like the number and kind of owners, a specific.
01:05:23.000 --> 01:05:33.000
variable can have and some of them here are about what kinds of types things can be.
01:05:33.000 --> 01:05:37.000
Well, there's an escape hatch. It's very badly named.
01:05:37.000 --> 01:05:42.000
Um, the escape hatch is named… unsafe.
01:05:43.000 --> 01:05:52.000
And… it's a block. You say, unsafe, open curly brace. You say some things, closed curly brace.
01:05:53.000 --> 01:05:55.000
Here's why it's badly named.
01:05:56.000 --> 01:06:03.000
There are actually seven traits, seven important promises.
01:06:03.000 --> 01:06:11.000
that, um, Rust requires to be enforced, and are enforced by the compiler and the Varro checker.
01:06:11.000 --> 01:06:19.000
Unsafe the word makes it sound like inside this block you don't have to do those things?
01:06:19.000 --> 01:06:22.000
That is not what it means.
01:06:22.000 --> 01:06:24.000
Unsafe means.
01:06:25.000 --> 01:06:27.000
I promise.
01:06:27.000 --> 01:06:33.000
that even though I'm about to say things in a way.
01:06:33.000 --> 01:06:37.000
The compiler wouldn't have the power to prove.
01:06:38.000 --> 01:06:41.000
Meet those seven criteria.
01:06:42.000 --> 01:06:44.000
They will.
01:06:44.000 --> 01:06:47.000
And by the time you get out of it.
01:06:47.000 --> 01:06:52.000
They still will and you can check again.
01:06:52.000 --> 01:06:54.000
That's what that says.
01:06:54.000 --> 01:07:04.000
So you use unsafe, for instance, if the thing you're about to do is you've got a giant array.
01:07:04.000 --> 01:07:09.000
And you need to move items out of the way to push something in the middle.
01:07:09.000 --> 01:07:19.000
That's an incredibly difficult thing to do if you also have to satisfy all of these promises.
01:07:19.000 --> 01:07:29.000
and let Rust make its, um, out-of-band runtime checks, proving it's all okay.
01:07:29.000 --> 01:07:35.000
What you want to do is say, I'm just going to do it. It has to be done.
01:07:35.000 --> 01:07:38.000
I promise this is going to be okay.
01:07:38.000 --> 01:07:41.000
That's what the unsafe block says.
01:07:39.000 --> 01:07:44.000
But that's… that's shifting the burden on this developer.
01:07:44.000 --> 01:07:49.000
Uh, and the compiler isn't gonna check that code for you?
01:07:49.000 --> 01:07:51.000
That's what Unsafe says.
01:07:49.000 --> 01:07:54.000
Like, you can do unsafe things. Yeah, you can really… you can do bad things, right?
01:07:55.000 --> 01:07:59.000
But the promise is… that you won't.
01:07:59.000 --> 01:08:06.000
Let me rephrase that. You can do things that could be made to be unsafe.
01:07:59.000 --> 01:08:07.000
Yeah, but the compiler isn't gonna… isn't gonna… Sure.
01:08:06.000 --> 01:08:16.000
You can do things Rust would never let you do. You have the power to twiddle bits in ways Rust just won't allow.
01:08:10.000 --> 01:08:11.000
Right.
01:08:16.000 --> 01:08:22.000
But your promise is that by the end it's all okay.
01:08:24.000 --> 01:08:26.000
Even though it might not be.
01:08:27.000 --> 01:08:32.000
Yes, it could be that your promise was a lie.
01:08:29.000 --> 01:08:30.000
Yeah, okay.
01:08:32.000 --> 01:08:35.000
Uh, okay. It's on you.
01:08:35.000 --> 01:08:38.000
It is on you. That's what unsafe means.
01:08:36.000 --> 01:08:38.000
Yeah, okay.
01:08:38.000 --> 01:08:39.000
Yeah, okay.
01:08:40.000 --> 01:08:44.000
Having an unsafe block.
01:08:44.000 --> 01:08:46.000
Inside a function?
01:08:46.000 --> 01:09:02.000
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.
01:09:02.000 --> 01:09:07.000
An unsafe function doesn't make a module or package unsafe.
01:09:05.000 --> 01:09:08.000
It doesn't taint the module or the block.
01:09:08.000 --> 01:09:17.000
Exactly. But it is something that you can look for, and it absolutely is something you should test for.
01:09:17.000 --> 01:09:23.000
Now… I didn't really have a space to talk about this.
01:09:24.000 --> 01:09:34.000
But our friend Marlon mentions a really important third-party library package.
01:09:34.000 --> 01:09:46.000
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.
01:09:46.000 --> 01:10:00.000
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.
01:10:00.000 --> 01:10:18.000
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.
01:10:18.000 --> 01:10:24.000
And also, Honor Marlin, he's pointing out something very important. This is… this is super good knowledge.
01:10:25.000 --> 01:10:40.000
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?
01:10:41.000 --> 01:10:49.000
But first, some of you are gonna say, eh, so what, and you're wrong. And that is, Rust has macros.
01:10:50.000 --> 01:10:53.000
I hear you, C programmers.
01:10:53.000 --> 01:10:55.000
So what?
01:10:55.000 --> 01:10:58.000
No, no, no, no. Not that kind of macro.
01:10:56.000 --> 01:10:58.000
We've had those for years.
01:10:58.000 --> 01:11:10.000
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.
01:11:10.000 --> 01:11:24.000
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.
01:11:24.000 --> 01:11:33.000
This is the kind of macro that gets the already parsed token stream.
01:11:33.000 --> 01:11:49.000
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.
01:11:49.000 --> 01:11:50.000
Umm.
01:11:50.000 --> 01:11:56.000
And it does things the compiler can do.
01:11:56.000 --> 01:11:59.000
It goes from tokens.
01:11:59.000 --> 01:12:01.000
and produces.
01:12:01.000 --> 01:12:08.000
something to go next in the world. It might be that thing is more token stream.
01:12:08.000 --> 01:12:14.000
But, um, there are a lot of things in… in Lisp, for instance.
01:12:14.000 --> 01:12:25.000
Huge hunks of the Lisp language are actually implemented with macros. There isn't a while loop in Lisp.
01:12:25.000 --> 01:12:38.000
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.
01:12:38.000 --> 01:12:39.000
Umm.
01:12:39.000 --> 01:12:44.000
That you can't do that with a C macro, but you can do it in Lisp.
01:12:44.000 --> 01:12:47.000
And you can do it in Rust.
01:12:47.000 --> 01:12:53.000
Now, as it happens, Rust has all the ifs and whiles that you can care about.
01:12:53.000 --> 01:12:57.000
But there's tons of things that these macros implement.
01:12:57.000 --> 01:13:01.000
that are in the right place.
01:13:01.000 --> 01:13:07.000
Jim and I have a little disagreement about this. Um, I'm gonna say my words first.
01:13:07.000 --> 01:13:11.000
But here's some examples.
01:13:11.000 --> 01:13:26.000
Rust has some array initialization functionality affordances that let you instead of saying construct my array from.
01:13:26.000 --> 01:13:35.000
a, uh, generator, the equivalent, uh, or from another array, or from an existing, um.
01:13:39.000 --> 01:13:40.000
Umm.
01:13:40.000 --> 01:13:42.000
Uh, literal.
01:13:41.000 --> 01:13:42.000
a list.
01:13:42.000 --> 01:13:44.000
Okay.
01:13:42.000 --> 01:13:52.000
literal, constructed from a actual list. So, my array A, B, C, D, E.
01:13:52.000 --> 01:13:58.000
That's a thing that would be hard to do, maybe not impossible.
01:13:58.000 --> 01:14:01.000
with a C macro.
01:14:01.000 --> 01:14:03.000
Umm.
01:14:03.000 --> 01:14:08.000
And it makes a thing that lets you just say an array.
01:14:08.000 --> 01:14:22.000
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.
01:14:23.000 --> 01:14:35.000
My assertion is, and here's where Jim and I disagree, that some of those things that you, that you, uh, declare, define with.
01:14:35.000 --> 01:14:43.000
Rust macros, for instance, println and several others, this, uh, array construction thing.
01:14:43.000 --> 01:14:45.000
are.
01:14:45.000 --> 01:14:46.000
Rust.
01:14:46.000 --> 01:14:49.000
They are parts of the Rust language.
01:14:49.000 --> 01:14:54.000
And I don't want to misrepresent you, Jim. Why don't you give your side?
01:14:59.000 --> 01:15:02.000
I don't know.
01:15:02.000 --> 01:15:10.000
I think you're talking about initializing an array with a list of values.
01:15:10.000 --> 01:15:15.000
That just seems like a language thing to me, and you're saying you do that with a macro?
01:15:15.000 --> 01:15:22.000
I… I probably totally misunderstand.
01:15:20.000 --> 01:15:23.000
I'm saying… I'm saying.
01:15:23.000 --> 01:15:37.000
It was… designed into your system, and the implementation of it was a macro. It's not in the actual Rust grammar.
01:15:38.000 --> 01:15:44.000
But at the end, the thing you have, where you can.
01:15:44.000 --> 01:15:49.000
Make a new array in the way we just said.
01:15:48.000 --> 01:15:49.000
Mmhm.
01:15:49.000 --> 01:15:57.000
That that collection… is Rust. Okay, I got it by making a macro happen.
01:15:54.000 --> 01:15:56.000
Okay, yeah.
01:15:57.000 --> 01:16:09.000
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.
01:15:58.000 --> 01:15:59.000
Okay.
01:16:09.000 --> 01:16:18.000
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.
01:16:15.000 --> 01:16:16.000
Okay.
01:16:18.000 --> 01:16:22.000
I, uh… I'm still confused, but that's alright.
01:16:23.000 --> 01:16:27.000
I've been confused for 45 minutes now.
01:16:27.000 --> 01:16:34.000
A nice thing about macros, though, is in Rust, by convention.
01:16:34.000 --> 01:16:51.000
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…
01:16:46.000 --> 01:16:48.000
Mmhm.
01:16:51.000 --> 01:16:54.000
I think that pound sign goes at the end.
01:16:54.000 --> 01:16:55.000
Hum.
01:16:55.000 --> 01:17:00.000
So a really great thing. I'm on to a new topic.
01:17:00.000 --> 01:17:08.000
about Rust is that in a lot of languages, and Python has a quite annoying problem with this.
01:17:08.000 --> 01:17:13.000
Is that… Things fall into two worlds.
01:17:13.000 --> 01:17:16.000
Either a thing is an expression.
01:17:17.000 --> 01:17:19.000
Or, it's a statement.
01:17:19.000 --> 01:17:22.000
For instance, in Python.
01:17:23.000 --> 01:17:25.000
assignment.
01:17:25.000 --> 01:17:27.000
is a statement.
01:17:28.000 --> 01:17:39.000
So, in the old world, uh, or in some languages, like C, for instance, you can say A equals B equals C equals D.
01:17:38.000 --> 01:17:40.000
Mmhm.
01:17:39.000 --> 01:17:42.000
Because assignment is an expression.
01:17:42.000 --> 01:17:44.000
And that COMPLETE.
01:17:44.000 --> 01:17:47.000
sentence that I just said.
01:17:47.000 --> 01:17:55.000
ends with a semicolon, and that semicolon is a statement that happened to contain all those expressions.
01:17:55.000 --> 01:17:58.000
It goes from right to left.
01:17:58.000 --> 01:18:05.000
where C equals D is the expression that gets evaluated first.
01:18:04.000 --> 01:18:05.000
Okay.
01:18:05.000 --> 01:18:10.000
And the value of that expression is the value of D.
01:18:10.000 --> 01:18:11.000
Mmhm.
01:18:10.000 --> 01:18:14.000
And that value, which is now unnamed.
01:18:14.000 --> 01:18:22.000
is the right side of the expression B equals something, and now that expression is evaluated.
01:18:19.000 --> 01:18:20.000
That thing, right.
01:18:22.000 --> 01:18:28.000
In Python, when you would say… A equals B.
01:18:28.000 --> 01:18:30.000
That was an assignment.
01:18:30.000 --> 01:18:35.000
Or that was a yeah, that was that was a complete statement.
01:18:35.000 --> 01:18:40.000
And that statement was an assignment. So, if you said A equals B.
01:18:40.000 --> 01:18:41.000
You are done.
01:18:41.000 --> 01:18:43.000
Umm.
01:18:44.000 --> 01:18:46.000
And that was annoying.
01:18:46.000 --> 01:18:49.000
Uh, and a common beginner mistake.
01:18:49.000 --> 01:18:56.000
Is, people would say, if… Open parenthesis.
01:18:56.000 --> 01:19:00.000
A equals B, close parenthesis, is none.
01:19:00.000 --> 01:19:05.000
So there I've just written an assignment.
01:19:05.000 --> 01:19:07.000
And then a test for none.
01:19:05.000 --> 01:19:07.000
Uh-huh.
01:19:08.000 --> 01:19:12.000
But that can't happen in Python, or couldn't.
01:19:12.000 --> 01:19:14.000
Because assignment is a statement.
01:19:16.000 --> 01:19:19.000
Python fixed that.
01:19:19.000 --> 01:19:29.000
a while ago, I think in 3.10, using the walrus operator, colon equals. So if you want, uh, to say.
01:19:29.000 --> 01:19:38.000
the thing I just said in Python, now you put the A equals B in parentheses, but it's A colon equals B.
01:19:38.000 --> 01:19:43.000
And now it works! Well… In Rust.
01:19:43.000 --> 01:19:45.000
Almost all.
01:19:45.000 --> 01:19:47.000
Things that happen.
01:19:47.000 --> 01:19:57.000
are expressions. Even when to a programmer of C or Perl or Python, they look like statements.
01:19:57.000 --> 01:20:01.000
They return a value.
01:20:01.000 --> 01:20:05.000
And "if" doesn't just do its thing.
01:20:05.000 --> 01:20:08.000
It returns its value.
01:20:08.000 --> 01:20:18.000
And that means you can use it INSIDE something else. Is this always the right thing to do? Eh, no, no it's not.
01:20:18.000 --> 01:20:29.000
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.
01:20:29.000 --> 01:20:30.000
Umm.
01:20:32.000 --> 01:20:36.000
The thing I want to talk about next, and we're getting closer to the end.
01:20:36.000 --> 01:20:39.000
is performance.
01:20:39.000 --> 01:20:40.000
Ah.
01:20:40.000 --> 01:20:41.000
Rust.
01:20:41.000 --> 01:20:48.000
It's kind of awesome because it does all the great stuff we've talked about so far.
01:20:48.000 --> 01:20:52.000
In the same performance league.
01:20:52.000 --> 01:20:59.000
as C and C++. Now, I was a little cautious there, maybe you could hear the asterisk.
01:20:59.000 --> 01:21:08.000
It turns out that, um… Rust isn't always as fast as C or C++.
01:21:08.000 --> 01:21:17.000
Rust, by default, does runtime checks, like bounds checks, and… Other things.
01:21:17.000 --> 01:21:32.000
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.
01:21:33.000 --> 01:21:38.000
But if you write it in C, there's lots of stuff you can not do at all.
01:21:38.000 --> 01:21:44.000
that the Rust program is going to do, and the C program is going to beat you.
01:21:44.000 --> 01:21:45.000
Now.
01:21:45.000 --> 01:21:49.000
If you try really hard.
01:21:49.000 --> 01:21:59.000
You can catch up. And Rust gives you ASM blocks if you want to go that far. Please don't. But you could.
01:21:56.000 --> 01:21:58.000
Umm.
01:21:59.000 --> 01:22:04.000
Um, Rust lets you turn off certain kinds of checks, which you could.
01:22:04.000 --> 01:22:11.000
As always, I'm going to say… Measure. Measure the system.
01:22:11.000 --> 01:22:16.000
Are you looking at the place where it's gonna make a difference?
01:22:16.000 --> 01:22:21.000
If you are, okay, maybe this is the answer, I don't know.
01:22:21.000 --> 01:22:23.000
you better measure first.
01:22:23.000 --> 01:22:30.000
Um… Another interesting thing is that rust um.
01:22:30.000 --> 01:22:35.000
has WASM as a direct compile target. It's built in.
01:22:35.000 --> 01:22:41.000
You, instead of compiling to a particular platform, you can compile to WASM.
01:22:41.000 --> 01:22:44.000
We've talked about that.
01:22:42.000 --> 01:22:45.000
The WebAssembly stuff, yeah.
01:22:45.000 --> 01:22:52.000
Uh, I don't know if you have an episode number handy, Jim, but maybe you'll put it in the show notes.
01:22:45.000 --> 01:22:48.000
That's that's cool.
01:22:50.000 --> 01:22:52.000
of a year.
01:22:52.000 --> 01:22:55.000
Yeah, I'll, uh… I'll find it.
01:22:57.000 --> 01:23:01.000
Um… And one interesting.
01:23:01.000 --> 01:23:16.000
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.
01:23:16.000 --> 01:23:28.000
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.
01:23:28.000 --> 01:23:33.000
Here's a place where Rust might be able to hop in.
01:23:33.000 --> 01:23:34.000
Hmm.
01:23:34.000 --> 01:23:36.000
There is.
01:23:34.000 --> 01:23:36.000
Yah.
01:23:36.000 --> 01:23:37.000
A cost.
01:23:37.000 --> 01:23:45.000
Oh, by the way, the WebAssembly stuff we talked about a long time ago in episode number 3. That's why.
01:23:44.000 --> 01:23:50.000
Yeah, that's, that's a long, that's 30 episodes ago or, or so.
01:23:45.000 --> 01:23:48.000
Neither of us can remember the number.
01:23:48.000 --> 01:23:49.000
Yeah.
01:23:51.000 --> 01:24:02.000
Um, but just like, uh, originally was a big deal with C, and then with Python, and several other things, interoperability.
01:24:02.000 --> 01:24:06.000
uh, is a huge factor in Rust.
01:24:06.000 --> 01:24:13.000
Um… So, it has the foreign function interface to call C functions.
01:24:13.000 --> 01:24:28.000
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.
01:24:28.000 --> 01:24:37.000
You are holding a Python module in your hand, or what in all ways looks like a Python module.
01:24:37.000 --> 01:24:41.000
But everything past the import is Rust.
01:24:41.000 --> 01:24:44.000
To you, it's Python.
01:24:44.000 --> 01:24:46.000
To the machine, it's rust.
01:24:46.000 --> 01:24:50.000
There's another one called Maturin.
01:24:50.000 --> 01:24:54.000
Mattern is a build tool and can help.
01:24:54.000 --> 01:25:04.000
Um… UV and Ruff are Python tools. They're both written in Rust.
01:25:04.000 --> 01:25:08.000
Atuin, I talked about, written in Rust.
01:25:08.000 --> 01:25:12.000
A lot of stuff there.
01:25:14.000 --> 01:25:31.000
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.
01:25:31.000 --> 01:25:33.000
Rust didn't have that problem?
01:25:33.000 --> 01:25:39.000
Now, in the place where Discord had that problem, it doesn't.
01:25:39.000 --> 01:25:48.000
The Linux kernel now accepting Rust contributions. I heard words from Linux himself.
01:25:48.000 --> 01:25:56.000
That, um… The Linux kernel is moving towards Rust.
01:25:56.000 --> 01:26:03.000
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.
01:26:03.000 --> 01:26:06.000
But it sounds very promising.
01:26:06.000 --> 01:26:14.000
AWS, Firecracker, um, that's the micro-VM technology underneath Lambdas, that's now Rust.
01:26:14.000 --> 01:26:29.000
Um… There's tons of stuff. Cloudflare has Pingora. That's their Rust-built proxy. A huge amount of their NGINX footprint.
01:26:29.000 --> 01:26:36.000
at the edge are also the runtime is behind Cloudflare workers.
01:26:36.000 --> 01:26:44.000
Um, a smaller but notable, uh, Figma's multiplayer sync engine.
01:26:44.000 --> 01:26:50.000
Meta's Mononoke source control backend? 1Password's core?
01:26:50.000 --> 01:27:00.000
Um… I use a ton of CLI tools that are written in Rust. Like, I use ripgrep.
01:27:00.000 --> 01:27:10.000
Um, I use FD instead of FIND. I use EZA instead of LS. I use BAT instead of CAT.
01:27:10.000 --> 01:27:14.000
I use delta to see my git diffs.
01:27:14.000 --> 01:27:19.000
Um, I don't use Z oxide, but that's a good way to do CD.
01:27:19.000 --> 01:27:26.000
Um, I use Starship, as everyone should. That's a cross-shell prompt.
01:27:26.000 --> 01:27:34.000
I use Atoine. That's the better way to get through your shell history. There's a tool called Just.
01:27:34.000 --> 01:27:40.000
That is a replacement for Make, but a lot easier. I don't use it, but it's around.
01:27:40.000 --> 01:27:55.000
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.
01:27:55.000 --> 01:28:01.000
I'm still on TMUX, and there's Alacrity, and I don't know how to say this, but I think it's.
01:28:01.000 --> 01:28:06.000
Wheeze term? I know you've used alacrity.
01:28:04.000 --> 01:28:06.000
Or western?
01:28:06.000 --> 01:28:08.000
I have.
01:28:06.000 --> 01:28:09.000
Have you used Western too?
01:28:08.000 --> 01:28:12.000
I have not… I don't even believe I've heard of it.
01:28:12.000 --> 01:28:15.000
Huh. Um…
01:28:13.000 --> 01:28:15.000
I'll have to try it out.
01:28:15.000 --> 01:28:30.000
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.
01:28:30.000 --> 01:28:43.000
Spina, if that's your problem, um… Deno, uh, Turbo Pack, SWC, uh, TIKV, um.
01:28:44.000 --> 01:28:46.000
hugerent.
01:28:46.000 --> 01:28:48.000
Man, there's a lot of stuff.
01:28:46.000 --> 01:28:47.000
Wasmer.
01:28:47.000 --> 01:28:49.000
Tori.
01:28:50.000 --> 01:28:51.000
Tons of stuff.
01:28:52.000 --> 01:29:01.000
Um, and I've left out things. I left out all the blockchain crap, because… We have feelings about blockchains.
01:29:00.000 --> 01:29:01.000
Yep.
01:29:01.000 --> 01:29:06.000
So everything I've said so far is.
01:29:06.000 --> 01:29:08.000
You know, the happy path.
01:29:09.000 --> 01:29:20.000
Uh, but I can't… leave out. I must be completely transparent. I can't leave out the downsides. Um, Rust is complicated.
01:29:20.000 --> 01:29:32.000
Um, the ownership model, the trade system, generics, um… If you intend to actually know and use Rust yourself.
01:29:32.000 --> 01:29:38.000
And not just hand it over to some AI, and you already know how I feel about that.
01:29:38.000 --> 01:29:42.000
Oh, maybe you don't. Let me sum it up.
01:29:42.000 --> 01:29:43.000
Mistake.
01:29:44.000 --> 01:29:47.000
But if you're going to do it yourself.
01:29:47.000 --> 01:29:53.000
Um… AI can help you. Don't ask AI to solve the problem.
01:29:54.000 --> 01:30:01.000
Ask AI to explain it. Ask AI to guide you along the path to figure it out.
01:30:01.000 --> 01:30:06.000
Rust is picky. It wants you to do the right thing.
01:30:06.000 --> 01:30:11.000
And it's like a super pedantic PhD mother.
01:30:11.000 --> 01:30:21.000
Um, it is not going to, um… clean your plate for you, but it is going to tell you how to clean your plate.
01:30:21.000 --> 01:30:37.000
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.
01:30:37.000 --> 01:30:43.000
But in general, that's not gonna happen for you until you actually get there.
01:30:43.000 --> 01:30:45.000
This is a downside.
01:30:45.000 --> 01:30:58.000
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.
01:30:58.000 --> 01:31:01.000
Packages flash by? Okay, I'm exaggerating.
01:31:01.000 --> 01:31:04.000
Rust isn't quite that bad.
01:31:04.000 --> 01:31:06.000
But quite is.
01:31:06.000 --> 01:31:09.000
load-bearing in that statement.
01:31:09.000 --> 01:31:12.000
Rust is young.
01:31:12.000 --> 01:31:18.000
In terms of a tortoise, Rust is about 10 years old.
01:31:18.000 --> 01:31:26.000
So, it's been around, but we are finding rough edges. We are learning new things.
01:31:26.000 --> 01:31:36.000
It's been maturing and fast and that also means there are changes happening. It's under active development.
01:31:36.000 --> 01:31:49.000
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.
01:31:49.000 --> 01:31:53.000
Um, it lets you pick specifically.
01:31:53.000 --> 01:31:56.000
which Rust you're using.
01:31:56.000 --> 01:32:02.000
And lets you have multiple toolchains installed at the same time.
01:32:02.000 --> 01:32:15.000
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.
01:32:09.000 --> 01:32:10.000
Hum.
01:32:15.000 --> 01:32:25.000
knows what edition it is, and will keep compiling, so that's good, but yeah, it's developing.
01:32:25.000 --> 01:32:32.000
Um, so… I'm gonna give you a quote. The language might change under me.
01:32:32.000 --> 01:32:41.000
That's the quote. It's true of basically every actively developed language, C++, Python, whatever, you name it.
01:32:41.000 --> 01:32:46.000
Rust is one of the few that engineered an actual mechanism.
01:32:46.000 --> 01:32:51.000
So that only matters when you decide it matters.
01:32:51.000 --> 01:32:56.000
I think there's only one thing left to talk about.
01:32:56.000 --> 01:32:58.000
And that is…
01:32:57.000 --> 01:33:00.000
Yeah, how do I get started?
01:33:01.000 --> 01:33:04.000
So there's good news?
01:33:03.000 --> 01:33:05.000
Yep.
01:33:04.000 --> 01:33:09.000
And there's good news! Which do you want first?
01:33:07.000 --> 01:33:09.000
Well, give me the good news.
01:33:09.000 --> 01:33:17.000
Uh, the good news is… You can do it in under a minute.
01:33:17.000 --> 01:33:25.000
Um, there is one command to start you up, and once you've used that one command.
01:33:25.000 --> 01:33:27.000
There's one more command.
01:33:27.000 --> 01:33:29.000
to do absolutely everything else.
01:33:29.000 --> 01:33:40.000
So yeah, you gotta go to the Rust place, and go get Rustup. R-U-S-T-U-P, one word, Rustup.
01:33:40.000 --> 01:33:46.000
Maybe you brew install it, maybe you… whatever. However you get it, you get it.
01:33:46.000 --> 01:33:50.000
Um, probably we can provide a link in the show notes.
01:33:49.000 --> 01:33:51.000
Sure.
01:33:50.000 --> 01:33:55.000
Um… And once you've got rust up.
01:33:55.000 --> 01:33:57.000
You can install Rust.
01:33:57.000 --> 01:34:11.000
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.
01:34:11.000 --> 01:34:16.000
Um, and you'll use RustUp to install cargo.
01:34:16.000 --> 01:34:19.000
And then you can say.
01:34:19.000 --> 01:34:20.000
cargo.
01:34:20.000 --> 01:34:22.000
New.
01:34:22.000 --> 01:34:24.000
Hello World.
01:34:24.000 --> 01:34:35.000
Uh… And then you go into that project, and say cargo run, and it will compile and run your brand new project.
01:34:35.000 --> 01:34:41.000
and your project will print, Hello World, and it'll do everything it takes to do that.
01:34:41.000 --> 01:34:45.000
The dependency management, the every everything.
01:34:43.000 --> 01:34:44.000
Hmmm.
01:34:45.000 --> 01:34:50.000
It'll do all of that, the whole thing, from I don't have Rust up to finished.
01:34:50.000 --> 01:34:52.000
In under a minute.
01:34:52.000 --> 01:34:53.000
Hum.
01:34:52.000 --> 01:34:56.000
Um, and now you're saying hello world. That's how you start.
01:34:56.000 --> 01:35:02.000
Now, would you like to know the other good news?
01:35:01.000 --> 01:35:06.000
Yes, yes, I'm waiting on pins and needles.
01:35:06.000 --> 01:35:07.000
Wondering what it could be.
01:35:06.000 --> 01:35:22.000
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.
01:35:22.000 --> 01:35:28.000
Rustlings is a series of tiny programs.
01:35:28.000 --> 01:35:32.000
You know, and they start, like, four lines long or whatever.
01:35:32.000 --> 01:35:38.000
And the programs don't compile. They're Rust. Rust that doesn't compile.
01:35:38.000 --> 01:35:44.000
And you open multiple terminal windows. In one, you run Rustlings.
01:35:44.000 --> 01:35:49.000
And in the other, your editor is looking at the bad file.
01:35:51.000 --> 01:35:56.000
You… Make, you learn about that Rust concept.
01:35:56.000 --> 01:36:03.000
Maybe by reading the Rust book, which we're also going to link to, which is the fundamental authority.
01:36:03.000 --> 01:36:15.000
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.
01:36:15.000 --> 01:36:17.000
You fix the error.
01:36:17.000 --> 01:36:20.000
You save the file.
01:36:20.000 --> 01:36:24.000
Rust in the terminal window notices it.
01:36:25.000 --> 01:36:27.000
compiles it.
01:36:27.000 --> 01:36:30.000
decides that you got it right.
01:36:30.000 --> 01:36:43.000
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.
01:36:43.000 --> 01:36:47.000
When you started, you didn't know what was right.
01:36:47.000 --> 01:36:50.000
When you're done.
01:36:50.000 --> 01:36:55.000
You know your version was right enough to compile.
01:36:55.000 --> 01:37:00.000
And you can look at the classic definition of right.
01:37:00.000 --> 01:37:03.000
And then you move on to the next one.
01:37:02.000 --> 01:37:03.000
Hum.
01:37:03.000 --> 01:37:08.000
I love rustlings. I do it myself.
01:37:08.000 --> 01:37:10.000
They're bite-sized pieces.
01:37:10.000 --> 01:37:16.000
You learn exactly the right thing, in the right place, at the right pace.
01:37:16.000 --> 01:37:23.000
If you want to skip a bunch of them because you already know stuff, go ahead, you can do that.
01:37:23.000 --> 01:37:24.000
Umm.
01:37:24.000 --> 01:37:26.000
End.
01:37:26.000 --> 01:37:28.000
In the same way.
01:37:28.000 --> 01:37:34.000
The AI could have helped you understand something better.
01:37:34.000 --> 01:37:38.000
On an arbitrary Rust problem? Just as helpful here.
01:37:38.000 --> 01:37:40.000
So use AI.
01:37:40.000 --> 01:37:42.000
Umm.
01:37:42.000 --> 01:37:44.000
I'm gonna bring it back.
01:37:44.000 --> 01:37:45.000
Two.
01:37:45.000 --> 01:37:47.000
The original.
01:37:47.000 --> 01:37:49.000
thesis.
01:37:49.000 --> 01:37:56.000
Um, and question to Jim. The thesis is… For everyone listening.
01:37:56.000 --> 01:38:02.000
Even if you never ship a line of Rust in production.
01:38:03.000 --> 01:38:06.000
I believe, and my thesis is.
01:38:06.000 --> 01:38:09.000
Time spent with rust.
01:38:09.000 --> 01:38:17.000
changes how you will see ownership, error handling, and type design everywhere else.
01:38:18.000 --> 01:38:22.000
So that opens the question back to you, Jim.
01:38:22.000 --> 01:38:34.000
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.
01:38:34.000 --> 01:38:37.000
What is your thinking about that statement?
01:38:36.000 --> 01:38:50.000
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.
01:38:50.000 --> 01:38:55.000
It's, you know, I found that with Swift. I think differently after playing in Swift.
01:38:55.000 --> 01:38:59.000
And I think Rust is even more.
01:38:56.000 --> 01:39:01.000
And there are several languages like this.
01:39:00.000 --> 01:39:02.000
Sure.
01:39:01.000 --> 01:39:08.000
Um, like, for instance, um… Haskell or Lisp.
01:39:08.000 --> 01:39:27.000
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.
01:39:27.000 --> 01:39:31.000
But a very tiny fraction of that group.
01:39:31.000 --> 01:39:36.000
would actually be interested in writing a Lisp program?
01:39:36.000 --> 01:39:41.000
I think… that the more Rust you learn.
01:39:41.000 --> 01:39:46.000
the more interested in writing a Rust program you will become.
01:39:46.000 --> 01:39:48.000
That's what I think.
01:39:48.000 --> 01:39:52.000
Um… And.
01:39:52.000 --> 01:39:57.000
I think that's all I've got to say. In case it wasn't clear from the beginning.
01:39:58.000 --> 01:40:02.000
I really like Rust.
01:40:02.000 --> 01:40:03.000
Umm.
01:40:03.000 --> 01:40:08.000
Python… Is my daily driver?
01:40:08.000 --> 01:40:12.000
And until recently.
01:40:12.000 --> 01:40:17.000
I would describe it as my absolute favorite language, maybe even still.
01:40:17.000 --> 01:40:21.000
But boy, rust is very strong competition.
01:40:21.000 --> 01:40:22.000
Um…
01:40:21.000 --> 01:40:31.000
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.
01:40:31.000 --> 01:40:35.000
It was fun watching.
01:40:32.000 --> 01:40:37.000
It wasn't going to be a language I worried about in 10 more days.
01:40:36.000 --> 01:40:39.000
Yeah, it was…
01:40:37.000 --> 01:40:39.000
It has no null?
01:40:39.000 --> 01:40:50.000
Yeah, right. No exceptions? What? Yeah, but it was fun watching you go through those stages of learning and come out the other side.
01:40:39.000 --> 01:40:42.000
I'll give it five more days.
01:40:50.000 --> 01:40:55.000
I'm really liking the language. I should learn it.
01:40:55.000 --> 01:41:08.000
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.
01:41:08.000 --> 01:41:09.000
Damn.
01:41:08.000 --> 01:41:14.000
Can we add one more link to the show notes?
01:41:13.000 --> 01:41:15.000
Sure.
01:41:15.000 --> 01:41:24.000
When we're about to publish the show notes, let's stick on a link that points to… engineering philosophy.
01:41:25.000 --> 01:41:27.000
Your thing?
01:41:27.000 --> 01:41:28.000
Yes.
01:41:27.000 --> 01:41:35.000
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.
01:41:34.000 --> 01:41:36.000
Will do.
01:41:35.000 --> 01:41:47.000
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.
01:41:46.000 --> 01:41:54.000
I would love to work with you on an SQL section, um, because I know SQL!
01:41:48.000 --> 01:41:49.000
Oh.
01:41:49.000 --> 01:41:51.000
Yep.
01:41:51.000 --> 01:41:53.000
Yeah, that'd be great.
01:41:54.000 --> 01:41:55.000
Huh-huh.
01:41:54.000 --> 01:42:10.000
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.
01:42:09.000 --> 01:42:11.000
Yeah.
01:42:11.000 --> 01:42:17.000
I don't know if our listeners will remember, that was one of the opening scenes, maybe, of…
01:42:11.000 --> 01:42:12.000
Yeah, I've.
01:42:12.000 --> 01:42:13.000
Yeah, so.
01:42:17.000 --> 01:42:20.000
Kung Fu, the TV series.
01:42:20.000 --> 01:42:23.000
Wait, when was that, the 70s?
01:42:21.000 --> 01:42:27.000
Uh, wise, wise, wise choice, weed hopper, uh, grasshopper.
01:42:27.000 --> 01:42:34.000
I think Weed Hopper was the, was the Mad Magazine, uh, spoof on, uh, Kung Fu. Yeah.
01:42:34.000 --> 01:42:37.000
What a wise choice, grasshopper.
01:42:38.000 --> 01:42:43.000
Yeah, you're dating us. Yeah, because that was back in the 70s.
01:42:43.000 --> 01:42:50.000
Oh, and me saying four decades of hard-won engineering experience doesn't date me?
01:42:50.000 --> 01:42:52.000
Yeah. Yeah, right.
01:42:52.000 --> 01:42:58.000
Yeah, I started when I was two.
01:42:54.000 --> 01:42:59.000
Yeah, I get, I get it.
01:43:00.000 --> 01:43:15.000
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.
01:43:15.000 --> 01:43:30.000
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.
01:43:30.000 --> 01:43:45.000
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.
01:43:45.000 --> 01:44:00.000
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.
01:44:00.000 --> 01:44:10.000
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.
01:44:10.000 --> 01:44:25.000
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.
01:44:25.000 --> 01:44:31.000
So I got to spend, you know, two and a half hours with you, and that is an ice cream scoop.
01:44:31.000 --> 01:44:33.000
And two.
01:44:33.000 --> 01:44:49.000
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.
01:44:35.000 --> 01:44:36.000
Yeah.
01:44:46.000 --> 01:44:47.000
Yes.
01:44:49.000 --> 01:44:57.000
a double scoop. So this was great for me. And I guess I want to say to everybody, thanks and goodbye.
01:44:53.000 --> 01:44:55.000
Yah.
01:44:57.000 --> 01:44:59.000
Yeah, goodbye.