WEBVTT

00:00:01.610 --> 00:00:05.710
<v Matthias>Here's another episode of Rust in Production, a podcast about companies who

00:00:05.710 --> 00:00:07.690
<v Matthias>use Rust to shape the future of infrastructure.

00:00:08.170 --> 00:00:12.570
<v Matthias>My name is Matthias Endler from corrode, and today we talk to Richard Feldman

00:00:12.570 --> 00:00:16.630
<v Matthias>from ROC about their reasons for migrating from Rust to Zig.

00:00:19.010 --> 00:00:22.170
<v Matthias>Richard, thanks so much for taking the time for the interview.

00:00:22.510 --> 00:00:26.950
<v Matthias>Can you say a few words about yourself and about ROC, the programming language you're working on?

00:00:27.370 --> 00:00:31.030
<v Richard>Yeah, sure. So I'm Richard. So my day job is I work at Zed Industries,

00:00:31.170 --> 00:00:33.450
<v Richard>making the Zed code editor, which is all written in Rust.

00:00:33.710 --> 00:00:36.630
<v Richard>So mostly what I spend my time on is writing Rust. On the side,

00:00:36.770 --> 00:00:39.530
<v Richard>I have been developing for the past several years, the Roc programming language,

00:00:39.730 --> 00:00:42.010
<v Richard>which I created, but I work on with a number of other people.

00:00:43.270 --> 00:00:47.690
<v Richard>Originally, Roc's compiler was written in Rust completely. And now it's being

00:00:47.690 --> 00:00:50.130
<v Richard>rewritten in Zig, which is what I assume we're going to talk about.

00:00:51.530 --> 00:00:55.690
<v Matthias>Precisely. Yeah, it's perfect. we had said in

00:00:55.690 --> 00:00:58.590
<v Matthias>a previous episode as well if you want to check that out we

00:00:58.590 --> 00:01:01.530
<v Matthias>will link it in the show notes that was an amazing episode as

00:01:01.530 --> 00:01:04.650
<v Matthias>well and also for this one i have

00:01:04.650 --> 00:01:09.210
<v Matthias>really high hopes because your name was mentioned a couple times by a couple

00:01:09.210 --> 00:01:14.250
<v Matthias>of our listeners because you wrote an article or maybe you published a post

00:01:14.250 --> 00:01:19.410
<v Matthias>let's say about your migration from rust to Zig but before we get into that

00:01:19.410 --> 00:01:24.490
<v Matthias>what is Roc what makes it special why did you start that project.

00:01:25.240 --> 00:01:28.100
<v Richard>Yeah, so Roc's tagline is fast, friendly, functional.

00:01:28.560 --> 00:01:32.340
<v Richard>And basically, it's a functional programming language. The goal is to be really, really fast.

00:01:32.540 --> 00:01:36.540
<v Richard>We want it to be the fastest garbage collected language. That's sort of the goalpost that we set.

00:01:36.700 --> 00:01:40.940
<v Richard>So I would say that Go right now, as far as I'm aware, is the fastest garbage collected language.

00:01:41.120 --> 00:01:45.640
<v Richard>And we want to be faster than Go, not as fast as Rust or C++ or Zig or any of

00:01:45.640 --> 00:01:48.720
<v Richard>those, because we want to be completely memory safe, guaranteed.

00:01:48.720 --> 00:01:51.600
<v Richard>Speed and basically the the goal is to

00:01:51.600 --> 00:01:54.400
<v Richard>be competing with languages like go or maybe like

00:01:54.400 --> 00:01:57.480
<v Richard>you know ocamel also has a good reputation for speed while being

00:01:57.480 --> 00:02:01.140
<v Richard>a functional programming language as opposed to like go being very imperative

00:02:01.140 --> 00:02:05.740
<v Richard>so yeah that's that's the goal in terms of speed in terms of friendliness it's

00:02:05.740 --> 00:02:10.080
<v Richard>like have really simple apis very very heavily inspired by elm Roc is sort

00:02:10.080 --> 00:02:14.160
<v Richard>of an outgrowth of my really positive experiences with elm but elm is targeted

00:02:14.160 --> 00:02:17.280
<v Richard>at compiling to JavaScript and front-end web development,

00:02:17.320 --> 00:02:21.440
<v Richard>whereas Roc compiles to machine code or to WebAssembly and is sort of trying

00:02:21.440 --> 00:02:25.100
<v Richard>to address all of these use cases that are not front-end web development.

00:02:25.660 --> 00:02:29.640
<v Richard>Also, Roc's design has evolved quite a bit from Elm's. Now it's a much different

00:02:29.640 --> 00:02:32.080
<v Richard>language. When it started out, it was very similar to Elm.

00:02:32.360 --> 00:02:36.640
<v Richard>Now it's a lot less similar, but I think the essence of that sort of ethos of

00:02:36.640 --> 00:02:41.180
<v Richard>simplicity and really nice APIs and really friendly compiler error messages and things like that.

00:02:41.460 --> 00:02:44.620
<v Richard>Actually, Elm's error messages inspired Rust, even though So I think Rust is

00:02:44.620 --> 00:02:46.340
<v Richard>now more famous for compiler errors.

00:02:48.100 --> 00:02:50.600
<v Richard>So all of that is sort of what we're going for with Roc.

00:02:51.220 --> 00:02:54.200
<v Matthias>And take us back to the time when you started the project.

00:02:54.780 --> 00:02:59.320
<v Matthias>What was the ecosystem like? What were some of the other languages that you

00:02:59.320 --> 00:03:01.960
<v Matthias>got inspired by when you started with Roc?

00:03:02.160 --> 00:03:06.600
<v Matthias>And also, what was that initial spark that told you, hey, I need to do this,

00:03:06.720 --> 00:03:08.700
<v Matthias>and now is the best time for it?

00:03:09.900 --> 00:03:14.420
<v Richard>Really, the inspiration for it came from an experience I had.

00:03:14.600 --> 00:03:17.760
<v Richard>This is back when I was working at NoRedInk. We had this huge Elm front end,

00:03:17.900 --> 00:03:22.420
<v Richard>and we had Ruby on Rails for the back end. And Rails had been at the back end

00:03:22.420 --> 00:03:24.060
<v Richard>for long before we started using Elm.

00:03:24.220 --> 00:03:27.920
<v Richard>And we were trying to move the back end to something more functional.

00:03:28.460 --> 00:03:32.420
<v Richard>And kind of what we discovered was that there was just really this missing piece

00:03:32.420 --> 00:03:35.420
<v Richard>in the ecosystem, or at least that was my perception of it.

00:03:35.560 --> 00:03:38.960
<v Richard>We ended up going with Haskell and trying to use Haskell in kind of an Elm-like way.

00:03:39.260 --> 00:03:44.320
<v Richard>But my feeling was what we really want is a functional language that's statically

00:03:44.320 --> 00:03:49.960
<v Richard>type checked with type inference built around purity. So OCaml is a functional

00:03:49.960 --> 00:03:53.060
<v Richard>language, but it's really not like pure functions everywhere.

00:03:53.300 --> 00:03:57.300
<v Richard>It's sort of like pure functions are encouraged, but they're not really first class in OCaml.

00:03:57.830 --> 00:04:03.430
<v Richard>Same thing with F sharp. And basically what we ended up concluding was that it just doesn't exist.

00:04:03.570 --> 00:04:06.390
<v Richard>Like there is no Elm equivalent outside of the browser.

00:04:07.190 --> 00:04:09.930
<v Richard>And that was kind of the spark for me to go and do it.

00:04:09.990 --> 00:04:15.850
<v Richard>As far as what languages inspired it, really it was Elm plus like maybe little

00:04:15.850 --> 00:04:18.770
<v Richard>bits and pieces of other languages, but it's very primarily like,

00:04:19.050 --> 00:04:22.850
<v Richard>okay, how do I take this great experience we've had with Elm and translate it

00:04:22.850 --> 00:04:24.870
<v Richard>to other domains besides just the browser?

00:04:25.030 --> 00:04:28.690
<v Richard>And I didn't want to just do servers. The kind of the idea was i'd be using

00:04:28.690 --> 00:04:32.090
<v Richard>this phrase the long tail of domains like basically there's lots of different

00:04:32.090 --> 00:04:36.190
<v Richard>use cases out there it's not just servers there's command line apps there's native graphical apps.

00:04:37.270 --> 00:04:40.930
<v Richard>There's microcontrollers robotics you know there's this very long tail of different

00:04:40.930 --> 00:04:44.290
<v Richard>things you can do with programming and i wanted to see could we bring an elm

00:04:44.290 --> 00:04:48.310
<v Richard>like experience to all those different domains in terms of being a very simple

00:04:48.310 --> 00:04:50.970
<v Richard>functional experience yeah.

00:04:50.970 --> 00:04:55.370
<v Matthias>And i could see a few ways how this could go because the Rust compiler is not,

00:04:55.530 --> 00:04:59.530
<v Matthias>or the first version of it wasn't written in Rust because Rust didn't exist, obviously.

00:04:59.690 --> 00:05:02.190
<v Matthias>It was written on OCaml as well. And,

00:05:02.810 --> 00:05:07.150
<v Matthias>Then you have Elm, which might be another way to implement a new language on

00:05:07.150 --> 00:05:12.050
<v Matthias>top of, or maybe there's a language that I don't know of that you could use.

00:05:12.190 --> 00:05:15.750
<v Matthias>But why did you choose Rust and which alternatives did you consider?

00:05:16.490 --> 00:05:20.450
<v Richard>Yeah, also a great question. So basically, the reason I chose Rust was that

00:05:20.450 --> 00:05:23.390
<v Richard>I wanted the compiler to be as fast as possible.

00:05:24.070 --> 00:05:28.550
<v Richard>And I was, to be totally honest, scared of trying to do it in a memory unsafe

00:05:28.550 --> 00:05:33.190
<v Richard>language based on past experiences I'd had with segmentation faults that I really

00:05:33.190 --> 00:05:34.630
<v Richard>struggled to debug and stuff like that.

00:05:35.170 --> 00:05:39.790
<v Richard>When I was very young, like middle school era, I got into C++ because I wanted to do game dev.

00:05:40.070 --> 00:05:43.230
<v Richard>And I have some scars from trying

00:05:43.230 --> 00:05:46.690
<v Richard>to do that and bumbling around and just making a huge mess for myself.

00:05:46.850 --> 00:05:50.990
<v Richard>And the pitch of Rust of being, hey, you can have this really,

00:05:51.070 --> 00:05:54.570
<v Richard>really high performance ceiling. In other words, there's no mandatory garbage collector.

00:05:54.810 --> 00:05:58.070
<v Richard>There's no built-in boxing of things you

00:05:58.070 --> 00:06:01.310
<v Richard>can be as fast as a c or c plus plus program but

00:06:01.310 --> 00:06:04.150
<v Richard>you're going to have memory safety you don't have to worry about seg

00:06:04.150 --> 00:06:06.990
<v Richard>faults and all these things that that you know i had these bad experiences with

00:06:06.990 --> 00:06:10.910
<v Richard>in the past that was the pitch that sort of sold me because my thinking was

00:06:10.910 --> 00:06:14.610
<v Richard>well if i do the compiler in oCaml or Haskell or something like that yeah that's

00:06:14.610 --> 00:06:17.650
<v Richard>going to be a more familiar experience to me but at some point i'm going to

00:06:17.650 --> 00:06:22.470
<v Richard>reach this point where i'm like i want it to go faster and i can't because i'm

00:06:22.470 --> 00:06:24.550
<v Richard>limited by the performance ceiling of this language.

00:06:25.270 --> 00:06:27.870
<v Richard>I don't want that and then at that point i'm like what am i going to do

00:06:27.870 --> 00:06:30.850
<v Richard>i'm going to say oh now i rewrite it in rust you know this is something that's happening

00:06:30.850 --> 00:06:34.270
<v Richard>in the javascript ecosystem a lot is that a lot of projects started off

00:06:34.270 --> 00:06:37.170
<v Richard>being written in javascript because that's what was familiar to people and then

00:06:37.170 --> 00:06:41.310
<v Richard>they realized past a certain point that a compiler is one of those use cases

00:06:41.310 --> 00:06:46.210
<v Richard>where just more performance is better it's not like you get down to this point

00:06:46.210 --> 00:06:49.470
<v Richard>you know in a lot of graphical applications it's kind of like well as long as

00:06:49.470 --> 00:06:51.790
<v Richard>you're not dropping frames as long as you're under the you know however many

00:06:51.790 --> 00:06:53.930
<v Richard>milliseconds you have within each frame Thank you.

00:06:54.420 --> 00:06:57.640
<v Richard>Humans can't perceive a difference it's like it's fast enough and

00:06:57.640 --> 00:07:00.420
<v Richard>if you make it faster nobody notices compilers are

00:07:00.420 --> 00:07:03.320
<v Richard>not like that faster is pretty much always better it's

00:07:03.320 --> 00:07:05.980
<v Richard>a it's just a big part of the ux is you know

00:07:05.980 --> 00:07:09.380
<v Richard>how long are you waiting for rebuilds and stuff like that and so

00:07:09.380 --> 00:07:12.200
<v Richard>my feeling was especially actually this this came

00:07:12.200 --> 00:07:15.000
<v Richard>up in elm when we were using element NoRedInk at some point we

00:07:15.000 --> 00:07:17.820
<v Richard>became the largest elm code base we had a couple hundred thousand lines

00:07:17.820 --> 00:07:22.020
<v Richard>i don't remember exactly how big it was at the time but elm 0.18

00:07:22.020 --> 00:07:24.900
<v Richard>we were really feeling the pain of compile

00:07:24.900 --> 00:07:28.080
<v Richard>times it's like we'd had a really positive experience and it was becoming a

00:07:28.080 --> 00:07:31.240
<v Richard>very negative experience just because we were waiting so long for rebuilds

00:07:31.240 --> 00:07:34.140
<v Richard>and then when elm 0.19 came out evan had rewritten

00:07:34.140 --> 00:07:37.600
<v Richard>a huge amount of the elm compiler which was written in haskell for

00:07:37.600 --> 00:07:40.860
<v Richard>performance and it took him a long time it's months and

