CORECURSIVE #067

Full-Time Open Source

With Andrew Kelley

Full-Time Open Source

Andrew Kelley

Today’s show: How to quit your job and work on open source full time.

This story has it all – balancing side projects and full-time employment, building up enough supports to leave your job, and explaining quitting to your family and friends.

And also: what do you do if your project succeeds, and then someone forks it and builds a commercial business around it? And how do you deal with hacker news feedback? And how can we improve on the C programming language?

This is a fun one!

Transcript

Note: This podcast is designed to be heard. If you are able, we strongly encourage you to listen to the audio, which includes emphasis that’s not on the page

Introduction

Adam:Today on Corecursive.

Andrew:Let me be clear about this. Commercially forking Zig is fine. It’s MIT-licensed like go for it. But what they did with the Fork was be very tricky about it, right? So, they actually deleted the license file, put their own license in it and made it look like you had to pay for the software. So, they were deceiving people. That was the problem with what they were doing.

Adam:Hello, and welcome to Corecursive. I’m Adam Gordon Bell. Each episode someone shares the story of a piece of software being built. Today’s show, How to Quit Your Job and Work on Open Source Full Time. This story has it all, balancing open source work and full-time employment, building up enough supporters and enough savings to leave your job. The hardest part to me which is explaining leaving your job to your significant other and to your family and friends.

And then, also what do you do if your project succeeds, and then someone forks it and builds a commercial business around it? There’s a lot more as well dealing with hacker news feedback, how to improve upon the C programming language and how to be super ambitious without seeming arrogant. And my guest is this guy.

Andrew:My name is Andrew Kelly. I am the lead software developer and president of the Zig Software Foundation.

The Music Studio Project

Adam:Zig is a programming language, and we’ll get into why it’s needed, but Andrew got started on Zig because of another side project.

Andrew:I started working on a music studio project, and in this music studio project, you have more difficult requirements than you usually have in other programming projects. So, for example, if anyone’s going to use your music studio software live, for live performance, you have a hot loop where you absolutely must not skip the audio or their entire performance might be compromised.

So, you just have these like new constraints where you really need control over how it’s going to work. And likewise, if you want to support all the hardware that’s associated with this, a lot of times you’re not going to be able to rely on someone else’s third-party library to do that for you, you’re going to have to get into OC, C++ or another low-level language that gives you the control that you need and the other thing I noticed is that when I tried to use other people’s libraries, if I ran into a problem, I wouldn’t be able to fix it. It’s too slow.

I’m trying to make progress on this big project and I learned the value of inventing stuff here, right? People are always telling you, “Don’t invent.” Don’t NIH syndrome, but I learned the value of actually, yeah, that is the right thing to do sometimes. If you really want that much power and control you got to do it. So, that’s when I started just really getting into programming stuff from scratch with C or C++.

Reuse Problems

Adam:Even in C reuse is common, but reuse can bring problems.

Andrew:I think that the natural first impulse was that if someone else solved the problem, just go use their solution, right? It’s already done. You write the glue code, and then you’re off. In a lot of ways that’s smart because we only have so much time, we only have so much ability to analyze a problem space. And the other person has already done that part. So, let’s see what’s a good example of this.

The audio library would be an example. So, I tried using port audio. I tried using SDL, I think. These projects mostly work, but then the problem is that they solve 90% of the problem, and if you want to close that last 10% gap, you have to start over. So, I ended up writing my own cross-platform audio abstraction called the libsound.io, and that allowed me to do things that the other libraries didn’t let me do. So, for example, I had the ability to just display a list of input devices and have it automatically refresh. If you unplug the mic, it goes away, if you plug the mic in, it shows up.

It seems so simple, seems like such a reasonable thing for the user experience, but these other libraries just did not have that ability. And it would have taken me probably honestly years to get the feature into those libraries, and then have enough time pass that those libraries got the updates into the various open source distributions of packaged libraries. Because if you use a third-party library, people want to use the pre-packaged versions. So, then you’re even waiting for their release cycle. And then, you’re waiting for the downstream maintainers to get it, but if you put it in your own code base, you just ship it when you want to ship it, right?

And there’s just so many problems with these languages that get in the way of progress, bugs take forever to find and fix, progress is slower than it should be. And so, that’s when the juices started flowing. And I thought, “I think I can do better than this.” I think I see what these languages are bringing to the table and I think I can take them to the next level.

Fighting the Impluse to Rewrite

Adam:Did you fight that impulse? Did you immediately get sidetracked on building a language or what happened there?

Andrew:I did. I did fight the impulse. And I stuck with the music player project for quite a while. And then, to be honest I just went through kind of a difficult life experience. It was a breakup at the time and just as kind of a coping mechanism I let myself say, “Hey, I know you’ve been trying to be just disciplined and stick with the same project for a long time, but go have some fun, start a new project, start a programming language. It’ll be good for you.” And then, it’s never switched back.

Adam:So, was it like you were like my whole mind is occupied by this breakup, but I think if I start this new project it might be able to squeeze it out of my brain at least temporarily?

