DHH · 2025-07-12 · source ↗ · whole document (17)
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,