00:07:40.860 --> 00:07:43.740
<v Richard>months and months but when it came out it was just this amazing

00:07:43.740 --> 00:07:46.720
<v Richard>breath of fresh air all of our builds were fast again like they used to be when

00:07:46.720 --> 00:07:50.200
<v Richard>our when our code base was small and that was a really important lesson for

00:07:50.200 --> 00:07:54.220
<v Richard>me was yeah take the stuff seriously like compile times are a really big deal

00:07:54.220 --> 00:07:58.400
<v Richard>and if you want to build a language that has a good end user experience you

00:07:58.400 --> 00:08:02.040
<v Richard>know fast friendly functional part of that friendliness and user friendliness.

00:08:02.820 --> 00:08:07.460
<v Richard>Is committing to having a compiler that is really really really fast and that's

00:08:07.460 --> 00:08:10.340
<v Richard>something that i've been completely unwilling to compromise on since the beginning

00:08:10.340 --> 00:08:12.540
<v Richard>of the project the compiler's always It's got to be really fast.

00:08:13.260 --> 00:08:17.420
<v Matthias>Yeah. And that was in 2019. Correct me if I'm wrong here.

00:08:17.860 --> 00:08:22.660
<v Matthias>What was your level of Rust experience when you started with implementing Roc?

00:08:22.780 --> 00:08:24.560
<v Matthias>Was it your first big Rust project?

00:08:25.220 --> 00:08:31.440
<v Richard>It was my first big Rust project. So previously in 2017, I had dabbled in Rust, I would say.

00:08:31.640 --> 00:08:34.100
<v Richard>I'd written the Elm test runner originally in Node.js.

00:08:34.640 --> 00:08:38.320
<v Richard>And it was honestly out of frustration with the Node.js ecosystem that I was

00:08:38.320 --> 00:08:40.720
<v Richard>like, I just want to try something else. Why don't I try Rust?

00:08:41.100 --> 00:08:44.560
<v Richard>I never actually shipped anything out of that project It was like I just started

00:08:44.560 --> 00:08:48.260
<v Richard>rewriting it in Rust So I kind of got a feel for it And the experience that

00:08:48.260 --> 00:08:51.220
<v Richard>I had initially with Rust Was positive enough that I was like Yeah, this...

00:08:51.890 --> 00:08:54.650
<v Richard>This seems like something I'm willing to commit to for this compiler,

00:08:54.790 --> 00:08:57.550
<v Richard>even though I know this is going to be a very, very long, you know,

00:08:57.830 --> 00:09:01.350
<v Richard>project that I'm going to spend way more time on than this little sort of side

00:09:01.350 --> 00:09:03.290
<v Richard>project thing that was just kind of for fun.

00:09:03.290 --> 00:09:07.330
<v Richard>And I mean, my feeling going into this was that this is a language that I'm

00:09:07.330 --> 00:09:10.790
<v Richard>planning on putting multiple decades of my life into.

00:09:11.110 --> 00:09:16.490
<v Richard>And so committing to Rust with just that minimal level of experience was a bit

00:09:16.490 --> 00:09:20.770
<v Richard>of a leaf of faith in the sense that I didn't have enough Rust experience to

00:09:20.770 --> 00:09:23.070
<v Richard>know that I was going to like it that much long term.

00:09:23.430 --> 00:09:26.750
<v Richard>But at the same time, I had enough experience.

00:09:26.930 --> 00:09:30.170
<v Richard>It wasn't zero. It wasn't like I was sitting down and writing Hello World and Rust.

00:09:30.290 --> 00:09:32.050
<v Richard>And then I was like, that's what this compiler is going to be in.

00:09:32.050 --> 00:09:36.930
<v Richard>So I would say it was an informed decision, but my Rust experience at that point was pretty minimal.

00:09:37.850 --> 00:09:41.990
<v Matthias>When you think in decades, how does it shape the decision-making process?

00:09:42.790 --> 00:09:49.390
<v Richard>I would say the main thing is that it gives me the comfort to make long-term investments.

00:09:50.310 --> 00:09:54.370
<v Richard>So a lot of projects that I've worked on in my career have been for startups.

00:09:54.710 --> 00:09:58.690
<v Richard>And startups are often like, yep, in 18 months, we're going to be out of money

00:09:58.690 --> 00:10:02.950
<v Richard>and disappeared off the face of the planet. So it's really important that we

00:10:02.950 --> 00:10:04.290
<v Richard>survive the next 18 months.

00:10:04.650 --> 00:10:08.230
<v Richard>And so making a long-term investment has to be balanced against,

00:10:08.490 --> 00:10:12.270
<v Richard>okay, if we make this long-term investment, is that investment going to cause

00:10:12.270 --> 00:10:16.010
<v Richard>us to not exist long enough to reap the benefits of the long-term investment?

00:10:16.290 --> 00:10:17.870
<v Richard>And there's always that constant tension.

00:10:18.510 --> 00:10:22.430
<v Richard>With this project, my feeling was the opposite. It's like, I'm very comfortable

00:10:22.430 --> 00:10:23.630
<v Richard>making long-term investments.

00:10:23.810 --> 00:10:26.830
<v Richard>The main thing I was actually thinking about was, and this is again,

00:10:27.010 --> 00:10:31.790
<v Richard>shaped by my early experiences with Elm and participating in having the good

00:10:31.790 --> 00:10:36.150
<v Richard>fortune to live in the same city as Evan Czaplicki who created Elm and being

00:10:36.150 --> 00:10:37.330
<v Richard>able to talk to him about these things.

00:10:37.550 --> 00:10:42.710
<v Richard>But basically understanding that if I'm going to be making a long-term investment in the language...

00:10:43.930 --> 00:10:48.050
<v Richard>It's important that I also communicate that clearly and set expectations clearly

00:10:48.050 --> 00:10:49.470
<v Richard>to people who are using the language.

00:10:49.910 --> 00:10:52.490
<v Richard>So from the very beginning, I've tried really hard to communicate,

00:10:52.730 --> 00:10:56.330
<v Richard>hey, things are not set in stone here. We're going to be making breaking changes

00:10:56.330 --> 00:10:57.290
<v Richard>to this language, et cetera.

00:10:57.570 --> 00:11:00.650
<v Richard>The strongest way that I've done that is we intentionally, even though,

00:11:00.990 --> 00:11:04.850
<v Richard>like you said, the first line of code was 2019. I actually started designing it in 2018.

00:11:05.610 --> 00:11:08.610
<v Richard>But ever since then, we still do not have a numbered release.

00:11:08.790 --> 00:11:12.230
<v Richard>We're planning on having our first numbered release in 2026 like

00:11:12.230 --> 00:11:14.970
<v Richard>0.1.0 but the whole reason we've been doing that

00:11:14.970 --> 00:11:18.630
<v Richard>is just to communicate you have to build from nightly expect things

00:11:18.630 --> 00:11:21.470
<v Richard>to break despite this we still do actually have one

00:11:21.470 --> 00:11:26.210
<v Richard>person who's been consistently using Roc in production at his job but that's

00:11:26.210 --> 00:11:30.070
<v Richard>to me an appropriate level of cautiousness where like we only have one person

00:11:30.070 --> 00:11:33.030
<v Richard>doing it even though lots of people have done Roc for hobby projects and stuff

00:11:33.030 --> 00:11:37.630
<v Richard>because we are making big changes and so those are all things that i see as

00:11:37.630 --> 00:11:40.090
<v Richard>long-term investments i think if i were thinking more short term,

00:11:40.270 --> 00:11:42.570
<v Richard>I might be like, okay, no, we already need to be backwards compatible.

00:11:42.930 --> 00:11:46.090
<v Richard>We can't, you know, new releases need to not break things.

00:11:46.630 --> 00:11:52.670
<v Richard>Rust and Gleam and Go are all languages that I think went 1.0 and had a strong

00:11:52.670 --> 00:11:56.830
<v Richard>backwards compatibility guarantee relatively early on. And I think that really

00:11:56.830 --> 00:11:57.750
<v Richard>helped them with adoption.

00:11:58.310 --> 00:12:02.730
<v Richard>But to me, my goal is not immediate term adoption. I'm more thinking about what

00:12:02.730 --> 00:12:04.510
<v Richard>we're trying to do is really ambitious.

00:12:04.890 --> 00:12:08.430
<v Richard>And I really, really, really want to get it right, or at least as close to right

00:12:08.430 --> 00:12:11.310
<v Richard>as we can get it before we make commitments to backwards compatibility.

00:12:11.990 --> 00:12:16.150
<v Richard>So that's the type of thing that I think thinking in decades has as a benefit.

00:12:16.430 --> 00:12:19.590
<v Richard>It's that I can say, yeah, we've been working on this for years,

00:12:19.630 --> 00:12:23.230
<v Richard>but we still don't have a numbered release because I really want to clearly

00:12:23.230 --> 00:12:25.750
<v Richard>communicate to people, things are going to break.

00:12:27.490 --> 00:12:30.510
<v Richard>Please don't expect that we're going to have backwards compatibility because

00:12:30.510 --> 00:12:31.550
<v Richard>we're not ready for that yet.

00:12:31.710 --> 00:12:34.230
<v Richard>But I think we're actually almost to the point where we are ready for that,

00:12:34.230 --> 00:12:37.850
<v Richard>which is pretty exciting milestone to be coming up on hopefully next year.

00:12:38.580 --> 00:12:40.440
<v Matthias>I want to talk about Rust, the

00:12:40.440 --> 00:12:45.840
<v Matthias>good parts, for a moment, because not everything was bad, I'm assuming.

00:12:46.900 --> 00:12:51.240
<v Matthias>In your post, you already mentioned a couple of really sane reasons to move away from Rust.

00:12:51.380 --> 00:12:55.540
<v Matthias>But can you talk to us a little bit about the good parts, the things that you

00:12:55.540 --> 00:13:00.780
<v Matthias>like about Rust, working with larger codebases, and what does it really feel

00:13:00.780 --> 00:13:03.540
<v Matthias>like to work in the trenches with such a language?

00:13:04.260 --> 00:13:06.080
<v Richard>Yeah, there are lots of good parts to Rust. And to be clear,

00:13:06.220 --> 00:13:07.740
<v Richard>I like Rust overall as a language.

00:13:07.940 --> 00:13:12.420
<v Richard>I'm not like a Rust hater. I'm not like, oh, Rust is old and busted and Zig

00:13:12.420 --> 00:13:14.660
<v Richard>is like the new hotness. It's very much the opposite.

00:13:14.860 --> 00:13:20.280
<v Richard>It's more that for this particular project, I ended up deciding that if we're

00:13:20.280 --> 00:13:23.920
<v Richard>going to do a rewrite anyway, then that rewrite should be in Zig rather than

00:13:23.920 --> 00:13:28.440
<v Richard>rewriting it again in Rust, which we'll get to. But yeah, Rust's the good part.

00:13:28.600 --> 00:13:31.900
<v Richard>So I mean, the first thing that I would mention is that, like I said,

00:13:32.000 --> 00:13:38.260
<v Richard>I work at Zed full time, and I don't think it would make any sense for Zed to move away from Rust.

00:13:38.560 --> 00:13:43.420
<v Richard>Like Rust seems like it just fits the way that Zed's codebase works like a glove.

00:13:43.620 --> 00:13:48.720
<v Richard>If you wanted to rewrite Zed in something other than Rust, first of all,

00:13:48.780 --> 00:13:52.360
<v Richard>that sounds like a really daunting proposition, not just because it's a lot

00:13:52.360 --> 00:13:56.200
<v Richard>of work, but because Zed's codebase very, very heavily works.

00:13:56.220 --> 00:13:59.560
<v Richard>Relies on a combination of features that Rust is really good at,

00:13:59.900 --> 00:14:05.640
<v Richard>such as you have the memory safety, which when you have a wide contributor base,

00:14:05.860 --> 00:14:07.200
<v Richard>we have Zed's open source.

00:14:07.340 --> 00:14:10.840
<v Richard>So it's not just that we have people at Zed working on Zed, but also we get

00:14:10.840 --> 00:14:12.120
<v Richard>all sorts of outside contributions.

00:14:12.740 --> 00:14:17.160
<v Richard>It's really helpful in that context to be able to look at someone's pull request

00:14:17.160 --> 00:14:22.140
<v Richard>and be able to say with a lot of confidence, okay, this is not introducing sneaky memory safety bugs.

00:14:22.140 --> 00:14:26.600
<v Richard>Now, granted, you can make the point that, you know, lots of non-memory safe

00:14:26.600 --> 00:14:29.520
<v Richard>languages have lots of contributors too, like Zig, for example.

00:14:30.020 --> 00:14:33.780
<v Richard>Also Ghosty, which Mitchell Hashimoto made in Zig, has lots of contributors.

00:14:34.440 --> 00:14:38.080
<v Richard>But I think it's definitely a selling point of Rust that when I look at a pull

00:14:38.080 --> 00:14:41.540
<v Richard>request coming into Zed, I can say with a lot of confidence,

00:14:41.540 --> 00:14:45.660
<v Richard>this is not going to introduce some very subtle memory safe debug that I'm going

00:14:45.660 --> 00:14:48.980
<v Richard>to have a really difficult time debugging later.

00:14:48.980 --> 00:14:53.800
<v Richard>Sort of the blast radius of what a new contribution can do in terms of mistakes

00:14:53.800 --> 00:14:58.040
<v Richard>is a lot smaller I do think that's something we benefited from in the Rust version

00:14:58.040 --> 00:14:59.180
<v Richard>of the Roc compiler as well.

00:15:00.410 --> 00:15:03.450
<v Richard>So outside contributors, but also, of course, you know, within the code base,

00:15:03.530 --> 00:15:07.570
<v Richard>it's the same thing. It's definitely a benefit to not have to worry about those things.

00:15:08.150 --> 00:15:12.410
<v Richard>I wouldn't say I've gotten zero segmentation faults or memory safety errors

00:15:12.410 --> 00:15:16.830
<v Richard>in either the original Rust compiler for Roc or in Zed.

00:15:16.950 --> 00:15:19.290
<v Richard>Actually, literally yesterday we had a seg fault in CI.