Andrew:Yeah. That was exactly right.

Adam:And did it work?

Andrew:Mn-hmm (affirmative). I mean I think just the natural emotional progress ran its course, but just in the meantime I was having fun with a distracting toy project.

Adam:Yeah. I mean it’s certainly more productive than like, I don’t know, playing Mario Kart for-

Andrew:Mario Kart.

Adam:… eight hours a day or something. I like Mario Kart. I don’t know.

Andrew:Yeah. Mario Kart’s a great game.

Creating a Programming Language

Adam:Andrew had always wanted to create a programming language.

Andrew:The very first time I ever used a programming language, I always wondered what would it be like to make one? And whenever I listen to music, I always wonder what would it be like to try and make a song like this? I’ve always enjoyed just consuming things by just wondering what the other side of the process looks like.

Adam:When I was in university, I had a class where we built a compiler, like a toy compiler. And it was super fun. Andrew had a similar experience and went on to toy around with a fork of CoffeeScript. I found playing with programming languages to be fun, but Andrew, he got something different out of it.

Andrew:You know what it was? I actually ran my first marathon a couple years ago, but I don’t feel like I did. Because I walked the last four miles of it, hit that wall hard. And I guess most people do, because I was still in like the top 50% for my age group. So, I guess just most people walk at the end of marathons, but in my head, it’s like you didn’t do it. You walked part of it, right?

So, I always felt that way about the compilers that I’ve made, because if it’s like a CoffeeScript one, you’re actually just outputting JavaScript. And then, for the one in college the professor just had us do C as the output. So, I always felt like I walked the last part. I always wanted to say, “No. I want to make it actually make machine code and make it do the whole thing. I don’t want to cheat on some of the layers.”

I also don’t want to devalue like the work that people have done. That’s all it’s still a compiler. If you go from one input language to a different input language, that’s a compiler. That’s just my personal subjective experience is that I felt like I was missing some interesting part that I hadn’t had the experience of completing.

Adam:Andrew understood before he even started what the C language brought to the table, and this is important. C is a small language and it’s everywhere. C is used by 20% of software developers according to the Stack Overflow Survey. Some conditions may apply there.

I don’t know if the Stack Overflow Survey is representative, but they have a lot of developers using it and 20% of them say that they are writing C. That’s one in five developers. That’s more people than use Ruby and Swift and Rust combined.

So, anyways, Andrew has his breakup and he gives himself permission to start on his language. His idea isn’t to start from first principles and create a new language, but to look for specific problems that can be addressed.

Andrew:Is there dirt under this rug? Maybe we can do this a different way. A lot of software is built on premises of abstractions that previous generations have handed to us. Let’s peel those off a little bit and take a peek and say, “Maybe we might want to make some different decisions now that it’s 40 years later.”

Static Linking

Adam:What’s an example?

Andrew:One example would be static linking. If you’re trying to ship a application on Linux, there’s a common problem people have where it’ll only work on one distribution of Linux. So, for example, someone might provide their application on their website you download it, but only runs on Ubuntu or something that’s close enough to Ubuntu.

Adam:I literally just had this problem. I was trying to install a Python library Matplotlib. And on Mac OS, it was super easy, but to get it into Alpine Linux, I had to install all these dependencies.

Andrew:And the reason for this is that they dynamic link all the libraries they depend on. They just expect you to install those libraries with the system package manager. I’ve chosen to make Zig so that the default on Linux is that you do not link libc at all when we provide the download of a pre-built Zig for Linux. It works for all Linuxes, all of them, because the binary has no libc dependency. It just uses the syscalls in assembly.

And the only dependency it has is a file system and the kernel. It doesn’t depend on anything else. So, that way we can provide a binary that just works for everybody’s computer on Linux just like on Windows and other systems. We got that benefit by questioning distributing things with dynamic linking and saying, “Well, maybe we should go a different direction.”

Adam:Go does something similar?

Integer Casting Rules

Andrew:Yes. I think it does depend on glibc though. I know that you can actually use Zig with Go and Zig will provide the ability to have a static Linux binary and give you this benefit with Go programs.

Adam:So, were there other aspects of C that you were targeting that frustrated you?

Andrew:One is that there are just too many ways to accidentally introduce bugs that are not interesting bugs that you get because programming is hard, but they’re unnecessary bugs, because the C programming language made some bad decisions. So, as an example, there’s a type system and the whole point of a type system is to help you not make bugs, but the type system has some things that it allows with no errors and no warnings that just are bugs 99% of the time.

It’s very easy to make that mistake. Just stuff like integer casting rules is one, so that’s one complaint I would make. Too easy to shoot yourself in the foot. And then, have a unnecessarily complicated debugging session to solve the problem.

The C Preprocessor

Andrew:And then, the second complaint I would make is that while C code is usually very simple to read, because it’s just functions and data. That’s the best case scenario. It does have just another different programming language on top of it, which is the C pre-processor. It’s not C, it’s a different language that’s based on text concatenation and people abuse that language too much.

