Superintelligence CouncilСовет гения · sim.im

DHH · 2025-07-12 · transcript-lex-474-2025 · source ↗

Beautiful code

`0:46:10`

Now you're iterating over the code in that bracket five times, that's it. — [Lex] Okay, that's nice. — That's not just nice, that's exceptional. There's literally no other programming language that I know of that has managed to boil away the line noise that almost every other programming language would inject into a five time iteration over a block of code to that extent. — Wow, that's a really nice, well, thank you for giving that example. That's a beautiful example. Wow, I don't think I know what programming language that does that. That's really nice. — Ruby is full of that. So let me dive into a couple of examples. Because I really think it helps paint the picture. And let me preface this by saying I actually, I like the ethos of Python. I think the Ruby and the Python community share a lot of similarities. They're both dynamic interpreted languages. They're both focused on immediacy and productivity and ease of use in a bunch of ways. But then they're also very different in many other ways. And one of the one ways they're very different is aesthetically.

`0:47:11`

Python, to me, I hope I don't offend people too much. I've said this before, it's ugly. And it's ugly in its space, because it's full of superfluous instructions that are necessary for legacy reasons of when Guido made Python back in '87 that are still here in 2025. And my brain can't cope with that. Let me give you a basic example. When you make a class in Python, the initialize a method, the starting method is def. Okay, fair enough. That's actually the same as Ruby, D-E-F, definition of a method. Then it is underscore, not one, underscore, two, init, underscore, underscore, parentheses start, self, comma, and then the first argument. — [Lex] Yeah, the whole self thing. — I look at that and go, I'm sorry I'm out. I can't do it. It's everything about it

`0:48:12`

offends my sensibilities to the core. Here you have the most important method that all new objects or classes have to implement. And it is one of the most aesthetically offensive ways of typing initialized that I've ever seen anywhere. And you guys are okay with this? — Hey, you're making me, you know, where you're like talking about my marriage or something like this, and I'm not realizing I've been in a toxic relationship all along. Yet, I just get used to it. — That to me, by the way, was the magic of Ruby. It opened my eyes to help beautiful program could be. I didn't know I'd been working in ASP. I'd been working in PHP. I didn't even have the concept that aesthetics beautiful code was something we could optimize for that. Something we could pursue. And even more than that, that we could pursue it above other objectives. That Ruby is as beautiful as it is. It's not an accident and it's not easy. Ruby itself is implemented in C. It's very difficult to parse Ruby code,

`0:49:14`

because Ruby is written for humans and humans are messy creatures. They like things in just the right way. I can't fully explain why the __init___ make me repulse, but it does. And when I look at the Ruby alternative, it's really instructive. So it's def, same part, D-E-F, space, initialize, parentheses. Not even parentheses. If you don't need to call it within the arguments, there's not even a parentheses. That in itself is actually also a major part. If the human doesn't need the additional characters, we're not just gonna put them in because it'd be nicer to parse for the computer. We're gonna get rid of the semicolons. We're gonna get rid of the parentheses. We're gonna get rid of the underscores. We're gonna get rid of all that ugliness, all the line noise and boil it down to its pure essentials. And at the same time, we're not gonna abbreviate. This is a key difference in the aesthetics between Ruby and Python as well.

`0:50:14`

init, short of type, it's only five characters. Initialize is a lot longer, but it looks a lot better and you don't type it very often. So you should look at something pretty. If you don't have to do it all the time, it's okay that it's long. Those kinds of aesthetic evaluations are rife all over the Ruby language. But let me give you an even better example. The if conditional. That's the bedrock of all programming languages. They have the if conditional. If you take most programming languages, they all have if. That's basically the same in almost every language. Space, start parentheses, we all do that. And then you have perhaps, let's say you're calling a object called user.isadmin, close parentheses, close parentheses, start brackets, and here's what we're gonna do if the user is an admin, right? That would be a normal programming language. Ruby doesn't do it like that.

`0:51:15`