00:15:21.730 --> 00:15:26.950
<v Richard>And it was it was on well it was it was in our new Windows code base and some

00:15:26.950 --> 00:15:29.670
<v Richard>of the stuff that we're doing is very low level you know interacting directly

00:15:29.670 --> 00:15:33.310
<v Richard>with the operating system graphics APIs and drivers and stuff like that because

00:15:33.310 --> 00:15:37.170
<v Richard>we're it's a very high performance code base and you know,

00:15:38.090 --> 00:15:42.450
<v Richard>Zed is a good example of the classic Rust model of if you're going to have to

00:15:42.450 --> 00:15:45.690
<v Richard>have some unsafe code because you're doing just innately unsafe things,

00:15:45.890 --> 00:15:51.530
<v Richard>maybe for performance, maybe for FFI, whatever, just having it very small and contained is helpful.

00:15:51.790 --> 00:15:57.350
<v Richard>And so, you know, it is helpful to know that the surface area of that is smaller and more contained.

00:15:57.510 --> 00:16:01.590
<v Richard>And if you look at Zed's code base, I think you see what you want to see in

00:16:01.590 --> 00:16:04.390
<v Richard>a classic Rust code base, which is the amount of unsafe is a very,

00:16:04.470 --> 00:16:06.690
<v Richard>very small percentage of the overall code base.

00:16:07.930 --> 00:16:11.250
<v Richard>So yeah i mean i think all those things are great obviously the

00:16:11.250 --> 00:16:13.970
<v Richard>the cargo ecosystem is very large and there's lots

00:16:13.970 --> 00:16:16.830
<v Richard>of stuff you can get off the shelf which is nice there's this classic

00:16:16.830 --> 00:16:19.850
<v Richard>problem in a language where if you were to time travel back

00:16:19.850 --> 00:16:22.650
<v Richard>to when rust 1.0 came out or you know even before

00:16:22.650 --> 00:16:25.450
<v Richard>that everybody would say well ecosystem is

00:16:25.450 --> 00:16:28.230
<v Richard>a downside of rust where they would say like well there's no ecosystem you

00:16:28.230 --> 00:16:30.870
<v Richard>know how can you how can you ignore the gigantic c and c plus plus

00:16:30.870 --> 00:16:33.810
<v Richard>ecosystem whereas of course now ecosystem is the selling point

00:16:33.810 --> 00:16:36.790
<v Richard>i don't know how like people have amnesia about this but

00:16:36.790 --> 00:16:39.850
<v Richard>like it's like every language that has a big ecosystem

00:16:39.850 --> 00:16:42.970
<v Richard>today used to have no ecosystem it just

00:16:42.970 --> 00:16:47.490
<v Richard>grew over time that's just it's a normal part of a language growing so it's

00:16:47.490 --> 00:16:51.090
<v Richard>it's totally reasonable for people to say i don't want to use this language

00:16:51.090 --> 00:16:55.530
<v Richard>right now because right now the ecosystem is small but it's a little bit of

00:16:55.530 --> 00:16:58.850
<v Richard>a pet peeve of mine when people act like that's just this permanent state it's

00:16:58.850 --> 00:17:02.890
<v Richard>like no actually it's the opposite of that it always the ecosystem always grows.

00:17:03.150 --> 00:17:06.030
<v Richard>That's where all the ecosystems you think of as big came from.

00:17:07.060 --> 00:17:10.780
<v Richard>But certainly at this point, the crates.io ecosystem is just,

00:17:10.860 --> 00:17:13.780
<v Richard>you know, very large and you can pull all sorts of stuff off the shelf.

00:17:13.940 --> 00:17:18.060
<v Richard>And that's a selling point. There are some things in Zig that we use at Zed

00:17:18.060 --> 00:17:20.200
<v Richard>that we couldn't get off the shelf in Zig.

00:17:20.360 --> 00:17:24.480
<v Richard>We would have to do like FFI to a C library or a C++ and C++.

00:17:24.920 --> 00:17:27.780
<v Richard>If you're trying to pull stuff off the shelf in C++ and use that in Zig,

00:17:28.060 --> 00:17:32.800
<v Richard>that's a much bigger pain than trying to pull something off the shelf in C and use that.

00:17:32.800 --> 00:17:36.560
<v Richard>See it's a lot easier to interoperate with in Zig so

00:17:36.560 --> 00:17:39.540
<v Richard>yeah the ecosystem also a selling point and i

00:17:39.540 --> 00:17:42.300
<v Richard>think the biggest thing for zed's code base is just the fact

00:17:42.300 --> 00:17:47.160
<v Richard>that you have for lack of a better term drop and because you have drop you have

00:17:47.160 --> 00:17:51.500
<v Richard>reference counting automatic reference counting and we use arc all over the

00:17:51.500 --> 00:17:55.180
<v Richard>zed code base it's just everywhere and we rely on it very heavily we're constantly

00:17:55.180 --> 00:17:59.220
<v Richard>cloning arc things when i first got to the zed code base i was a little bit

00:17:59.220 --> 00:18:01.440
<v Richard>nervous because I would see these .clones everywhere.

00:18:02.140 --> 00:18:06.160
<v Richard>And my experience from writing the Rok compiler in Rust, which used very little

00:18:06.160 --> 00:18:11.520
<v Richard>Arc or RC, was that, oh, if I see a .clone, that's a hotspot.

00:18:11.620 --> 00:18:14.080
<v Richard>That's a big performance potential problem.

00:18:14.400 --> 00:18:17.340
<v Richard>And we had this convention of in the few places where we would use Arc,

00:18:17.440 --> 00:18:20.900
<v Richard>we would do the Arc colon colon clone. So it's really clear,

00:18:21.040 --> 00:18:21.920
<v Richard>like, don't worry, don't worry. It's okay.

00:18:22.180 --> 00:18:25.620
<v Richard>It's just a reference count bump. We're not deep cloning the whole thing.

00:18:26.480 --> 00:18:30.120
<v Richard>But in Zed's code base, if you did that, you would be writing arc colon colon

00:18:30.120 --> 00:18:34.740
<v Richard>clone so so many times it would just be everywhere so what happens instead is

00:18:34.740 --> 00:18:38.200
<v Richard>you just use dot clone because that's way more concise because that's the normal

00:18:38.200 --> 00:18:40.780
<v Richard>way that cloning is used in the Z code base,

00:18:41.520 --> 00:18:44.080
<v Richard>but to do that you do have to have that,

00:18:44.880 --> 00:18:50.580
<v Richard>drop, basically. You need to be able to have automatic, C++ people would call it RAII.

00:18:51.660 --> 00:18:55.560
<v Richard>Zigg, by design, does not have that. And so that's one of the examples of why

00:18:55.560 --> 00:18:59.700
<v Richard>the idea of rewriting Zed's code base in Zigg sounds totally ridiculous to me.

00:18:59.760 --> 00:19:00.760
<v Richard>It would just be a terrible choice.

00:19:01.540 --> 00:19:06.060
<v Richard>Because some projects, one language is a good fit for them, and then other projects,

00:19:06.200 --> 00:19:08.100
<v Richard>another language is a better fit for them.

00:19:08.580 --> 00:19:13.080
<v Richard>So I'm comfortable making the claim that I am happy writing rust at zed as my

00:19:13.080 --> 00:19:16.820
<v Richard>day job and i think that's the correct choice for zed and also outside of work

00:19:16.820 --> 00:19:21.960
<v Richard>having the Roc compiler be in Zig and i think that's the right choice for Roc

00:19:21.960 --> 00:19:26.760
<v Richard>compiler so different projects different needs that.

00:19:26.760 --> 00:19:30.880
<v Matthias>Thing that you mentioned with arc clone and making that explicit really like

00:19:30.880 --> 00:19:35.060
<v Matthias>that idea that's that's such a great idea because yeah you show that,

00:19:35.880 --> 00:19:38.880
<v Matthias>Cost of cloning is really low. And of course,

00:19:39.000 --> 00:19:44.160
<v Matthias>you couldn't do that in all places where you had a lot of usages of ARC,

00:19:44.240 --> 00:19:48.940
<v Matthias>but I wondered if you could build a trade extension for that and you had a ARC

00:19:48.940 --> 00:19:52.680
<v Matthias>underscore clone method on the type that was ARC, for example.

00:19:52.860 --> 00:19:57.900
<v Matthias>And then it would be kind of, you know, explicit, but also weirdly strange.

00:19:57.980 --> 00:20:00.700
<v Matthias>So I'm not 100% sure if you want to go down that route.

00:20:00.860 --> 00:20:05.140
<v Richard>But no, that's... I mean, we're probably not going to do that in Zed because

00:20:05.140 --> 00:20:08.660
<v Richard>I mean, the number of places we would have to switch to that is extremely high.

00:20:09.100 --> 00:20:12.340
<v Richard>But yeah, you can call it bump or something. Like you're just bumping the reference

00:20:12.340 --> 00:20:14.620
<v Richard>count. That's actually a really cool idea. I never thought of that.

00:20:14.980 --> 00:20:21.180
<v Matthias>Yeah, nice. So you wrote a lot of Rust code, probably many tens of thousands,

00:20:21.380 --> 00:20:24.760
<v Matthias>maybe hundreds of thousands, maybe millions of lines of code by now. I don't know.

00:20:25.020 --> 00:20:28.980
<v Richard>Probably hundreds of thousands. I don't think millions. I think I'm under 1 million probably.

00:20:29.600 --> 00:20:34.240
<v Richard>So yeah, the Roc compiler at the point where we decided to switch over and

00:20:34.240 --> 00:20:36.720
<v Richard>do the rewrite was at like 300,000 lines of Rust code.

00:20:36.820 --> 00:20:41.120
<v Richard>Now I did not write all 300,000 lines. There's a lot of other contributors involved in that for sure.

00:20:41.520 --> 00:20:45.040
<v Richard>But at the same time, I also wrote a lot of lines that ended up getting deleted

00:20:45.040 --> 00:20:46.400
<v Richard>or rewritten, et cetera.

00:20:46.700 --> 00:20:49.880
<v Richard>So I think between that and my work at Zed, I'm definitely sure it's multiple

00:20:49.880 --> 00:20:51.220
<v Richard>hundreds of thousands of Rust code.

00:20:51.360 --> 00:20:54.960
<v Richard>I also taught a course on Rust. I taught intro to Rust for frontendmasters.com.

00:20:55.200 --> 00:20:58.680
<v Richard>So that was like an eight hour course just teaching people Rust from scratch.

00:20:58.980 --> 00:21:02.800
<v Richard>I've not taught a Zig course there. I did teach a course but

00:21:02.800 --> 00:21:06.460
<v Richard>but yeah so i have a lot of experience hands-on

00:21:06.460 --> 00:21:09.620
<v Richard>in rust a lot a lot of hours with it and also i've taught

00:21:09.620 --> 00:21:13.640
<v Richard>it to beginners which always requires you know learning a little bit of extra

00:21:13.640 --> 00:21:16.600
<v Richard>detail about things where you sort of have these gaps and as soon as you have

00:21:16.600 --> 00:21:19.840
<v Richard>to explain it to someone in depth where they need to understand it you sort

00:21:19.840 --> 00:21:23.240
<v Richard>of immediately realize where the gaps are and kind of have to go fill some of

00:21:23.240 --> 00:21:27.820
<v Richard>them in so yeah i definitely feel comfortable saying i feel like a Rust expert,

00:21:28.060 --> 00:21:32.200
<v Richard>but not a Zig expert yet, I don't think. I've had a lot less time with Zig.

00:21:33.380 --> 00:21:36.400
<v Matthias>Because that kind of leads me to the next question which is

00:21:36.400 --> 00:21:39.900
<v Matthias>with that level of experience some

00:21:39.900 --> 00:21:43.540
<v Matthias>patterns more or less naturally must have evolved and

00:21:43.540 --> 00:21:47.780
<v Matthias>there are probably things that you would call idiomatic rust that maybe are

00:21:47.780 --> 00:21:52.280
<v Matthias>not written down anywhere or maybe are not in the book what what would you say

00:21:52.280 --> 00:21:58.540
<v Matthias>are some things that you would consider ergonomic or rustic code how does it

00:21:58.540 --> 00:22:00.560
<v Matthias>look like what is it like in practice.

00:22:00.560 --> 00:22:04.520
<v Richard>Yeah well i mean the first thing is of course use unsafe as little as possible

00:22:04.520 --> 00:22:06.420
<v Richard>ideally not at all if you can avoid it,

00:22:08.040 --> 00:22:13.600
<v Richard>I guess there's a lot of using traits for things so for example if you can initialize

00:22:13.600 --> 00:22:18.640
<v Richard>something you probably want to use from and into like that's a kind of a standard

00:22:18.640 --> 00:22:22.220
<v Richard>practice in the ecosystem just so you can make the conversions a little bit more ergonomic,

00:22:22.740 --> 00:22:26.080
<v Richard>similarly if you're going to be formatting it as a string then okay maybe you

00:22:26.080 --> 00:22:30.480
<v Richard>want to give it display you probably want to give it debug I think there's a

00:22:30.480 --> 00:22:34.460
<v Richard>lot of trait centric thinking when I'm writing Rust code, like in terms of like

00:22:34.460 --> 00:22:36.820
<v Richard>what traits do I want to implement, even just the baseline.

00:22:38.050 --> 00:22:40.730
<v Richard>Don't write standalone functions in the top level of your

00:22:40.730 --> 00:22:43.490
<v Richard>module prefer to make an impl for the

00:22:43.490 --> 00:22:46.310
<v Richard>particular type and then you know add it

00:22:46.310 --> 00:22:49.410
<v Richard>to there unless you're writing some function that's really not tied

00:22:49.410 --> 00:22:52.510
<v Richard>to any one particular type kind of the default is

00:22:52.510 --> 00:22:55.310
<v Richard>to think in terms of types and in terms of traits and then in terms

00:22:55.310 --> 00:22:58.990
<v Richard>of impl and putting things on there um also like

00:22:58.990 --> 00:23:03.890
<v Richard>pretty straightforward you know to think about doing like

00:23:03.890 --> 00:23:07.090
<v Richard>taking references to things so like you know ampersand or