And then, it’s just too hard to figure out what’s going on. You see a function call, is it a function call? If you’re not super familiar with the code you’re reading, you’re always wondering, “Is that a macro? It might be a macro.” Right?

Adam:Yeah. It requires global knowledge of what all of these things are.

Andrew:Global knowledge is a great way to put it. Yeah. One of the big design considerations that I made with the Zig language was let’s reduce the amount that someone must remember when they’re reading code.

Software Development Culture

Adam:Another thing Andrew thought he could improve upon was more cultural.

Andrew:Some people are so defensive about a norm where people are like mean to each other. And don’t get me wrong, I’m a very blunt person. I’m very comfortable with conflict and I can tell someone I think that they’re full of shit, but have you ever gone into the C, freenode channel and just observed?

Adam:No.

Andrew:That is one of the most toxic, hostile chatrooms I’ve ever been in. Before the freenode drama, the C programming language channel on freenode. You could go in there and ask some simple question like, “How do I… I don’t know. How do I align a field in a struct or something?” Some very reasonable question, and you’ll get one person who calls you a name, one person who says you can’t period, passive aggressive doesn’t explain it at all.

One person gives you just wrong information and the actual answer is that you can do it. It’s fine. And there’s some tricks you can do. It’s one of the worst places in the world. I don’t know what’s up with that. So, it’s like the one word I’d use to describe it is pedantic, right?

Adam:oh, yeah.

Andrew:And they even have, there’s even a flag and a C compiler that’s pedantic. And I always think like, “Oh, it’s the C chat room flag.”

Adam:With this vision in mind of a better language and a better less pedantic community and a working version of the language up on GitHub, Andrew starts to get some users.

Releasing the First Version Of Zig

Andrew:The number of people who file an issue per week has just gone up slowly over time. The number of people who wanted to help out, submit pull requests, which were up for grabs since the very beginning. It was always done in the open. It’s just slowly gone up over time.

One of the first projects that I got to see that someone did with Zig was the Pokemon rom randomizer project. So, they used Zig and made a set of command line tools to take the Game Boy roms that were Pokemon ones and just did some rom hacking. And then, gave you a new rom that you could then pop into an emulator and it would shuffle around all the, which graphs have which Pokemon and stuff.

Adam:Building a programming language is just a lot of work. You have to find time to keep pushing it forward.

Andrew:I would describe Zig as kind of like a flower growing in the cracks of the concrete of my career. When I started it I was taking a break from full-time work. And then, I needed a job. So, I got a job at a start-up called Backtrace, did that for a little bit, save some more money, quit, worked on Zig full-time for a few months. I interviewed with Apple, and they just flat out said, “You may not do that in your spare time.”

So, I said, “Fuck off then.” And now getting donations from Apple to the Zig Software Foundation, by the way.

Adam:That’s awesome.

Joining OKCupid

Andrew:Joined OKCupid, moonlighted Zig during that time.

Adam:Was there ever any tension? I imagine you’re at OKCupid or the other place. And I don’t know, is work building up or is there things to do? Do you constantly try to evangelize how great your language is to your co-workers until they get angry? What happened?

Andrew:Oh, yeah. When I joined OKCupid, I had to have a whole negotiation with the recruiter, because a lot of companies just put in the contract something like, “Anything you do in your spare time is owned, the IP is owned by the company.” It’s ridiculous. So, I just said, “You have to strike that from the contract. I’m going to own all the IP of everything I do in my spare time on my own equipment.”

And the guy was like, “Oh, no one asks for this. We don’t usually do this. I’ll see what I can do.” And I had to take a real like hard-line stance with him, eventually he caved. You have to protect your baby or someone’s going to take it away.

Adam:Yeah. That’s silly, right? And you know that they had no problem striking it, it’s just they didn’t want to go through the problem of like… He didn’t want to find out who to ask about that.

Andrew:Yeah. He was just like didn’t want to bother.

Adam:Yeah.

Andrew:True.

OK WebServer and Zig

Adam:But what about your actual co-workers, did they know you were working on Zig? Did you talk about it?

Andrew:Oh, yeah. I wasn’t shy about that. And I tried not to be annoying, but I couldn’t help if we were… If we had some problem in the code base, I couldn’t help point out like, “Well, in Zig if you wrote… The code would be written this way and this problem would have been a compiler error instead of a bug.”

In some ways I think it helped me design the compiler errors because I was just seeing the problems that we were hitting in practice.

Adam:What technologies were they using?

Andrew:At OKCupid, it’s a big C++ code base.

Adam:It’s kind of unexpected to me that it would be C++. I just assume all like SaaS stuff is, I don’t know, not C++.

Andrew:Yeah. So, the funny story there is that the company was founded, I don’t know, 15 years ago by Maxwell Krohn, and this other guy’s name. Their PhD thesis was called OK Web Server. And it was just like some… It had nothing to do with dating. It was just a way to do security on a C++ web service. And so, basically they did their research, and they thought, “Okay, now what? I guess we’ll start a company.”

So, OKCupid was actually named after the research paper OK Web Server.