Ruby boils almost all of it away. We start with the if. Okay, that's the same. No parenthesis necessary because there's no ambiguity for the human to distinguish that the next part is just a single statement. So you do if, space, user, dot, admin, question mark. No open brackets, no parentheses, no nothing. Next, open line. Here's your conditional. That question mark means nothing to the computer, but it meets something to the human. Ruby put in the predicate method style purely as a communication tool between humans. It's actually more work for the interpreter to be able to see that this question mark is there. Why is this question mark in here? Because it just reads so nicely. If user.admin?

`0:52:15`

That's a very human phrase, but it gets better. You can turn this around. You can have your statement you want to execute before the conditional. You can do user.upgrade. Say you're calling an upgrade method on a user. Space, if, space, user.admin?. We do the thing if the thing is true. Instead of saying, if the thing is true, do the thing. But it gets even better. This is why I love this example with the conditional, because you can keep diving into it. So let's flip it around. user.downgrade if!not user.admin, right? That'd be a typical way of writing it. Ruby goes, that exclamation point is light noise. Why do we have if and then an exclamation point, that's ugly. We could do user.downgrade unless user.admin?

`0:53:17`

That to me is an encapsulation of the incredible beauty that Ruby affords the programmer through ambiguity that is only to serve the human reader and writer. All of these statements we've just discussed, they're the same for the computer. It'll combine down to the same C code. That'll compile down to the same assembly code. It makes no difference whatsoever. In fact, it just makes it harder to write an interpreter. But for the human who gets to choose whether the statement comes before the conditional or the predicate method has, it's just incredible. It reads like poetry at some point. — It's also incredible that, you know, one language designer's creating that, you know, Guido van Rossum also, it's like one person gets to make these extremely difficult decision because you have to think about how does that all get parsed? And you have to think about the thousands, if it's a popular language that millions of people that end up using this.

`0:54:17`

And what they feel, what that question mark for the if statement, what does that feel like for the user? — That's what Matz thought about because he started his entire mission off a different premise than almost every programming language designer that I'd heard, at least articulate the vision. That his number one goal was programmer happiness. That his number one goal was the affordances that would allow programmers to articulate code in ways that not just execute it correctly, but were a joy to write and were a joy to read. And that vision is based on a fundamentally different view of humanity. There's no greater contrast between Matz and James Gosling, the designer of Java. I wanted to listen to James talk about the design of Java. Why was it the way it was? Why was it so rigid? And he was very blunt about it, which, by the way, I really appreciate. And I think Gosling has done a tremendous job with Java.

`0:55:20`

But his view of humanity is rather dark. His view of humanity was programmers at the average are stupid creatures. They cannot be trusted, which sophisticated programming languages because they're gonna shoot their foot off or their handoff. And that would be kind of inconvenient to the regional development office of a mid-tier insurance company writing code that has to last for 20 years. Now it's actually a very Thomas-Sowell view of constrained capacity in humans that I've come to appreciate much later in life. But it's also a very depressing view of programmers that there are just certain programmers who are too dumb to appreciate code poetry. There are too ignorant to learn how to write it well. We need to give them a sandbox where they just won't hurt themselves too much. Matz went the completely opposite direction.

`0:56:23`

He believes in humanity. He believes in the unlimited capacity of programmers to learn and become better. So much so that he's willing to put the stranger at his own level. This is the second part I truly appreciate about Ruby. Ruby allows you to extend base classes. You know how we just talked about 5.times is a way to iterate over a statement five times? That five is obviously a base class. It's a number. Do you know what? You can add your own methods to that. I did, extensively. In Rails, we have something called active support, which is essentially my dialect of Ruby for programming web applications. And I'll give you one example. I've added a method called days to the Number. So if you do 5.days, you get five days in seconds. Because seconds is the way we set cache expiration times

`0:57:26`

and other things like that. So you can say cache expires in 5.days. And you're gonna get whatever's five times — That's nice. — 24 times 60 times 60 is, or whatever the math is, right? Very humanly readable. In a novel programming language, you would type out the seconds and then you would have a little comment above it saying this represent five days. In Ruby, you get to write five days. But even better than that, Matz didn't come up with it. Matz didn't need the five days. I needed that because I needed to expire caches. I was allowed by Matz to extend his story with my own chapters unequal footing, such that a reader Ruby could not tell the difference between the code Matz wrote and the code that I wrote. He trusted me as a complete stranger from Denmark who had never met to mess with his beautiful story. That level of trust is essentially unheard of.