00:23:07.090 --> 00:23:09.910
<v Richard>ampersand mutt i say mutt people that said usually say mute

00:23:09.910 --> 00:23:13.050
<v Richard>but i don't know i've always said but so no i

00:23:13.050 --> 00:23:16.010
<v Richard>i since my first experience writing rust

00:23:16.010 --> 00:23:18.810
<v Richard>was with other people who you know were doing rust for the first time we

00:23:18.810 --> 00:23:21.750
<v Richard>kind of developed our own like terminology i guess

00:23:21.750 --> 00:23:24.370
<v Richard>or way of pronouncing things and when you're looking at

00:23:24.370 --> 00:23:27.050
<v Richard>other people's code you don't you don't see how they pronounce it but it said

00:23:27.050 --> 00:23:29.910
<v Richard>we pair program a lot i think i'm the only one who says mutt everybody else

00:23:29.910 --> 00:23:36.350
<v Richard>says mute but it's fine which makes sense it's mutable but anyway um so yeah

00:23:36.350 --> 00:23:41.090
<v Richard>So I think another sort of unwritten rule is that you really should try to avoid

00:23:41.090 --> 00:23:43.590
<v Richard>putting references in data structures,

00:23:43.830 --> 00:23:47.890
<v Richard>which is to say you should really try to avoid having lifetime type parameters

00:23:47.890 --> 00:23:49.910
<v Richard>in your structs or what have you.

00:23:50.290 --> 00:23:55.530
<v Richard>This is something that in the ROC code base, like the original one, we did not really do.

00:23:55.670 --> 00:24:00.130
<v Richard>So we kind of took the approach of, well, yeah, I mean, we don't want to have

00:24:00.130 --> 00:24:03.870
<v Richard>allocations for these things. So let's use Bumpalo for all of our arena allocations

00:24:03.870 --> 00:24:07.230
<v Richard>and then store references to either stuff on the arena or stuff...

00:24:07.230 --> 00:24:09.210
<v Richard>I guess, yeah, it always ended up being in the arena.

00:24:09.330 --> 00:24:11.510
<v Richard>It wasn't really on the stack because then the lifetimes wouldn't work out.

00:24:12.170 --> 00:24:14.250
<v Richard>But yeah, so that's another...

00:24:15.400 --> 00:24:18.040
<v Richard>I don't know unwritten rule i guess is and and it's it's not the

00:24:18.040 --> 00:24:20.960
<v Richard>type of thing where you necessarily need a rule because as we discovered

00:24:20.960 --> 00:24:23.900
<v Richard>if you do that the ergonomics end up being

00:24:23.900 --> 00:24:26.600
<v Richard>pretty annoying because you have this like tick a that's just following you

00:24:26.600 --> 00:24:30.240
<v Richard>around everything you write tick a tick a tick a tick a everywhere so

00:24:30.240 --> 00:24:32.980
<v Richard>i would say it's it's not that you can't do that

00:24:32.980 --> 00:24:36.380
<v Richard>in rust but rather that you know you're asking like what's idiomatic i

00:24:36.380 --> 00:24:39.420
<v Richard>think that's that's something that people tend to avoid is having

00:24:39.420 --> 00:24:42.060
<v Richard>life in lifetime annotations be everywhere it's more like if you're going to

00:24:42.060 --> 00:24:45.000
<v Richard>have lifetime annotations you kind of ideally want them to just be confined

00:24:45.000 --> 00:24:47.840
<v Richard>to a function signature rather than sort of leaking out into

00:24:47.840 --> 00:24:51.220
<v Richard>your data structures and that's kind of i guess a lot of people will solve that

00:24:51.220 --> 00:24:54.560
<v Richard>by using like reference counting or things like that or interior mutability

00:24:54.560 --> 00:24:57.780
<v Richard>or something like that of course at that point as soon as you get into like

00:24:57.780 --> 00:25:00.200
<v Richard>cell and things like that it's sort of like well if you make a mistake then

00:25:00.200 --> 00:25:03.100
<v Richard>now you're potentially you know dealing with a runtime panic which is not great

00:25:03.100 --> 00:25:05.380
<v Richard>or or else having to do all these conditional things.

00:25:05.640 --> 00:25:11.820
<v Richard>So yeah, we did a lot of that and I think kind of learned the hard way that

00:25:11.820 --> 00:25:15.760
<v Richard>that's something that you should probably avoid when you're writing Rust code

00:25:15.760 --> 00:25:18.740
<v Richard>is having lifetime annotations in your structs, like your data structures.

00:25:19.400 --> 00:25:21.920
<v Richard>What else? Yeah, I mean, I guess in general...

00:25:22.790 --> 00:25:25.590
<v Richard>Try to avoid boxing and you know doing

00:25:25.590 --> 00:25:28.590
<v Richard>things on the heap but i would say rust is

00:25:28.590 --> 00:25:31.490
<v Richard>less hardcore about avoiding those

00:25:31.490 --> 00:25:34.170
<v Richard>things than something like c or Zig is so if you look at

00:25:34.170 --> 00:25:37.930
<v Richard>like the lowest level c operating system apis c really

00:25:37.930 --> 00:25:40.790
<v Richard>really like the operating system is is really not going to

00:25:40.790 --> 00:25:44.130
<v Richard>be calling malloc for you like almost ever it's really

00:25:44.130 --> 00:25:47.210
<v Richard>going to be a lot more doing things like okay you need

00:25:47.210 --> 00:25:50.010
<v Richard>to pass in what in rust would be the equivalent of like a

00:25:50.010 --> 00:25:53.070
<v Richard>mutable reference to something where you're saying like give me

00:25:53.070 --> 00:25:56.030
<v Richard>a pointer to this data that you've already pre-initialized and

00:25:56.030 --> 00:25:58.770
<v Richard>also tell me how much you know how many bytes i have to

00:25:58.770 --> 00:26:01.830
<v Richard>work with i'm going to write into there like the the caller says

00:26:01.830 --> 00:26:05.250
<v Richard>here's some memory that i've you know in rust this would be like maybe uninit

00:26:05.250 --> 00:26:09.550
<v Richard>basically and it's like hey give me give me some data i'm gonna you know write

00:26:09.550 --> 00:26:12.470
<v Richard>to it and then i'm gonna give it back to you you know i'm gonna return back

00:26:12.470 --> 00:26:15.430
<v Richard>to you and don't worry the data has been written there and i'll tell you how

00:26:15.430 --> 00:26:19.730
<v Richard>many bytes i wrote into there that's a really common idiom that you see in C,

00:26:19.870 --> 00:26:22.270
<v Richard>at least in low-level operating system type code.

00:26:22.530 --> 00:26:25.470
<v Richard>Whereas in Rust, it would tend to be the opposite. It would be more like,

00:26:25.570 --> 00:26:27.990
<v Richard>no, no, don't worry. I'm just going to take care of that for you.

00:26:28.270 --> 00:26:31.350
<v Richard>There might be some API that's like, give me a mutable reference to something

00:26:31.350 --> 00:26:35.310
<v Richard>and I'll write into it, but that's a lot less common in Rust. So.

00:26:36.100 --> 00:26:38.920
<v Richard>There's a pro and con there on the one hand the apis and rust

00:26:38.920 --> 00:26:41.920
<v Richard>tend to be nicer looking i would say they look a little bit more

00:26:41.920 --> 00:26:44.660
<v Richard>dare i say functional in some

00:26:44.660 --> 00:26:47.760
<v Richard>cases where you're like i'm gonna call this it's gonna do some heap allocation

00:26:47.760 --> 00:26:50.600
<v Richard>with the global allocator and then return you know a string

00:26:50.600 --> 00:26:54.700
<v Richard>or a vec or whatever whereas in c it's more like yeah give me a buffer and it's

00:26:54.700 --> 00:26:57.180
<v Richard>like well what if the buffer is not big enough it's like well then you're probably

00:26:57.180 --> 00:26:59.600
<v Richard>gonna have to call me again and i'll fill in the rest of the buffer after you

00:26:59.600 --> 00:27:03.260
<v Richard>resize it for me or something like that so you don't tend to see that type of

00:27:03.260 --> 00:27:09.980
<v Richard>thing in rust it tends to be more open to doing silent allocations than than see your Zig now.

00:27:09.980 --> 00:27:14.980
<v Matthias>From experience i know that quite a few people that i would deem to be experts

00:27:14.980 --> 00:27:19.520
<v Matthias>in rust or very experienced are pretty lightweight on design patterns for some

00:27:19.520 --> 00:27:25.700
<v Matthias>reason and i wonder if you also saw that in working with larger code bases and

00:27:25.700 --> 00:27:28.780
<v Matthias>where you stand on that side of the spectrum.

00:27:28.960 --> 00:27:33.440
<v Matthias>So do you use a lot of design patterns in your code or are you also just like

00:27:33.440 --> 00:27:37.680
<v Matthias>leaning into what you mentioned, structs, traits, and combining those?

00:27:37.900 --> 00:27:42.540
<v Matthias>And do the design patterns evolve more or less naturally for you or is it something

00:27:42.540 --> 00:27:44.580
<v Matthias>that you consciously think about when you write code?

00:27:45.200 --> 00:27:48.660
<v Richard>So let's be a little bit more specific. When you say design patterns,

00:27:48.700 --> 00:27:52.700
<v Richard>are you thinking about sort of the concept as in like, you know,

00:27:53.360 --> 00:27:57.060
<v Richard>patterns of design that come up like, you know, techniques and things like that?

00:27:57.240 --> 00:28:00.460
<v Richard>I mean, of course, in that sense, I would just call those, I don't know,

00:28:00.560 --> 00:28:01.600
<v Richard>idioms or something like that.

00:28:01.860 --> 00:28:05.500
<v Richard>Usually when I think design patterns, I'm thinking like Gang of Four,

00:28:05.760 --> 00:28:09.100
<v Richard>observer pattern, you know, things like that, visitor pattern and whatnot.

00:28:09.100 --> 00:28:12.500
<v Richard>So certainly I'm not thinking in terms of gang of four stuff.

00:28:12.760 --> 00:28:15.940
<v Richard>Like I did a lot of enterprise Java early on in my career.

00:28:16.400 --> 00:28:21.380
<v Richard>And that based on that experience, I've kind of, I don't know,

00:28:21.780 --> 00:28:26.380
<v Richard>sampled the object oriented style and I've sampled the functional style and

00:28:26.380 --> 00:28:29.520
<v Richard>I've sampled the imperative procedural, not object oriented style,

00:28:29.700 --> 00:28:32.440
<v Richard>which is what I would put Rust and Zig in that category.

00:28:32.840 --> 00:28:37.960
<v Richard>And my conclusion is that imperative procedural is fine. Functional is fine. Yeah.

00:28:38.490 --> 00:28:43.070
<v Richard>Object-oriented is a mistake i i i've been trying to sugarcoat that more and more over the years,

00:28:43.990 --> 00:28:47.190
<v Richard>trying to be diplomatic about it but for the purposes of this podcast i'm just

00:28:47.190 --> 00:28:49.910
<v Richard>going to say yeah i don't think any of that was the right direction i think

00:28:49.910 --> 00:28:53.770
<v Richard>it's going to turn out to be a dead end in programming that you know people

00:28:53.770 --> 00:28:56.210
<v Richard>are going to look back on as like that was the thing that people used to do

00:28:56.210 --> 00:29:00.490
<v Richard>i don't think that's the future of programming so yeah i i'm happy to have moved past that.

00:29:00.490 --> 00:29:05.550
<v Matthias>Oh that's interesting because you use different ways to encapsulate code then

00:29:05.550 --> 00:29:11.470
<v Matthias>And you use namespaces and modules and freestanding functions to group that logic.

00:29:11.690 --> 00:29:17.470
<v Matthias>But don't you still need some way to hold state, like structs or things where

00:29:17.470 --> 00:29:23.230
<v Matthias>you can maintain some sort of order of the events that come in,

00:29:23.290 --> 00:29:24.930
<v Matthias>like as in an actor system or so?

00:29:25.750 --> 00:29:28.850
<v Matthias>It's kind of a pretty bold statement to say OOP was a mistake.

00:29:29.290 --> 00:29:30.470
<v Matthias>What's the alternative then?

00:29:30.690 --> 00:29:34.610
<v Richard>Well, it depends on who you ask, right? So if you talk to some of the like Casey

00:29:34.610 --> 00:29:37.930
<v Richard>Muratori and Jonathan Blow and people like them who do a lot of like high performance

00:29:37.930 --> 00:29:39.810
<v Richard>game dev saying OO it was a mistake.

00:29:39.910 --> 00:29:42.470
<v Richard>Is there just like, yeah, so let's talk about something interesting.

00:29:42.630 --> 00:29:44.910
<v Richard>You know, like we know we've known this for a very long time.

00:29:45.900 --> 00:29:49.400
<v Richard>Yes. In the broader programming world, I agree that it's a bold statement,

00:29:49.400 --> 00:29:51.780
<v Richard>but there are quite a lot of people who are just like, yeah,

00:29:51.920 --> 00:29:54.220
<v Richard>of course it's, it's not controversial at all.

00:29:54.340 --> 00:29:57.460
<v Richard>So yeah, I mean, like you mentioned encapsulation. So for example,

00:29:57.680 --> 00:30:02.500
<v Richard>encapsulation is a special case of modularity. So modularity is the idea of the boundary.

00:30:02.660 --> 00:30:06.060
<v Richard>It's like saying it's just pub and private, right? Public and private interface.

00:30:06.260 --> 00:30:08.760
<v Richard>So you can say like, here are the things that I'm exposing. Here are the things

00:30:08.760 --> 00:30:09.960
<v Richard>that I'm intentionally not exposing.

00:30:10.420 --> 00:30:14.340
<v Richard>Nobody outside my module can access my private things encapsulation just

00:30:14.340 --> 00:30:17.440
<v Richard>means modularity but in an object-oriented context

00:30:17.440 --> 00:30:20.560
<v Richard>it's like modularity applied to classes and objects

00:30:20.560 --> 00:30:23.460
<v Richard>well if you don't have classes and objects and you just got like

00:30:23.460 --> 00:30:26.080
<v Richard>you said structs and rust like modularity is