Adam:That’s funny.

Andrew:Yeah.

Adam:Yeah. So, it’s like arbitrary that they use C++. Well, it’s actually arbitrary that they choose dating.

Andrew:Right. Exactly. Yeah.

Adam:Yeah. It was always going to be C++. They just didn’t know what.

The OKCupid Code Base

Andrew:The funny thing too is when you’re joining the company they just have you read the paper, because it’s still accurate about how the code base works.

Adam:I mean in some ways that’s great, because like most places have code bases that like, there’s not a single person that can explain the entirety of it, right?

Andrew:Yeah. I agree with you, although I will say just having splunked through a bunch of that old code, I could tell that the founders were just having a lot of fun and just experimenting a lot, just playing with stuff. I’m just like, “Who cares? We’re definitely going to exit from the startup and leave in four years. I don’t give a shit.” Right?

You can see it in their code. You can tell they’re just screwing around and they really don’t care about the longevity of… It was pretty… I feel like I have kind of like a parasocial relationship with the founders. I didn’t actually interact with them, but I interacted with their code. And I’m just like…

Adam:What does-

Andrew:Why did you do this to me?

Adam:Yeah. What does I don’t give a shit, I’m going to exit like C++ look like?

Andrew:There was a file that was both a Perl script and a C++ file, and to update it… It’s self-updating, so you run it with Perl and it edits itself, but then you’re supposed to… It’s for the C++ project. Does that make sense? It’s a polyglot file.

Adam:Oh, wow.

Andrew:So, the same file is a Perl program and it edits itself like a weird hack so that it could be parsed by both.

Adam:That’s amazing.

Andrew:It’s very cute.

Join the Newsletter

Did you know CoRecursive has a newsletter?