`0:58:27`

I know there are other program languages that allow things with macros and so forth. But none do it in a way like Ruby does it. None does it with an articulated vision of humanity, a trust in humanity like Matz does, that is the opposite end of the spectrum of Java. — Yeah, I mean for my aesthetic sensibilities, just the way you describe 5.days, that's really pleasant to me. Like I could see myself sitting alone, sleep deprived, and just writing that. It's just an easy thing. You can write it in a long way with a comment. You can write multiple lines. You could do, and now with AI, I'm sure it's gonna generate it correctly, but there's something really pleasant about the simplicity of that. I'm not sure what that is. But you're right, there is a good feeling there. And I'm sure we'll talk about happiness from all kinds of philosophical angles, but you know, that is what happiness is made of. That little — Exactly. — good feeling there.

`0:59:28`

— It's the good feeling that come out of a concept compressed to its pure essence. There's nothing you can take away from that statement that's superfluous. — But see, I also wanna push back a little bit 'cause I also a program named Perl a bunch. Just be cool. So like it's not all about compression. — No, you can compress it too far. Perl golf is a thing where you can turn programs into something that's unreadable for humans. Now the great thing about Perl was that it came out before Ruby. Matz was a great student of Wall, was a great student of Perl, was a great student of Python and Smalltalk and Lisp. He took inspiration from all of these prior attempts at creating good programming languages and really edited down the very best bits into this. So he was able to learn from his lessons. But what I found incredible about Ruby is that here we are 2025,

`1:00:29`

Ruby has been worked on for over 30 years, and essentially the first draft is 90% of what we're still using. There was almost a sense of divine inspiration possible in wherever Matz was writing that initial version of Ruby that transcended time to such a degree that no one has still even begun to reach it. This is the other thing I always find fascinating. I generally believe in the efficient market theory that if someone comes up with a better mousetrap or better idea, others will eventually copy them to such an extent that perhaps the original mousetrap is no longer even remembered. No one has been able to copy that essence of Ruby. They borrowed elements, that's totally fine, but Ruby still stands taller than everyone else on these metrics, on this trust in humanity and programmers. — And we should also say like, you know, maybe the perfect programming language that metric and then there's the successful language and those are often different.

`1:01:30`

There's something wonderful about the Brendan Eich story of creating JavaScript. There's something truly beautiful about the way JavaScript took over the world. I've recently got to visit the Amazon jungle and just one of my favorite things to do is just to watch the ants take over anything, everything. And it's just like it's a nice distributor system. It's a messy thing that doesn't seem to be ordered, but it just works and the machinery of it. — Worse is Better. Worse is Better. I mean that's actually the name of a pattern in software development and other ways of how do is the pattern of Linux. Linux was quantifiably worse than I think it was Minx at the time. Other ways of it that were more cathedral less bizarre and it's still one that there's something to it that the imperfections can help something go forward. It's actually a trick I've studied to the degree that I now incorporated in almost all open source that I do. I make sure that when I release the first version

`1:02:32`

of any new thing I work on, it's a little broken. It's a little busted in ways that invite people to come in and help me. Because there's no easier way to get the collaboration of other programmers than to put something out that they know how to fix and improve. — Yeah, that's awesome. — But Ruby is somehow, or was at least a little bit different in that regard. Not in all regards. Matz got the ethos of the language, the design of language just right. But the first versions of Ruby were terribly slow. It's taken, I mean hundreds of man years to get Ruby to be both this beautiful yet also highly efficient and really fast. — And we should say that the thing that made you fall in love with this particular programming language is metaprogramming? — Yes, so that takes all of these elements we've just talked about and turned them up to 11. I'll explain metaprogramming real quick. — Yeah, please. — Metaprogramming is essentially a version of the 5.days.