00:30:26.080 --> 00:30:28.860
<v Richard>fine you can you know all we're talking about there is just like

00:30:28.860 --> 00:30:31.840
<v Richard>did i decide to make this field on my struct pub

00:30:31.840 --> 00:30:34.820
<v Richard>or not right everything just sort of follows from

00:30:34.820 --> 00:30:37.900
<v Richard>that it's the very basic thing of saying i'm intentionally hiding

00:30:37.900 --> 00:30:40.720
<v Richard>these implementation details and the reason that i'm hiding these

00:30:40.720 --> 00:30:43.620
<v Richard>implementation details is that for example i'm trying

00:30:43.620 --> 00:30:47.100
<v Richard>to create an invariant that i want to be enforced by the compiler like

00:30:47.100 --> 00:30:50.140
<v Richard>i want to make sure that nobody is you know reaching in and messing with these internals because

00:30:50.140 --> 00:30:54.100
<v Richard>if they did it would violate my assumptions and i want to really hardcore communicate

00:30:54.100 --> 00:30:58.220
<v Richard>that by giving anyone who tries to do that a compiler error or i might be making

00:30:58.220 --> 00:31:02.160
<v Richard>a library and i might want to say i want to have really strong backwards compatibility

00:31:02.160 --> 00:31:05.460
<v Richard>guarantees but i might want to change the internal structure of this same thing

00:31:05.460 --> 00:31:07.440
<v Richard>right i'm going to make these things pub and these things private.

00:31:08.620 --> 00:31:13.220
<v Richard>That's all it is that's that's modularity and then encapsulation is just modularity

00:31:13.220 --> 00:31:17.560
<v Richard>but i'm specifically talking about modularity at the level of a class and since

00:31:17.560 --> 00:31:21.720
<v Richard>Rust doesn't have classes i would argue that technically speaking Rust doesn't

00:31:21.720 --> 00:31:23.760
<v Richard>have encapsulation Rust just has modularity,

00:31:24.540 --> 00:31:27.600
<v Richard>somebody might but people use these terms pretty interchangeably i think in

00:31:27.600 --> 00:31:31.280
<v Richard>a lot of cases like a lot of people well first of all even though the term modularity

00:31:31.280 --> 00:31:33.980
<v Richard>i think might have come first i don't know now we're getting back into like

00:31:33.980 --> 00:31:38.600
<v Richard>alan k coined the term object oriented in the 70s and you know nicholas virz

00:31:38.600 --> 00:31:43.260
<v Richard>was working on modula also in the 70s i'm not sure exactly.

00:31:44.200 --> 00:31:49.300
<v Richard>Which term technically came first, but certainly the term encapsulation is more popular today.

00:31:49.500 --> 00:31:53.300
<v Richard>So I think that's what more people associate with that boundary system.

00:31:53.440 --> 00:31:56.260
<v Richard>But I think it's worth noting that from a historical perspective,

00:31:57.080 --> 00:32:00.620
<v Richard>modularity is the thing that everybody seems to agree that they want now.

00:32:01.060 --> 00:32:04.400
<v Richard>Literally right now, I think on Hacker News yesterday or the day before,

00:32:04.600 --> 00:32:08.960
<v Richard>there was a front page article about modules in C++ and when are they coming?

00:32:09.200 --> 00:32:12.180
<v Richard>So an observation i would make is that every language

00:32:12.180 --> 00:32:15.040
<v Richard>that just had encapsulation just to say the only way

00:32:15.040 --> 00:32:17.820
<v Richard>to do public and private was at the class boundary every single

00:32:17.820 --> 00:32:21.180
<v Richard>one of them has ended up wanting a module system every

00:32:21.180 --> 00:32:23.900
<v Richard>i should say every popular one okay like i'm sure

00:32:23.900 --> 00:32:26.660
<v Richard>there's some you know obscure languages that don't have it i'm sure small talk

00:32:26.660 --> 00:32:29.840
<v Richard>will never you know consider adding a module system but but i

00:32:29.840 --> 00:32:32.680
<v Richard>mean c++ java right like all these languages have

00:32:32.680 --> 00:32:35.340
<v Richard>ended up having some separate mechanism so it's like actually we don't

00:32:35.340 --> 00:32:39.140
<v Richard>want only to be able to do that through classes and that

00:32:39.140 --> 00:32:42.040
<v Richard>makes sense modules are a really nice idea but the question becomes if

00:32:42.040 --> 00:32:45.480
<v Richard>you have public and private at the module level do

00:32:45.480 --> 00:32:48.460
<v Richard>you also need a separate class thing which

00:32:48.460 --> 00:32:51.660
<v Richard>also has its own public and private or is module level sufficient and it seems

00:32:51.660 --> 00:32:55.460
<v Richard>to me to be the case that module level turned out to be you know sufficient

00:32:55.460 --> 00:33:01.780
<v Richard>and you know Rust is an example of a language that does not have objects does

00:33:01.780 --> 00:33:06.920
<v Richard>not have classes unless you want to count like you know whatever din objects dyn you.

00:33:07.680 --> 00:33:11.120
<v Richard>Like trade objects and stuff like that but that's just the name they chose for

00:33:11.120 --> 00:33:14.000
<v Richard>that that's not like they are not objects in the object oriented sense they

00:33:14.000 --> 00:33:17.320
<v Richard>don't have classes they don't have inheritance or any of that stuff so yeah

00:33:17.320 --> 00:33:22.400
<v Richard>I don't know I don't want to get too far in the weeds on that but I guess to sum it up I would say that.

00:33:22.920 --> 00:33:26.480
<v Richard>Actually, I gave a whole talk on this. I gave multiple talks on the subject

00:33:26.480 --> 00:33:30.420
<v Richard>of object-oriented and whatnot, but I gave one called The Next Paradigm Shift

00:33:30.420 --> 00:33:33.380
<v Richard>in Programming and also The Return of Procedural Programming.

00:33:33.500 --> 00:33:39.260
<v Richard>The Return of Procedural Programming is a very on-the-nose talk about OO got really big.

00:33:39.380 --> 00:33:44.100
<v Richard>If you look at what are the biggest new languages that have come out that are

00:33:44.100 --> 00:33:46.560
<v Richard>getting popular, they break down into two categories.

00:33:46.920 --> 00:33:50.100
<v Richard>One is they're just a plus-plus version

00:33:50.100 --> 00:33:53.360
<v Richard>of an already popular language so for example kotlin is basically

00:33:53.360 --> 00:33:56.360
<v Richard>java plus plus it's like they took java and then intentionally have

00:33:56.360 --> 00:33:59.660
<v Richard>seamless java interop and so you

00:33:59.660 --> 00:34:02.560
<v Richard>could not possibly make a language that has seamless java interop without having

00:34:02.560 --> 00:34:06.720
<v Richard>it be object-oriented because java is extremely object-oriented but if

00:34:06.720 --> 00:34:09.720
<v Richard>you look at if you exclude those and say like languages that are not coupled

00:34:09.720 --> 00:34:12.400
<v Richard>to an existing already popular language what are

00:34:12.400 --> 00:34:15.180
<v Richard>the greenfield languages like and there's only two

00:34:15.180 --> 00:34:18.040
<v Richard>there's rust and there's go those are the two languages that

00:34:18.040 --> 00:34:21.260
<v Richard>are getting popular that are greenfield not based on

00:34:21.260 --> 00:34:24.660
<v Richard>and coupled to an existing already popular language and neither

00:34:24.660 --> 00:34:28.040
<v Richard>of them are object-oriented at all they're just procedural languages and

00:34:28.040 --> 00:34:31.400
<v Richard>that's hence the title of the talk the return of procedural programming so

00:34:31.400 --> 00:34:34.880
<v Richard>if someone wants to make the case that object orientation is the future you

00:34:34.880 --> 00:34:38.060
<v Richard>might want to ask why is it that the only new popular object-oriented languages

00:34:38.060 --> 00:34:42.340
<v Richard>that are coming out and gaining actual traction in the real world why are they

00:34:42.340 --> 00:34:47.720
<v Richard>all coupled to legacy object-oriented languages and nobody's making new object-oriented

00:34:47.720 --> 00:34:49.640
<v Richard>languages from scratch that are seeing popularity.

00:34:50.920 --> 00:34:56.580
<v Matthias>I can get behind that. Never seen it this way, but the way you explained it makes a lot of sense.

00:34:56.860 --> 00:34:59.760
<v Matthias>We will link those talks in the show notes.

00:35:00.200 --> 00:35:06.560
<v Matthias>I guess Rust kind of found a nice balance there because that's also somewhat

00:35:06.560 --> 00:35:08.680
<v Matthias>what I consider idiomatic, Rust,

00:35:08.980 --> 00:35:16.860
<v Matthias>to make use of separate input blocks, to make use of composability with traits and so on.

00:35:16.980 --> 00:35:21.520
<v Matthias>And you don't always need trade objects and that sort of thing.

00:35:22.590 --> 00:35:27.310
<v Matthias>Ensure a lot of things that compile time and make it still composable right and still have,

00:35:27.870 --> 00:35:30.890
<v Matthias>all the ways to do different

00:35:30.890 --> 00:35:33.730
<v Matthias>kinds of visibility at your disposal you can have

00:35:33.730 --> 00:35:38.550
<v Matthias>pop you can have pop crate you can have public modules and so on so that's it's

00:35:38.550 --> 00:35:42.790
<v Matthias>pretty cool i'm sure we could talk about this for a long time but i would like

00:35:42.790 --> 00:35:48.210
<v Matthias>to shift gears too the first time where you noticed that Rust might not have

00:35:48.210 --> 00:35:51.230
<v Matthias>been the right choice for the language that you were building.

00:35:52.190 --> 00:35:58.610
<v Matthias>What was the first time when you noticed, well, no, I need to think about an alternative to Rust?

00:35:59.590 --> 00:36:07.270
<v Richard>That's very easy. We talked early on about how a big part of programming language UX is compile times.

00:36:07.690 --> 00:36:11.790
<v Richard>They got slow. When we had a small Rust code base, their compile times were

00:36:11.790 --> 00:36:13.030
<v Richard>fine. Everything was nice and snappy.

00:36:13.370 --> 00:36:15.790
<v Richard>And as it got bigger and bigger, they got slower and slower.

00:36:15.790 --> 00:36:18.150
<v Richard>And now they're just quite slow.

00:36:18.570 --> 00:36:22.170
<v Richard>I just did this morning. I did a scratch build of the Rust code base and it

00:36:22.170 --> 00:36:27.610
<v Richard>took like 30-40 seconds somewhere in there and a rebuild still took about 10

00:36:27.610 --> 00:36:31.610
<v Richard>seconds and in contrast our Zig project,

00:36:31.730 --> 00:36:34.650
<v Richard>which granted this is apples and oranges. The Rust code base is like 300,000 lines.

00:36:34.750 --> 00:36:37.070
<v Richard>A Zig rewrite is currently at about 100,000 lines.

00:36:37.910 --> 00:36:43.550
<v Richard>The scratch build of the Zig one was like 13 seconds or something like that and then the,

00:36:44.450 --> 00:36:50.770
<v Richard>the incremental rebuild was like 1.3 seconds. Now that's worth noting that that's

00:36:50.770 --> 00:36:54.770
<v Richard>going to get much, much faster in the future because I'm working on an ARM64 Mac.

00:36:55.350 --> 00:36:59.690
<v Richard>Zig has an alternative backend to LLVM, but it's only X64 right now.

00:36:59.770 --> 00:37:02.590
<v Richard>The ARM one is still a work in progress. It hasn't shipped yet. It's not stable.

00:37:03.410 --> 00:37:08.270
<v Richard>And once it does, then that 1.3 second rebuild is going to get much smaller still.

00:37:08.570 --> 00:37:12.370
<v Richard>And also Zig still doesn't have full, like they have not fully realized their

00:37:12.370 --> 00:37:16.130
<v Richard>goals in terms of incremental rebuilds, whereas Rust, I would say,

00:37:16.290 --> 00:37:19.530
<v Richard>has at this point based on the constraints of the language with crates being

00:37:19.530 --> 00:37:21.770
<v Richard>the smallest compilation unit rather than individual files.

00:37:23.090 --> 00:37:27.630
<v Richard>So given all of that, it's already the case that we're seeing a much bigger

00:37:27.630 --> 00:37:31.370
<v Richard>gap between Zig and Rust than sort of linear in terms of lines of code.

00:37:31.510 --> 00:37:35.410
<v Richard>Like if all those being equal, Rust code bases, you know, 300,000 lines versus

00:37:35.410 --> 00:37:39.050
<v Richard>Zig one being 100,000 lines, you would think that the Zig one would be maybe

00:37:39.050 --> 00:37:43.090
<v Richard>three times faster, but not 10 times faster for like incremental rebuilds.

00:37:43.410 --> 00:37:46.390
<v Richard>And also, it's not just that it's already 10 times faster, which it is,

00:37:46.870 --> 00:37:52.930
<v Richard>it's one-tenth the incremental compilation time, but also that it's going to

00:37:52.930 --> 00:37:57.230
<v Richard>get much faster in an upcoming release, like probably the next one after the current release.

00:37:57.910 --> 00:38:01.030
<v Richard>When I'm assuming the ARM64 one's going to ship, and actually people who are

00:38:01.030 --> 00:38:06.090
<v Richard>working on the raw compiler in x64 processors are already benefiting from that

00:38:06.090 --> 00:38:08.750
<v Richard>much faster compilation time because that one already has shipped.

00:38:08.750 --> 00:38:11.950
<v Richard>So meanwhile like on

00:38:11.950 --> 00:38:15.430
<v Richard>the rust side i mean lvm is a very very known culprit

00:38:15.430 --> 00:38:18.410
<v Richard>for making slow builds and unfortunately you

00:38:18.410 --> 00:38:21.450
<v Richard>have to you can't just you know do like check like cargo

00:38:21.450 --> 00:38:24.890
<v Richard>check you know that's not the whole thing you want to run your tests and in

00:38:24.890 --> 00:38:28.590
<v Richard>order to run your tests you have to do code generation and that requires lvm