Sign up to get insights, takeaways, and exclusive content from each new episode.

    We won't send you spam. Unsubscribe at any time.

    The Stress of Two Jobs

    Adam:Before you went full time, did you ever feel like this is too much to do this and my job?

    Andrew:Oh, I was definitely stressed out. Yeah. My fiancée can tell you about some of the times I just kind of just showed up very, very stressed and just like unable to like be a good partner, but I never even considered quitting doing Zig stuff. The only thing I ever considered was quitting work. The thing that was causing me so much stress was the feeling that I was wasting my life just on this bullshit. Wasting my life just being a pawn in someone else’s just play to get money, whereas what I felt like I was doing with this open source project was more meaningful.

    I mean we create our own meaning in life. I’m not here to judge what anyone wants to do with their life, if you want to make money go make money, but I don’t want to be a pawn in your gambit to make money. I want to do what I think is meaningful in my life, and for me a large part of that is just contributing as a collective to open source software. And I could tell as Zig was picking up more steam, I could tell that I was missing out on opportunities, because of the full-time work.

    People who would become contributors were kind of just turned away because they didn’t get enough attention that I would have given them if I had more time or just the progress, the rate of progress didn’t match up to my ambitions of what I wanted it to be. I think I just became very, very aware of the opportunity cost I was paying by being employed for someone else. And that was rough. That was probably a low point in my life.

    Setting Up Patreon for Zig

    Adam:Fortunately, Andrew had a plan that he got from Alan Webster.

    Andrew:So, that’s someone from the handmade community. I met him at Handmade Seattle, but I noticed that he was making a text editor, and he had a patreon, and he was getting something like 400 bucks a month or something like that. And that’s not enough to live on. That’s maybe enough for groceries for food for a month, but I thought like that’s progress, and that’s a big amount of money, even if I’m just going to try and save money, and then quit and then go back to work when I run out, that would help me delay, that helped me give me more runway.

    So, I thought, “Maybe this can work.” So, I started just paying really close attention to everyone who did this kind of imitate them. And so, yeah, so, I did a patreon at first, and there was never a spike. It was always just like very, very slow growth. I started doing live coding streams. I started, I just put links to donate to me at the bottom of my blog posts. Every time I got a blog post on hacker news or Reddit or something I’d get like a few more donations, but the point is they’re recurring.

    People are going to add and remove, it’s going to go up or down, but because of statistics you can just kind of count on it more. You can plan your life a little bit more about how much income you’re going to get. That was a total game changer. So, after a few months I realized that it was predictable. And I could actually find out how to quit my job. And then, that’s when I started crunching the numbers and figured out that if I quit and if my donation growth kept up that my savings would start, they’d dip, and then they start going back up before I hit zero.

    Adam:Oh, that’s clever. Yeah. You calculated not just the amount you would need to survive, but how far you could dip into your savings before you’d come back out the rate of growth or something.

    Andrew:Right. Yeah. With conservative numbers, but the math checked out. Yeah. It was really nerve-wracking and scary, but it turned out even much better than I expected, because the thing that I hadn’t considered is if I quit full-time work and I got to spend full-time work on Zig that would help me make more progress faster.

    Telling Friends and Family I’m going Full-Time

    Adam:Did you run this idea by others? Did you tell your mom, like, “Hey…”

    Andrew:I told my girlfriend. She was really supportive, especially considering the fact that we were renting an apartment in Manhattan and she was still in school and wasn’t ready to start pulling a bunch of money in with her career yet. So, kudos to her for supporting my dream, even when it was like maybe not financially completely stable.

    Adam:She was on board right away?

    Andrew:Yeah. In fact, she actually encouraged me to do it. I think I was wavering a little bit, and she was the one who was saying, “I don’t know why you’re so worried. The numbers check out. I think you’re good.”

    Adam:Was she the person you were afraid to run with this idea too? I just keep thinking of my mom.

    Andrew:Your mom? What would you tell your mom?

    Adam:She doesn’t really totally understand what I do at all, right? I think that it involves computers is the extent of it, right?

    Andrew:Right.

    Adam:So, telling her that I was going to leave my paying job that involves computers for a non-paying job that involves computers. I don’t think-

    Andrew:Right. Yeah. I see the point that you’re making. Yeah. I think for me telling the older generation about this was all kind of fun and games to me. So, for example, my parents are pretty financially conservative. So, just telling my dad like, “Yeah, I’m quitting my job and going to do this like donation thing.” And being just completely… I don’t actually care what his feedback was, because I just, it’s not relevant.

    But it was fun to just kind of make him think like, “Oh, what is my son doing? It doesn’t make any sense, but all right. I guess if it works for you.” And then, my girlfriend’s grandma was the other fun one. I recall she was saying something like, “So, what does he do? He has a tip jar.” It’s like close enough I guess.

    Open Source Self Worth

    Adam:That’s great. Once you did quit, was it everything that you thought it would be? Day one you start-

    Andrew:It was even more. First of all, I’ve never been happier. Second of all, I realized that the freedom that I have has allowed me to open my mind up to just other, even just different politics and ways of thinking about society and how the world works. It’s harder to think about maybe more radical ways that society could run when you have to play the game, and you’re spending 40 or plus hours per week clocked in and just like doing the labor. Not only was it everything I thought I would be, but once I tasted this freedom, I know I will never have a boss again.

    I will go start a farm if I have to. My just sense of worth of self-worth has just skyrocketed and I just, I don’t even want to be subject to another person’s domain anymore. I want everyone to feel this way. I want everyone to feel they get to decide what they do with their life and no one’s going to tell them what they have to do.

    Adam:Did you have a really bad boss?

    Andrew:Actually, no. Well, I did have one or two, but actually no. I’ve had bosses that are fine. I’ve had good bosses. I had a boss that was like a friend, a co-worker before who just kind of went into a manager position. I think that’s why I realized that I never want to have a boss again is that I had a good one and I still really hated him.

    Adam:One thing Andrew hated in his work as a software laborer, which is what he calls it, was the presumption of growth and growing profit. So, to support Zig and to support himself and future contributors, he started the Zig Software Foundation, and he started it as a non-profit.

    Andrew:So, all the income just comes from satisfied users. I mean the product is free. So, the point is we don’t have to grow. There’s no venture capitalists who are breathing down our back saying that we need to monetize our users. The motives that we have for doing features and making progress is just intrinsic. There’s no monetary incentives to do anything in Zig. It’s all just people driven.

    And I think that to me that’s like I’m really happy with it being this way. And it’s something that I didn’t get when I worked at any startups.

    Zig on Hacker News

    Adam:Another thing he didn’t get to do when working at startups was show his work to the world, with Zig, everything was out in the open and early on Zig showed up on hacker news.

    Andrew:A lot of the comments were, “Oh, we don’t need another programming language or this guy’s an idiot. He hasn’t even made a programming language before. This is like his first one.” Not actually true, but that people just say whatever they want to say. It was all just kind of like there’s too many players in the field. Just get out of here, shoo, that kind of thing.

    And I wasn’t fazed at all. I was ready. I knew that was the game and just kept working on making progress in the language and just kept peeling off those layers and re-evaluating like, “What’s the better way to do this? How should the standard library work? How should the language work?” But I also did pay attention to the people who had legitimate complaints.

    So, some of the early legitimate complaints were that the sigils were too noisy. We had percents everywhere. And they’re all gone now. I think that was a legitimate complaint and that it’s now gone. It looks like cleaner. It’s a lot more keyword based and it doesn’t seem to be an issue anymore.

    Adam:Did you jump on when people said this is his first language or this can’t be trusted? Did you respond to them?

    Andrew:I wasn’t shy, but I just kind of tried to only respond if I felt like I could like look good. What are you trying to do in a hacker news trend, right? You’re not actually interacting with someone. What you’re actually doing is putting on a show for the lurkers of which there’s like hundreds of thousands of lurkers. And those are the people who are going to read your comments and be like, “Oh, this guy’s cool. Maybe I want to actually check out the project.”

    I was actually just trying to sell my personality at that point rather than engage with just people saying stupid shit.

    Zig Is Immoral and UnSafe

    Adam:In that first Zig post on hacker news, a lot of the comments were about the impossibility of replacing C, but Andrew hasn’t slowed down, and things being impossible is not the main thing that people bring up right now.

    Andrew:It’s funny how it just kind of changes course as the language gets taken more and more seriously. And now, all the comments are even starting to shift to kind of like the philosophy of memory safety and whether Zig is immoral.

    Adam:The morality comments they come from people who see Zig as competition to Rust, but Andrew doesn’t see it as competition.

    Andrew:So, there’s a lot of ways that these languages can be complementary. And it doesn’t have to be like a zero-sum game, and there’s a lot of ways that these projects can help each other. So, as an example both projects depend on LLVM. So, on the Zig side of things, we’ve submitted a lot of bug fixes upstream to LLVM, especially regarding non x86 architectures, because we just have a really good cross compilation story. Likewise, Rust has submitted a lot of fixes to LLVM having to do with aliasing, because that’s just an important concept in that language.

    It’s not as an important concept in C++, so that’s kind of the changes that they’ve made. So, in this way we can team up, right? That’s great. We’re on the same, we’re all just players in the open source field helping each other out. But there’s always people who want to make it a competition, which one’s better? Which one am I going to use? That sort of thing.

    And so, people will just find ammo to fling. And so, the obvious one that you would pick is, “Well, Rust gives you memory safety and Zig doesn’t.” And the talking point is that’s a fatal flaw. It’s 2021, we can’t have memory on safety in a modern language. I think that they just kind of missed the point. So, the way I would describe it is that Rust has a kind of like vertical memory safety approach where on the top, it’s safe. And then, on the bottom, you hit the unsafe block, and it’s not safe, right?

    Let’s acknowledge that Rust is also unsafe because it has unsafe blocks in it at the bottom layer. Zig is more of I would say horizontal safety approach. So, there’s no unsafe blocks where it’s all contained in, but each feature of the language models safety in a different way.

    Pointers in Zig and Rust

    Andrew:So, as an example, the pointer type in Zig actually can represent alignment. In Rust, if you want to mess with pointer alignment, you have to use an unsafe block and you’ve turned off safety for alignment.

    In Zig, you have pointer alignment in the type. So, it’s actually completely safe, and in Rust it’s not.

    Adam:Okay, pointers. This is a really cool example. So, pointers and C are just raw memory addresses. Just integers that tell you where to look in memory, and you can screw them up in a lot of ways. A pointer can be null. It can be incorrectly aligned and so on. Raw pointers leading to buffer overflows are responsible for many security problems, but pointers are also super useful. Certain system calls, you can’t make them without pointers.

    So, Zig works to make pointers safer. It can’t be null. They have to be optional instead. They know about alignment and so on. Rust has a different strategy. Rust keeps pointers mainly the same as C, but it puts them in unsafe blocks and says, “You really shouldn’t be using these. We have the borrow checker. Zig could have taken this unsafe keyword approach.

    Andrew:I mean if we did that, it would just kind of be Rust. I think this question is also asking why not add a borrow checker? And the answer is Zig also wants to be optimal and optimal means you want to fully use the hardware that you have. So, my hardware lets me use virtual memory and it lets me use intrusive data structures. And it lets me write code in a certain way that’s the most efficient way to use all the CPU and all the memory. So, if my language doesn’t let me use all my hardware features, it’s not optimal.

    Undefined Behavior in Zig

    Adam:Another way to think about this is Zig is less ambitious, intentionally. It’s a smaller language. It’s what if C were better? And one place you can see this is with the handling of undefined behavior.

    Andrew:I think undefined behavior is a misunderstood beast. So, a lot of people think it’s just a crime like, “Why does it exist? It was a mistake to ever have it in the language.” But I think it’s actually a tool. I’ll give you an example. Integer overflow is a simple example.

    So, you can define it so that if you overflow 64-bit integer, it wraps. That’s one way to do it. Now, you don’t have undefined behavior. Okay, but now if you add something in your code and it overflows, and you didn’t expect it to, now you have a bug. And this is a really contrived example, but let’s say it’s like the bank balance or something, and you just went from like a million dollars to zero or something like that.

    That’s a critical bug that happened because of well-defined behavior, whereas if we make integer overflow for just the regular plus operator undefined, then we can compile the program in a safe mode that doesn’t allow it and crashes if it happens. And that’s what you get and debug and release safe builds of Zig.

    So, my point is that undefined behavior lets you catch bugs. And also, let’s say that you had this code now and you’ve tested it. It’s battle tested. It’s done. It’s like some low-level library… No one’s reported a bug in it for 10 years. We’re done working on it, right? It’s finished. It’s like the mp3 encoder or something.

    Now, you can compile it in a different mode and instead of putting a safety check in for the undefined behavior, now we tell the compiler, “Assume that will never happen, and now if it did happen it would be undefined behavior.” But because we know that there’s no bugs, we can actually generate much better code assuming that the undefined behavior will never happen.

    Adam:So, in Zig, if you’re not doing the fastest build then you’re always asserting that this won’t overflow and you crash if that’s the case.

    Andrew:Yeah. Exactly.

    Adam:And that’s better than setting that person’s account to a million from a million to zero or whatever.

    Andrew:That is in accordance with the Zig philosophy, yes.

    Adam:If you’re running in your kind of release mode, you won’t crash on it, right?

    Release Fast in Zig

    Andrew:In release fast mode, which is unsafe, you will get actual undefined behavior. So, you might crash or you might get overflow. You might go down to zero or you might run an unrelated function.

    Adam:Run an unrelated function. That sounds super scary. That’s why you don’t really want to turn off the asserts unless you’re certain that they’re not needed. I could see Andrew using this for the hot loop of his audio software, we’re missing the timing of the audio is almost as bad as crashing. The reason for being able to turn these off is for speed.

    Andrew:And not only that, but by not having the checks, you’re allowing the optimizer to notice patterns that would not be there if the checks were present. So, for example, there may be the array bounds checking maybe is inside a function and by not including the checking, we were actually able to inline that function into the place of the call site. And then, because of the lack of bounds checking, it was then able to see another optimization and flatten that out. It can have snowballing effects to not have these extra checks in there.

    Forking Zig

    Adam:So, while Andrew is pushing Zig forward, trying to tell people that undefined behavior is a tool, not a crime, something bad happens.

    Andrew:Oh, yeah, this story, huh? Yeah. We had this character come in, and at first, he just seemed a really enthusiastic contributor. He did a lot of help with his pull requests, but I didn’t mind. I would just kind of throw in a couple commits, some fix ups, and just merge it, and say, “Yeah, good enough. I’ll help you with the rest.”

    But then all of a sudden, he just blew up at some kind of language decisions. He created a commercial fork, translated the documentation to Japanese, and then if you downloaded it, all the files were just the Zig files, but he just changed the extension to zen.

    Adam:But he was a contributor to a certain extent?

    Andrew:Oh, yeah.

    Adam:It said in something I read that other contributors left with him.

    Andrew:I think that’s not an accurate way to put it, because it implies that there was like some kind of controversy, but what actually happened was that just that one person… This guy’s name is [inaudible 00:37:20]. The thing that actually happened was that just he just got pissed and left and no one else left, but then he offered actual money to one of the core contributors of Zig, and that person accepted the job and started working on the fork.

    So, that’s what happened. And you know what? Fair, because at that point, we didn’t have the Zig Software Foundation yet. We couldn’t offer any money to core contributors. You got to put food on your table, so I really… I don’t even blame them for taking it. They got to probably improve their resume and work on something more fun and get some more money. Fine.

    Adam:So, were there people in Japan who are paying for a fork of Zig?

    Andrew:I really don’t know. Honestly, this guy is a total weirdo. It’s like he’s the kind of person where they’ll share conspicuous photos of themselves, shaking hand with some important person. And then, you’re like, “What? What’s going on? What did you do with that person?” And it’s like, “Oh, we had like a business deal, business transaction.”

    It’s like, “Well, what? What did you do?” And then, it’s all show. A super weirdo guy. I don’t even know how to explain it. I’m not giving you a good synopsis of the story, but let me be clear about this. Commercially forking Zig is fine. It’s MIT-licensed. Like go for it. You’re supposed to give, supposed to just acknowledge in the license that it’s a fork.

    If you just take a file that’s Zig code, and you rename the extension, you have to keep the MIT license in there. That’s fine. Go for it. But what they did with the fork was like be very tricky about it, right? So, they actually deleted the license file, put their own license in it and made it look like you had to pay for the software. So, they put like, “Oh, this is licensed by our company’s license and you have to pay $100 a year or something for it.”

    So, they were deceiving people. That was the problem with what they were doing. As long as you don’t trick people, you’re welcome to do a commercial fork of Zig.

    Adam:Legally it’s fine to fork Zig. It’s allowed as part of the license, but it feels a bit wrong to me. Andrew built this and he deserves some credit for creating it, and if I were Andrew and I left my job to work full-time on this project. And now, had just been forked by a commercial company, I would have freaked out. Andrew is much more calm though.

    Andrew:Honestly, it was more of a curiosity for me. I wasn’t ever worried about it, but I was definitely kind of just curious about, what is this guy’s motive? Didn’t seem like a effective strategy that he was taking.

    Adam:The thing that strikes me as strange is like stealing something that’s free, and then trying to sell it. I guess that’s not totally what’s happening, but it’s sort of what’s happening.

    Andrew:Yeah.

    Adam:People don’t tend to pay for programming languages right now that often I guess.

    Andrew:Right. Right.

    Adam:I mean it’s possible that he was on to something.

    Andrew:He was onto something in the sense that he translated the documentation, and then it became accessible to people who didn’t speak English. A lot of countries don’t have a big enough, like I don’t know cultural impact on the world that they can get away with not speaking English. So, in that way, English is one of the like lingua francas of technology for better or worse, but China, Japan, Russia are big enough that you can just be someone who only speaks those languages.

    Adam:This language barrier is the heart of the issue, but the Zig team had a solution for that.

    Andrew:We put out a little blog post just kind of explaining, “Hey, this other, this thing that you’re paying for, you can get it for free over here if you want. We’re sorry we don’t have the translation of the docs yet, hopefully we can get that soon.” And I think after that blog post… We got that blog post translated into Japanese. And I think that once people saw that and it went around they realized, “Oh, okay, it’s better to just get it from the upstream rather than go for this guy.”

    The Opposite of Imposter Syndrome

    Adam:It’s strange how this stuff, it doesn’t faze Andrew. Of course, I can improve upon C, of course, I could take on a commercial fork. People have talked to death the imposter syndrome, but this is the opposite. Andrew is just very assertive and confident in what he can accomplish.

    Andrew:From the very beginning, my attitude was, “Let’s fucking do this. Let’s go. I’m not fooling around.” When you first make a project, obviously, you’re not unique, you’re not a unicorn. A lot of people made a programming language that’s not impressive, that’s not interesting. So, people are calling it a toy language at the very beginning.

    And that’s good. I just let it slide. Part of the job I have to do is marketing and getting people to be excited about it. So, I know that having a reputation of a toy language in the beginning is okay and I’m not going to fight about it. But in my head I was thinking, “Oh, just wait. This ain’t no toy.”

    Adam:That’s awesome. I love that. If you were going to run a marathon a lot of people have a goal to finish the marathon I guess, but you’re like, “I’m going to win it.”

    Andrew:Yeah.

    Adam:And take down C.

    Andrew:Let’s go. Yeah.

    Adam:Yeah.

    Andrew:I do feel like I have a sense for like what’s cool and what’s kind of cringy. If your posts make it under Reddit or something. And so, I definitely have been very conscious about, how am I going to come off to people so that I don’t seem like too arrogant and too big for his britches or something even though I am?

    Adam:Yeah. Because in the back of your head you’re like, “Yeah. We’re taking down C.” But you’re like, I’m just going to… Let’s get people slowly introduced to this concept.

    Andrew:Yeah. Exactly.

    The Future of Zig

    Adam:What does the world look like when you take down C like?

    Andrew:Oh, it’s beautiful. It looks mostly the same, except all your apps just work slightly better, and they just crash less often, and they use less memory, and they just go faster. When professors teach operating system courses, it’ll just be like obviously assumed that you just use Zig. That’s not the focus. That’s just the setting when textbooks try to do how operating systems work or how embedded devices work, it’ll just be like assumed that you’re going to use Zig as the example code, because that’s just what everyone does.

    The world won’t really be that much different, it’ll just be just a better programming experience for everyone. So, in one sense I have a lot of ambition because I am trying to dethrone this entrenched player, but on the other sense, Zig is not actually a super ambitious language. It’s just trying to take it to the next level of faster, less memory, less bugs, better development experience, better end user experience. Just a little bit better.

    Adam:So, it’s just an incremental improvement on C?

    Andrew:Yep. So, that’s kind of the yin-yang of ambition there.

    Adam:There’s no vision of you accepting your Turing award and… Yeah.

    Andrew:No. Everyone will just be like a little less stressed in their daily lives as a programmer. That’s it.

    Advice for Open Source Developers

    Adam:Andrew is five years into building Zig and five years is a long time and Zig is more than just him now. The Zig Software Foundation is now supporting other full-time employees, and this is all through donations. Andrew has some tips for self-funding your own open source projects.

    Andrew:I think that there’s no better time than now for people who’s trying to make a living in an unconventional way. My advice is do it because you love it and don’t be afraid to put yourself out there on the crowdfunding platforms and ask for tips and don’t expect overnight success. I also think that people do want a, they want something to believe in, right?

    I think with early days of Zig the feeling that I was kind of offering was, we’re going to take on C, right? This is an ambitious project, but I’m here to stick with it. I’m here to pull it off. Let’s go. Let’s do this. And that was a vibe people can get on board with.

    Let’s do this. Let’s go.

    Putting Out My Tip Jar

    Adam:That was the show. I find Andrew to be a very inspiring person. So, it’s time for me to put out my own tip jar. If you go to patreon.com/adamgordonbell, you can find the patreon page for the podcast, and if you are enjoying these episodes and want me to keep putting more time into them, think about setting up a recurring donation.

    It takes me a lot of time to make each episode, and that’s why I’m only able to make one a month right now. So, if you want to support the show, check it out. I’ll put a link in the show notes and on the webpage as well.

    Until next time, let’s do this. Let’s go or sorry. I mean thank you so much for listening.

    Support CoRecursive

    Hello,
    I make CoRecursive because I love it when someone shares the details behind some project, some bug, or some incident with me. No other podcast was telling stories quite like I wanted to hear. Right now this is all done by just me and I love doing it, but it's also exhausting. Recommending the show to others and contributing to this patreon are the biggest things you can do to help out.
    Whatever you can do to help, I truly appreciate it!

    - Adam Gordon Bell

    Audio Player
    back 15
    forward 60s
    00:00
    00:00
    46:08

    Full-Time Open Source