00:38:28.590 --> 00:38:33.490
<v Richard>in rust there is a crane lift back then but i'm not kidding when i started Roc

00:38:33.490 --> 00:38:35.730
<v Richard>wrote the first lines of code the

00:38:35.730 --> 00:38:39.230
<v Richard>crane lift back in for rust was work in progress, it still hasn't landed.

00:38:39.900 --> 00:38:46.040
<v Richard>So that was 2019. And maybe it's right around the corner, but I can only hold

00:38:46.040 --> 00:38:47.000
<v Richard>my breath through so long.

00:38:48.240 --> 00:38:54.500
<v Matthias>Yeah. And I guess you probably used all the tricks at your disposal to make it faster.

00:38:54.760 --> 00:38:57.860
<v Matthias>You probably went through a lot of tutorials and tried a few things.

00:38:58.300 --> 00:39:02.140
<v Matthias>It's probably optimized to the max by now, the Rust code that is.

00:39:02.680 --> 00:39:05.580
<v Richard>I wouldn't say we went all the way to the max. We certainly tried a lot of things.

00:39:05.720 --> 00:39:08.460
<v Richard>So like the really obvious one that everybody says, oh, just try mold.

00:39:08.460 --> 00:39:11.480
<v Richard>And said mold made no difference whatsoever for us i mean we like

00:39:11.480 --> 00:39:14.240
<v Richard>we didn't even bother enabling on ci because we had people who are

00:39:14.240 --> 00:39:16.880
<v Richard>using like daily driving linux and like oh let's try it

00:39:16.880 --> 00:39:20.860
<v Richard>out they're like i mean it's a little faster like

00:39:20.860 --> 00:39:23.660
<v Richard>you know mold for linking we tried splitting up

00:39:23.660 --> 00:39:26.340
<v Richard>our crates along more boundaries etc i mean

00:39:26.340 --> 00:39:29.100
<v Richard>really the the overall feeling that we

00:39:29.100 --> 00:39:32.020
<v Richard>ended up having was that even if we

00:39:32.020 --> 00:39:35.140
<v Richard>do like use all the maximum number of tricks and

00:39:35.140 --> 00:39:38.460
<v Richard>and try to like contort the code base around just the number

00:39:38.460 --> 00:39:41.840
<v Richard>one goal is trying to get it to build as fast as possible it's

00:39:41.840 --> 00:39:45.960
<v Richard>just still not going to be anywhere near as fast as Zig is building i mean the

00:39:45.960 --> 00:39:50.360
<v Richard>Zig team is in the progress of working towards hot code reloading where like

00:39:50.360 --> 00:39:54.780
<v Richard>you make a you're running your Zig program and while it's running you make it

00:39:54.780 --> 00:39:58.620
<v Richard>you know you save and it's like instantly updated with the running program.

00:39:59.780 --> 00:40:02.500
<v Richard>That's i i it's inconceivable to me

00:40:02.500 --> 00:40:05.300
<v Richard>that Rust would ever have that like in my lifetime i'm not saying it's

00:40:05.300 --> 00:40:08.820
<v Richard>impossible i'm just saying that just based on

00:40:08.820 --> 00:40:11.840
<v Richard>the i don't know the way things are organized right now

00:40:11.840 --> 00:40:15.020
<v Richard>and i've talked with a lot of people in the rust project about compile

00:40:15.020 --> 00:40:17.960
<v Richard>times there are definitely some heroes who are like really trying

00:40:17.960 --> 00:40:21.000
<v Richard>to fight the good fight you know and trying to make like

00:40:21.000 --> 00:40:24.080
<v Richard>compile times a major priority but unfortunately it

00:40:24.080 --> 00:40:27.000
<v Richard>really it feels like that's not

00:40:27.000 --> 00:40:29.840
<v Richard>the majority view right now it's it's the majority view is

00:40:29.840 --> 00:40:33.000
<v Richard>not that compile times are a major priority or

00:40:33.000 --> 00:40:36.820
<v Richard>need to be a major priority or maybe it's that people think

00:40:36.820 --> 00:40:40.680
<v Richard>that they should be a priority but their ambitions for how much of an improvement

00:40:40.680 --> 00:40:44.940
<v Richard>they think are possible is way below what the what the ambition level is for

00:40:44.940 --> 00:40:49.760
<v Richard>Zig like when i talk to Rust core team members i've told them this so this is

00:40:49.760 --> 00:40:54.960
<v Richard>not i'm not you know i'm not saying anything here that I haven't said to people who work on Rust.

00:40:55.810 --> 00:41:00.730
<v Richard>When I talk to them about the compile time situation, the response that I usually

00:41:00.730 --> 00:41:04.690
<v Richard>get is something along the lines of, here's why it's really hard to make it faster.

00:41:05.130 --> 00:41:09.750
<v Richard>When I talk to Zig people about compile times, it's the exact opposite.

00:41:09.890 --> 00:41:14.170
<v Richard>They're like, I'm so sorry that it's not already as fast as the hardware could possibly make it be.

00:41:15.070 --> 00:41:19.470
<v Richard>We're working really, really hard on making it be that whatever your hardware

00:41:19.470 --> 00:41:23.910
<v Richard>is, we're using it to the maximum extent to give you the absolute lightning fast compile times.

00:41:23.910 --> 00:41:28.510
<v Richard>The attitude difference is just totally night and day and this was something that i picked up on,

00:41:29.130 --> 00:41:32.150
<v Richard>ever since i met andrew kelly who created Zig at a conference is

00:41:32.150 --> 00:41:35.150
<v Richard>just there's this big attitude difference in

00:41:35.150 --> 00:41:38.150
<v Richard>terms of how important compile times

00:41:38.150 --> 00:41:41.150
<v Richard>are to the roadmap every year i fill out the rust state of

00:41:41.150 --> 00:41:44.870
<v Richard>rust survey and you know i'm outing myself

00:41:44.870 --> 00:41:47.550
<v Richard>you know whatever somebody reads that they could tell who if it's me you

00:41:47.550 --> 00:41:50.410
<v Richard>know even if i didn't put my name on it like they ask about

00:41:50.410 --> 00:41:53.450
<v Richard>oh do you want this feature do you want that thing stabilized you want this that every year

00:41:53.450 --> 00:41:56.610
<v Richard>i'm just like i don't care i don't care i don't care i don't care just make it faster all

00:41:56.610 --> 00:41:59.290
<v Richard>i care is compile times i don't care if this gets stabilized or that

00:41:59.290 --> 00:42:02.770
<v Richard>gets stabilized or this is available in language everything in rust is already

00:42:02.770 --> 00:42:07.130
<v Richard>like from a feature perspective fine like all these little like oh what if what

00:42:07.130 --> 00:42:10.170
<v Richard>if you have like async functions i'm like i don't care i'll just put them in

00:42:10.170 --> 00:42:13.510
<v Richard>the block it's fine like i make an async block of closure it's like i don't

00:42:13.510 --> 00:42:18.610
<v Richard>i don't care i just care about i want the compile times to be a lot a lot a lot lower than they are,

00:42:19.090 --> 00:42:24.350
<v Richard>but of course I don't seem to be in the majority on that in terms of Rust users

00:42:24.350 --> 00:42:27.310
<v Richard>either it seems like to be totally honest a lot of Rust users.

00:42:28.130 --> 00:42:31.950
<v Richard>Are okay with the compile times being the way they are and maybe that's because

00:42:31.950 --> 00:42:35.110
<v Richard>they're working on smaller code bases I don't know or maybe it's because,

00:42:35.730 --> 00:42:39.450
<v Richard>they're coming from like a Java or a C++ background and they're not they're

00:42:39.450 --> 00:42:43.650
<v Richard>like what's the problem but coming from an Elm background and also now you know

00:42:43.650 --> 00:42:48.150
<v Richard>having experienced like Zig compile times I'm like I just I don't,

00:42:48.690 --> 00:42:53.430
<v Richard>I can't not be bothered by it a lot, all the time, like knowing what's possible.

00:42:54.030 --> 00:42:57.950
<v Richard>So yeah, I don't know. I've ranted on my podcast, which is software unscripted,

00:42:58.030 --> 00:43:00.530
<v Richard>by the way, a lot about Rust compile times.

00:43:01.390 --> 00:43:04.490
<v Richard>We were thinking about a rewrite anyway. I don't know that if we would have

00:43:04.490 --> 00:43:07.710
<v Richard>like seriously discussed doing it in Zig if Rust compile times were fast.

00:43:07.790 --> 00:43:09.310
<v Richard>I think we would have just been like, no, we're going to rewrite,

00:43:09.390 --> 00:43:10.550
<v Richard>but we're going to rewrite it in Rust again.

00:43:11.830 --> 00:43:16.790
<v Matthias>Okay. I'm probably in the camp where compile times are not that big of a problem

00:43:16.790 --> 00:43:23.250
<v Matthias>for me nowadays it used to be a problem and then two things happened first modern

00:43:23.250 --> 00:43:29.090
<v Matthias>arm hardware is pretty decent at compiling Rust so you have m4 and it's it's

00:43:29.090 --> 00:43:30.630
<v Matthias>much better than it used to be,

00:43:31.330 --> 00:43:34.290
<v Matthias>and the other part was the Rust compiler did

00:43:34.290 --> 00:43:37.070
<v Matthias>actually get faster since 1.0 i hear that

00:43:37.070 --> 00:43:40.470
<v Matthias>a lot from people that come from functional programming and

00:43:40.470 --> 00:43:43.390
<v Matthias>from game dev for people that need fast

00:43:43.390 --> 00:43:46.250
<v Matthias>feedback loops because this is kind of

00:43:46.250 --> 00:43:49.930
<v Matthias>a development model that doesn't really fit well

00:43:49.930 --> 00:43:52.830
<v Matthias>or perfectly well right now with rust i feel like

00:43:52.830 --> 00:43:59.270
<v Matthias>if i were to write a game from scratch i would also be cautious to maybe use

00:43:59.270 --> 00:44:05.510
<v Matthias>rust or not i wouldn't be sure but is that true like does that ring true to

00:44:05.510 --> 00:44:10.110
<v Matthias>you where you say it's because of your background maybe even before using Rust,

00:44:10.330 --> 00:44:14.390
<v Matthias>you learned that there's a different way to build software.

00:44:15.210 --> 00:44:21.270
<v Richard>I certainly think that the degree to which compile times bother you would depend,

00:44:21.610 --> 00:44:26.770
<v Richard>sort of obviously, on what you're used to and what you, I don't know,

00:44:26.850 --> 00:44:28.530
<v Richard>think of as sort of possible or normal.

00:44:29.420 --> 00:44:32.500
<v Richard>Like if I'm used to Elm and like, you know, sub second, you know,

00:44:32.920 --> 00:44:36.340
<v Richard>recompiles and stuff like that, then yeah, I mean, it's going to bother me when

00:44:36.340 --> 00:44:40.280
<v Richard>I'm waiting 10 seconds, you know, to, to be able to build my thing or to run my tests.

00:44:41.140 --> 00:44:45.100
<v Richard>Similarly, I mean, like at Zed, it's, it's just really obvious.

00:44:45.100 --> 00:44:49.340
<v Richard>Like the classic example of the, the really obvious pain point here is I'm like,

00:44:49.440 --> 00:44:54.520
<v Richard>I just need to scoot this thing over by two pixels because it's a little bit off.

00:44:54.660 --> 00:44:58.180
<v Richard>I just need to make a little tweak here and I'm just sitting there waiting for

00:44:58.180 --> 00:45:02.240
<v Richard>that. I'm like, if I were using a browser, JavaScript or something like that,

00:45:02.680 --> 00:45:07.200
<v Richard>I wouldn't even need to think about this. I would just be like, refresh the page.

00:45:07.560 --> 00:45:11.060
<v Richard>Now, granted, in modern front-end development, a lot of people have TypeScript

00:45:11.060 --> 00:45:14.400
<v Richard>and Next.js and this and that, but those are self-inflicted wounds.

00:45:14.420 --> 00:45:16.600
<v Richard>You have the option to not do that to yourself.

00:45:16.900 --> 00:45:20.920
<v Richard>In Rust, there is no such option, as far as I'm aware. There's no way to say,

00:45:21.040 --> 00:45:22.260
<v Richard>I have this big Rust code base.

00:45:22.740 --> 00:45:26.700
<v Richard>I'm just making this small tweak to this one thing. I think if you wanted to

00:45:26.700 --> 00:45:31.480
<v Richard>do something like that, But you would probably need to, I don't know,

00:45:31.620 --> 00:45:36.380
<v Richard>do something like reorganize, like really aggressively reorganize your crates

00:45:36.380 --> 00:45:40.860
<v Richard>in a way where you can try to just make it so that, I don't know,

00:45:40.920 --> 00:45:42.460
<v Richard>the caching works out or something like that.

00:45:42.740 --> 00:45:46.860
<v Richard>I mean, we've tried to do some of that at Zed, obviously, because compile times are such a pain point.

00:45:47.040 --> 00:45:52.060
<v Richard>But yeah, if you need to make a change to something deep in the bowels of our

00:45:52.060 --> 00:45:54.620
<v Richard>code base, it's always going to be super slow.

00:45:54.700 --> 00:45:57.160
<v Richard>Something that's dependent on by lots of things. there's just no way to get

00:45:57.160 --> 00:46:00.960
<v Richard>it to be fast whereas again like if you have a giant javascript code base not

00:46:00.960 --> 00:46:03.640
<v Richard>typescript you know where you have to do the builds and everything but just

00:46:03.640 --> 00:46:06.780
<v Richard>have a you know giant vanilla javascript code base obviously that has its own

00:46:06.780 --> 00:46:09.080
<v Richard>problems on many many levels

00:46:09.500 --> 00:46:13.860
<v Richard>but in terms of feedback loop it's still just going to be very fast and yeah

00:46:13.860 --> 00:46:17.600
<v Richard>so if if that's the type of thing that you're used to is this sort of javascript

00:46:17.600 --> 00:46:22.500
<v Richard>or elm like feedback loop it's just very frustrating and innately i think to

00:46:22.500 --> 00:46:26.520
<v Richard>to work on a large rust code base and to have these slow feedback loops.

00:46:27.010 --> 00:46:32.890
<v Matthias>Yeah. Zed has sort of their own UI framework as far as I remember,

00:46:33.130 --> 00:46:39.510
<v Matthias>but there are systems like Dioxus and Laptos now that have hot reloading and

00:46:39.510 --> 00:46:41.150
<v Matthias>it's an experimental feature,

00:46:41.350 --> 00:46:45.850
<v Matthias>but they somehow made it work such that you can make certain modifications in

00:46:45.850 --> 00:46:50.750
<v Matthias>your code and it's kind of guarded by a certain way to write things.

00:46:51.070 --> 00:46:54.130
<v Matthias>Not everything is hot reloadable, but some components are

00:46:54.130 --> 00:46:56.850
<v Matthias>but of course you're not

00:46:56.850 --> 00:46:59.770
<v Matthias>writing some sort of user interface with

00:46:59.770 --> 00:47:02.910
<v Matthias>Roc you're writing a compiler so that's completely different

00:47:02.910 --> 00:47:05.830
<v Matthias>right yeah and i i can see how that

00:47:05.830 --> 00:47:08.690
<v Matthias>might be frustrating where make a single line change and then

00:47:08.690 --> 00:47:11.730
<v Matthias>you wait for 30 seconds for a clean build

00:47:11.730 --> 00:47:14.790
<v Matthias>and so on so that can can certainly be true have

00:47:14.790 --> 00:47:17.990
<v Matthias>you considered any alternatives other languages that

00:47:17.990 --> 00:47:21.550
<v Matthias>maybe have faster compile time spoiler or not maybe that

00:47:21.550 --> 00:47:24.370
<v Matthias>much of a paradigm shift like maybe i don't know

00:47:24.370 --> 00:47:27.410
<v Matthias>microsoft for example they wrote rewrote c

00:47:27.410 --> 00:47:33.650
<v Matthias>sharp in rust but also typescript in go or there might be yeah actually typescript

00:47:33.650 --> 00:47:38.530
<v Matthias>and c sharp might also be alternatives i don't know if you want to write a compiler

00:47:38.530 --> 00:47:43.630
<v Matthias>in typescript necessarily but perhaps c sharp i don't know or have you considered

00:47:43.630 --> 00:47:47.330
<v Matthias>any other languages other than Zig as well for the rewrite well.

00:47:47.330 --> 00:47:49.590
<v Richard>This gets back to the the performance ceiling right.

00:47:49.590 --> 00:47:50.210
<v Matthias>So like.

00:47:50.210 --> 00:47:53.730
<v Richard>I said it's been a hard non-negotiable goal that Roc the Rocs compiler,

00:47:54.310 --> 00:47:57.470
<v Richard>needs to be as fast as possible it needs to be really really fast it needs to

00:47:57.470 --> 00:48:00.850
<v Richard>not just be like kind of fast it needs to be extremely extremely fast that's

00:48:00.850 --> 00:48:04.470
<v Richard>a really really important thing to me about the compiler which means that any

00:48:04.470 --> 00:48:09.830
<v Richard>language of the garbage cluster immediately out so go immediately out c sharp all of them you know,

00:48:10.440 --> 00:48:14.540
<v Richard>no dice so really i mean the only contenders

00:48:14.540 --> 00:48:17.840
<v Richard>i would say would be like rust Zig or

00:48:17.840 --> 00:48:20.980
<v Richard>some other language that has basically supports memory

00:48:20.980 --> 00:48:23.920
<v Richard>unsafety so even like when we got

00:48:23.920 --> 00:48:26.820
<v Richard>far like very far into the the rust

00:48:26.820 --> 00:48:30.660
<v Richard>compiler like the rust implementation of the Roc compiler we

00:48:30.660 --> 00:48:33.860
<v Richard>were using unsafe more and more and using it in the rusty way where you know

00:48:33.860 --> 00:48:37.660
<v Richard>you try to like minimize the blast radius but to do things like destructive

00:48:37.660 --> 00:48:41.440
<v Richard>arrays and whatnot and i don't know maybe we should get into that but yeah like

00:48:41.440 --> 00:48:47.100
<v Richard>there is like even though like so Roc also has a goal of being for a language

00:48:47.100 --> 00:48:50.100
<v Richard>that automatically manages memory for you and guarantees memory safety.

00:48:50.840 --> 00:48:54.000
<v Richard>It tries to be very very fast and like i said like you know we want like run

00:48:54.000 --> 00:48:59.540
<v Richard>faster than go is a goal one of the things that that makes me realize is just

00:48:59.540 --> 00:49:05.940
<v Richard>how important memory unsafety is to performance like basically there are some

00:49:05.940 --> 00:49:08.440
<v Richard>things that you cannot do or cannot do ergonomically,

00:49:09.080 --> 00:49:11.940
<v Richard>if you have a hard requirement of like memory safety is

00:49:11.940 --> 00:49:14.780
<v Richard>enforced there are just some things that require memory

00:49:14.780 --> 00:49:17.720
<v Richard>on safety if you want them to go fast because in order to enforce memory

00:49:17.720 --> 00:49:20.600
<v Richard>safety you have to do runtime checks so really really easy

00:49:20.600 --> 00:49:24.380
<v Richard>example of this is bounce checks so sometimes

00:49:24.380 --> 00:49:27.620
<v Richard>the compiler can align this but sometimes they can't like the way

00:49:27.620 --> 00:49:30.560
<v Richard>that rust gets memory safety around

00:49:30.560 --> 00:49:33.240
<v Richard>buffer overruns is just that you know

00:49:33.240 --> 00:49:36.040
<v Richard>if you have a slice or you have a vec then you do like an

00:49:36.040 --> 00:49:38.760
<v Richard>access at a particular point in there that's going to be checked

00:49:38.760 --> 00:49:41.540
<v Richard>at runtime and if you do like the square brackets then it's

00:49:41.540 --> 00:49:44.580
<v Richard>going to panic if you have an index out of bounds or if you

00:49:44.580 --> 00:49:47.660
<v Richard>do like a you know dot get then it's going to give you back an option then you

00:49:47.660 --> 00:49:51.760
<v Richard>have to handle you know what if it was inbounds what if it was out of bounds c

00:49:51.760 --> 00:49:54.580
<v Richard>does not have that of course rust does have the unsafe equivalent of that but

00:49:54.580 --> 00:49:58.100
<v Richard>then you have to wrap it in unsafe and then you avoid the bounce check well

00:49:58.100 --> 00:50:02.000
<v Richard>the point is that if you want maximum performance you don't want that bounce

00:50:02.000 --> 00:50:06.080
<v Richard>check you want to just not do that and the downside is if you make a mistake

00:50:06.080 --> 00:50:09.760
<v Richard>then now you have undefined behavior so obviously there's a trade-off there.

00:50:10.940 --> 00:50:13.800
<v Richard>But in a language like Roc, we don't offer the unsafe option.

00:50:14.120 --> 00:50:16.740
<v Richard>Like even if you're in like the hottest of hot loops and you're like,

00:50:16.840 --> 00:50:20.100
<v Richard>no, I really, I can, you know, the compiler is not able to elide this balance

00:50:20.100 --> 00:50:23.640
<v Richard>check and the balance check is actually causing problems for me in practice somehow.

00:50:25.100 --> 00:50:29.020
<v Richard>You're stuck. You just like, sorry, we don't support that. And so the performance

00:50:29.020 --> 00:50:33.800
<v Richard>ceiling on something like Rust or C, because, you know, Rust does allow you

00:50:33.800 --> 00:50:36.860
<v Richard>the option to say, no, you can do it without the balance check if you're really, really sure.

00:50:37.320 --> 00:50:40.540
<v Richard>C just doesn't have the balance check in the first place. and Zig much like

00:50:40.540 --> 00:50:43.300
<v Richard>rust has the option of yeah you can do it with it without the bounce check,

00:50:44.480 --> 00:50:48.220
<v Richard>Zig actually will do it with like a well

00:50:48.220 --> 00:50:51.380
<v Richard>so you can when you're compiling Zig has different optimization

00:50:51.380 --> 00:50:55.280
<v Richard>levels one of which is optimize safe which is basically like what rust does

00:50:55.280 --> 00:50:58.520
<v Richard>so it's like always have the bounce check you can also have optimize fast which

00:50:58.520 --> 00:51:01.840
<v Richard>basically means we'll do the bounce check and debug builds but in release builds

00:51:01.840 --> 00:51:06.120
<v Richard>we will not do it kind of similar to how rust will do panic on overflow and

00:51:06.120 --> 00:51:08.720
<v Richard>debug builds but then in release builds it'll just,

00:51:09.200 --> 00:51:12.520
<v Richard>let the number overflow and just the energy just wraps around Zig does that

00:51:12.520 --> 00:51:16.740
<v Richard>same thing for like memory access if you compile with release fast as opposed

00:51:16.740 --> 00:51:21.560
<v Richard>to release safe release safe we'll just keep them so basically those types of

00:51:21.560 --> 00:51:25.260
<v Richard>things are not accessible in a language like c sharp or something like that

00:51:25.260 --> 00:51:28.100
<v Richard>unless you want to drop into cffi and at that point i'm like well,

00:51:28.760 --> 00:51:32.020
<v Richard>if i'm going to do ffi why don't i just write it in one language and,

00:51:32.680 --> 00:51:37.420
<v Richard>So that's the type of thing that I see as sort of a reason that we did not consider

00:51:37.420 --> 00:51:39.240
<v Richard>languages like C-sharp or Go.

00:51:39.520 --> 00:51:41.940
<v Richard>Even though they are plenty fast for garbage-collected languages,

00:51:42.200 --> 00:51:45.600
<v Richard>however fast they might be, I want that maximum performance ceiling to be available.

00:51:45.820 --> 00:51:49.540
<v Matthias>One of the killer features that keeps coming up in every single discussion I

00:51:49.540 --> 00:51:56.800
<v Matthias>have with people that compare Zig and Rust, which are fundamentally two different languages,

00:51:57.120 --> 00:52:01.780
<v Matthias>is that Zig has this very nice concept of comp time.

00:52:01.780 --> 00:52:05.500
<v Matthias>And in Rust, we have not so much.

00:52:05.620 --> 00:52:11.520
<v Matthias>We have derives, we have a build RS, and we have macro rules.

00:52:11.800 --> 00:52:14.880
<v Matthias>But that's more or less what we can do.

00:52:15.280 --> 00:52:21.820
<v Matthias>So from your perspective, knowing both concepts, what is your current feeling about comp time?

00:52:22.000 --> 00:52:27.040
<v Matthias>Is it something that Rust should add? Or is it something that is very much native

00:52:27.040 --> 00:52:30.760
<v Matthias>to Zig and the way Zig works? And there are better alternatives in Rust?

00:52:31.240 --> 00:52:34.000
<v Richard>I don't think you could retrofit comp time onto rust i

00:52:34.000 --> 00:52:36.880
<v Richard>don't think that would make sense um the thing that's really

00:52:36.880 --> 00:52:40.200
<v Richard>cool about the way that Zig uses comp time primarily

00:52:40.200 --> 00:52:43.060
<v Richard>i would say is that Zig has

00:52:43.060 --> 00:52:45.920
<v Richard>comp time instead of a whole laundry list

00:52:45.920 --> 00:52:48.580
<v Richard>of features that rust has to try to do the same kind of

00:52:48.580 --> 00:52:52.200
<v Richard>job so you'll learn this one concept and i

00:52:52.200 --> 00:52:55.000
<v Richard>mean there's some different aspects of the concept it's not like it's this you

00:52:55.000 --> 00:52:58.300
<v Richard>know oh here's comp time it runs a compile time the end there's a

00:52:58.300 --> 00:53:01.080
<v Richard>whole like supporting ecosystem around that like okay if i want to do type

00:53:01.080 --> 00:53:04.140
<v Richard>introspection that's just like a thing i can do at compile

00:53:04.140 --> 00:53:07.000
<v Richard>time but you do actually have to go learn like how the type

00:53:07.000 --> 00:53:09.700
<v Richard>introspection stuff works kind of like how in rust you

00:53:09.700 --> 00:53:12.500
<v Richard>have to go learn proc macros though proc macros are a lot more complicated than

00:53:12.500 --> 00:53:16.260
<v Richard>comp time which i would say is the other nice thing about comp time it's not

00:53:16.260 --> 00:53:21.020
<v Richard>just that it's one powerful feature that takes the place of several other features

00:53:21.020 --> 00:53:25.380
<v Richard>in rust but also that it is conceptually pretty simple the learning curve is

00:53:25.380 --> 00:53:28.220
<v Richard>not as high as something like, again, I'll pick on proc macros.

00:53:29.250 --> 00:53:32.730
<v Richard>That said, I don't want to say that it's all upside and no downside.

00:53:33.010 --> 00:53:37.230
<v Richard>I mean, one of the things that is a, I don't know, thing that I miss from Rust

00:53:37.230 --> 00:53:43.330
<v Richard>when I'm working in Zig is that because Rust has like full parametric polymorphism,

00:53:43.550 --> 00:53:44.190
<v Richard>including of arguments,

00:53:44.990 --> 00:53:49.090
<v Richard>Rust types tend to be more self-descriptive than Zig types are.

00:53:49.290 --> 00:53:53.630
<v Richard>That's like pretty common in Zig to see something where at the type annotation

00:53:53.630 --> 00:53:56.710
<v Richard>level, it says something like, oh, this takes in any type.

00:53:56.710 --> 00:53:59.970
<v Richard>Now this is not the same thing as like in typescript

00:53:59.970 --> 00:54:02.950
<v Richard>for example you have a type called any it's just this magical thing that

00:54:02.950 --> 00:54:05.810
<v Richard>like you know you can give it anything and it's all going to work out unless it

00:54:05.810 --> 00:54:09.550
<v Richard>crashes at runtime or gives you horrible things that's not

00:54:09.550 --> 00:54:13.750
<v Richard>what it means what it means is just that this is something that's going to be

00:54:13.750 --> 00:54:18.850
<v Richard>resolved like this type is going to be resolved at compile time rather than

00:54:18.850 --> 00:54:23.070
<v Richard>being like fixed to a hard-coded type that you've written down so you will still

00:54:23.070 --> 00:54:27.510
<v Richard>get a compiler error if you misuse that function you try to give it a like incompatible type.

00:54:27.910 --> 00:54:32.370
<v Richard>But again, the thing that I miss from Rust is that in Rust, I would be able

00:54:32.370 --> 00:54:34.010
<v Richard>to see a type written out.

00:54:34.190 --> 00:54:37.010
<v Richard>So just at a glance, I can say, what does this function take?

00:54:37.250 --> 00:54:41.070
<v Richard>In Zig, it's much more common than it is in Rust because it's much more common

00:54:41.250 --> 00:54:44.890
<v Richard>in order to find out whether or not something succeeded or failed,

00:54:45.070 --> 00:54:48.810
<v Richard>I actually need to do a build. So the analogy here would be macros and Rust.

00:54:49.290 --> 00:54:51.770
<v Richard>Sometimes I have some code and I'm like, okay, I'm looking at this.

00:54:52.130 --> 00:54:56.090
<v Richard>And based on looking at it, I'm not totally sure if this is going to compile or not.

00:54:56.190 --> 00:54:58.830
<v Richard>I need to actually compile it to figure out if it's going to work or not,

00:54:58.850 --> 00:55:00.590
<v Richard>because it has to resolve all the macro stuff.

00:55:00.730 --> 00:55:04.050
<v Richard>And then based on how the macros resolve, okay, maybe it's going to turn out

00:55:04.050 --> 00:55:06.530
<v Richard>that something did or did not compile, and then I'll get an error.

00:55:06.810 --> 00:55:09.510
<v Richard>So I'm still getting the error at compile time. But of course,

00:55:09.630 --> 00:55:12.530
<v Richard>I would prefer to just have it be more visually obvious where

00:55:12.530 --> 00:55:15.110
<v Richard>i can just look at it and say like this is definitely going to work or this isn't going to

00:55:15.110 --> 00:55:18.330
<v Richard>work without actually having to wait for the compiler to you

00:55:18.330 --> 00:55:21.030
<v Richard>know go through the macro expansion to be able to tell whether or not it

00:55:21.030 --> 00:55:23.670
<v Richard>compiled that's kind of that analogy i think

00:55:23.670 --> 00:55:28.110
<v Richard>applies to Zig's comp time as well where there is a higher number of cases where

00:55:28.110 --> 00:55:32.410
<v Richard>i can't just look at it and know for sure like what its type is or what types

00:55:32.410 --> 00:55:36.110
<v Richard>this function accepts or doesn't accept i have to wait for the compiler to go

00:55:36.110 --> 00:55:39.010
<v Richard>through and give me that feedback So it's sort of like the absolute fastest

00:55:39.010 --> 00:55:41.930
<v Richard>feedback loop is I just look at it and I can tell from, you know,

00:55:42.010 --> 00:55:43.510
<v Richard>my intuition, my experience with the language.

00:55:43.790 --> 00:55:47.410
<v Richard>The second fastest feedback loop is compile time. Then the third fastest would be runtime.

00:55:48.170 --> 00:55:53.210
<v Richard>So there's more things in Zig that are in that second case of I can't just look at it.

00:55:53.290 --> 00:55:56.790
<v Richard>I have to actually run the compiler than there are in Rust when it comes specifically

00:55:56.790 --> 00:56:00.170
<v Richard>to type annotations because comp time is used in type annotations like that.

00:56:00.170 --> 00:56:03.610
<v Richard>So this is kind of an inside baseball thing, but I think anyone who's used both

00:56:03.610 --> 00:56:08.190
<v Richard>languages would pick up on that as something like, yeah, I do appreciate the

00:56:08.190 --> 00:56:11.750
<v Richard>conceptual simplicity of comp time and how it can take the place of all these

00:56:11.750 --> 00:56:12.450
<v Richard>other language features,

00:56:12.590 --> 00:56:16.850
<v Richard>make the language simpler and learning curve and all that good stuff. And it's very powerful.

00:56:17.010 --> 00:56:21.050
<v Richard>There's things that you can use comp time for in Zig that I guess I haven't

00:56:21.050 --> 00:56:24.610
<v Richard>maybe thought through it, but it seems like it would be harder to try to wrangle

00:56:24.610 --> 00:56:27.250
<v Richard>all the different Rust features together to do the same thing.

00:56:27.250 --> 00:56:30.550
<v Richard>But that is a downside is that you don't get.

00:56:31.350 --> 00:56:34.850
<v Richard>Some of your type annotations are just not as self-descriptive and in order to tell

00:56:35.230 --> 00:56:39.030
<v Richard>what this function takes i either need to go read the implementation or more

00:56:39.030 --> 00:56:42.310
<v Richard>likely i need to read the comments for the function that's like okay here's

00:56:42.310 --> 00:56:44.990
<v Richard>what you can give this thing right but i can't tell just by looking at the type

00:56:44.990 --> 00:56:46.870
<v Richard>annotation i actually do need to go read some documentation

00:56:47.290 --> 00:56:52.230
<v Richard>just to know what i can pass to this that will compile at compile time just like with a macro.

00:56:53.410 --> 00:57:00.110
<v Matthias>I'm not an expert on this but as far as i know six comp time also takes the

00:57:00.110 --> 00:57:06.730
<v Matthias>outer scope into consideration if something was defined before the comp time,

00:57:07.550 --> 00:57:11.930
<v Matthias>call then you could access that i don't know if that is true maybe correct me

00:57:11.930 --> 00:57:15.990
<v Matthias>if i'm wrong but there is a crate called crab time now which.

00:57:15.990 --> 00:57:17.610
<v Richard>Oh yeah works for us and.

00:57:17.610 --> 00:57:22.630
<v Matthias>It it takes a piece of code and then compiles that in a separate project and

00:57:22.630 --> 00:57:26.270
<v Matthias>then it inserts the result into your project.

00:57:26.270 --> 00:57:28.190
<v Richard>Yeah so it does not.

00:57:28.190 --> 00:57:29.890
<v Matthias>Access the outer scope though.

00:57:29.890 --> 00:57:32.690
<v Richard>But again like i mean going back to like to

00:57:32.690 --> 00:57:35.850
<v Richard>me the the cool part about comp time is it

00:57:35.850 --> 00:57:38.650
<v Richard>has something in common with functional programming which i love about

00:57:38.650 --> 00:57:41.830
<v Richard>functional programming which is the subtractive aspect it's like it's

00:57:41.830 --> 00:57:44.530
<v Richard>the thing that i most like about comp time and

00:57:44.530 --> 00:57:47.390
<v Richard>Zig is all the features that Zig does not have because it

00:57:47.390 --> 00:57:50.170
<v Richard>has comp time so if you add comp time to rust which

00:57:50.170 --> 00:57:53.110
<v Richard>already has all those other features it it just seems like it's

00:57:53.110 --> 00:57:55.810
<v Richard>it's moving in the wrong direction it's like well no the thing that i

00:57:55.810 --> 00:57:58.550
<v Richard>like is the the reduced feature set smaller set of

00:57:58.550 --> 00:58:02.830
<v Richard>simple primitives similarly to how you know if you take something like javascript

00:58:02.830 --> 00:58:05.310
<v Richard>or typescript you're like oh let me add some more functional programming stuff

00:58:05.310 --> 00:58:08.630
<v Richard>and then it's like well no but i what i like about it is the subtracted the

00:58:08.630 --> 00:58:12.570
<v Richard>smaller tool set i want a smaller tool set of simple primitives i don't want

00:58:12.570 --> 00:58:16.510
<v Richard>to just add yet another way to do it into something that I think is already

00:58:16.510 --> 00:58:18.210
<v Richard>too complex in the JavaScript ecosystem.

00:58:18.840 --> 00:58:22.020
<v Matthias>Yeah, I can fully get behind that.

00:58:22.160 --> 00:58:26.800
<v Matthias>And also, whenever you talk through such a technical problem,

00:58:27.020 --> 00:58:32.300
<v Matthias>or maybe a technical decision that was made, it always feels like your opinion

00:58:32.300 --> 00:58:36.400
<v Matthias>is very balanced. You don't really take any of both sides.

00:58:36.420 --> 00:58:40.280
<v Matthias>It's just that you pick what works best for you and for the team, right?

00:58:40.460 --> 00:58:44.640
<v Matthias>And that's very refreshing to hear as well, because everything is backed by

00:58:44.640 --> 00:58:49.200
<v Matthias>facts and backed by a lot of knowledge as well. so that was pretty impressive

00:58:49.200 --> 00:58:51.340
<v Matthias>i guess we could talk about that for ages.

00:58:51.340 --> 00:58:53.580
<v Richard>Unfortunately we did.

00:58:53.580 --> 00:58:59.440
<v Matthias>Run out of time but there's one final question that i commonly ask at the end

00:58:59.440 --> 00:59:03.580
<v Matthias>which is what is your message to the rust community.

00:59:03.580 --> 00:59:06.660
<v Richard>I think the biggest thing would be focus on the end user,

00:59:07.220 --> 00:59:10.960
<v Richard>i think it's it's easy because rust is such a big language with so many different

00:59:10.960 --> 00:59:15.040
<v Richard>features and there's so many different competing concerns you can have in terms

00:59:15.040 --> 00:59:19.300
<v Richard>of like i need to balance it's like making this safe and also making it well

00:59:19.300 --> 00:59:21.380
<v Richard>tested and well structured and easy to maintain,

00:59:21.960 --> 00:59:24.720
<v Richard>there's all these different things that you could be thinking about and i think,

00:59:25.380 --> 00:59:28.760
<v Richard>focusing on what's the end user gonna you

00:59:28.760 --> 00:59:31.740
<v Richard>know get out of my program that's the most important thing that's got to be

00:59:31.740 --> 00:59:36.080
<v Richard>the north star and don't lose sight of that when you're thinking about all these

00:59:36.080 --> 00:59:40.040
<v Richard>other things that you as a programmer could be thinking about and i think that's

00:59:40.040 --> 00:59:43.500
<v Richard>something that zed really embraces which i really appreciate about zed it's

00:59:43.500 --> 00:59:45.780
<v Richard>like we brag about things like Like, you know,

00:59:46.020 --> 00:59:48.760
<v Richard>this is a code editor that runs like 120 frames per second when you're like

00:59:48.760 --> 00:59:53.380
<v Richard>scrolling through your tabs, you know, as switching like code editors as fast

00:59:53.380 --> 00:59:56.620
<v Richard>as possible and things like that. And I think that's how it ought to be.

00:59:56.900 --> 01:00:01.500
<v Richard>It shouldn't be that we're bragging about, you know, Z is innately good because

01:00:01.500 --> 01:00:05.660
<v Richard>it's written in Rust, but rather that Z is really, really fast and writing it

01:00:05.660 --> 01:00:07.180
<v Richard>in Rust is the way that we achieve that.

01:00:07.890 --> 01:00:13.070
<v Matthias>That was pretty amazing Richard thanks so much for taking the time where can

01:00:13.070 --> 01:00:14.850
<v Matthias>people learn more about Roc.

01:00:14.850 --> 01:00:18.770
<v Richard>Yeah so Roc does R-O-C it's

01:00:18.770 --> 01:00:21.510
<v Richard>named after the mythical bird not the not the rock like the

01:00:21.510 --> 01:00:24.490
<v Richard>you know inanimate object or the genre of

01:00:24.490 --> 01:00:27.450
<v Richard>music so roc-lang.org like i

01:00:27.450 --> 01:00:30.270
<v Richard>said we're in the middle of a compiler rewrite so you can definitely try it out but

01:00:30.270 --> 01:00:32.910
<v Richard>stay tuned i would say like you know this is going to come

01:00:32.910 --> 01:00:36.330
<v Richard>out i'm assuming somewhat before advent of code 2025 but

01:00:36.330 --> 01:00:39.230
<v Richard>we're hoping to have the new compiler ready to

01:00:39.230 --> 01:00:42.650
<v Richard>rock for pun actually retroactively intended um

01:00:42.650 --> 01:00:45.610
<v Richard>ready to rock for advent of code 2025 so

01:00:45.610 --> 01:00:48.230
<v Richard>people can try it out and so far we're on track to be

01:00:48.230 --> 01:00:51.430
<v Richard>able to do that but yeah there's going to be a lot of new design changes

01:00:51.430 --> 01:00:54.190
<v Richard>and awesome stuff for the language it's going to be easier to get

01:00:54.190 --> 01:00:57.750
<v Richard>into especially for beginners and people can

01:00:57.750 --> 01:01:01.030
<v Richard>look forward to all that but if you want to get involved sooner than that or certainly

01:01:01.030 --> 01:01:03.710
<v Richard>if you want to contribute to the compiler or donate to what we're doing we

01:01:03.710 --> 01:01:07.070
<v Richard>have a non-profit foundation set up that people we can donate through so it's

01:01:07.070 --> 01:01:12.630
<v Richard>tax exempt in the u.s and yeah all that is at roc-lang.org and of course if

01:01:12.630 --> 01:01:17.950
<v Richard>you want to follow any of the rust stuff i'm doing check out zed zed.dev it's

01:01:17.950 --> 01:01:21.750
<v Richard>been my daily driver editor for years now i love it and it's been just getting better and better.

01:01:21.750 --> 01:01:27.650
<v Matthias>Yeah that was amazing greetings also to Conrad Irvin and Folkert de Vries who

01:01:27.650 --> 01:01:32.610
<v Matthias>used to be guests as you mentioned And Richard, thanks so much for taking the time.

01:01:33.270 --> 01:01:33.590
<v Richard>Thank you.

01:01:34.470 --> 01:01:38.110
<v Matthias>Rust in Production is a podcast by corrode. It is hosted by me,

01:01:38.390 --> 01:01:41.170
<v Matthias>Matthias Endler, and produced by Simon Brüggen.

01:01:41.350 --> 01:01:45.630
<v Matthias>For show notes, transcripts, and to learn more about how we can help your company

01:01:45.630 --> 01:01:48.510
<v Matthias>make the most of Rust, visit corrode.dev.

01:01:48.750 --> 01:01:51.090
<v Matthias>Thanks for listening to Rust in Production.