DHH · 2025-07-12 · source ↗ · whole document (23)
Rails manifesto: Principles of a great programming language
`2:09:58`
and you can chain 'em together very much in the spirit of how true functional programming languages worked. Ruby has even moved closer towards the functional programming and of the scale by making strings immutable. There are ideas from all different disciplines and all different paradigms of software development that can fit together. Smalltalk, for example. With only object oriented, and that was just it. Ruby tries to be mainly object oriented, but borrow a little bit of functional programming, a little bit of imperative programming, be able to do all of that. Rails tries to do the same thing. We're not just gonna pick one paradigm and run it through everything. Object orientation is at the center of it, but it's okay to invite all these other disciplines and it's okay to be inspired. It's okay to remix it. I actually think one of the main benefits of Rails is that it's a remix. I didn't invent all these ideas. I didn't come up with active record. I didn't come up with the NBC way of dividing an application. I took all the great ideas that I had learned and picked up from every different camp
`2:11:01`
and I put it together. Not because there was gonna be just one single overarching theory of everything, but I was gonna have a cohesive unit that incorporated the best from everywhere. — Is that idea a bit at tension with the beauty of the monolith system? — I think the monolith can be thought of as quite roomy, quite as a big tent that the monolith needs actually to borrow a little bit of functional programming for the kinds of problems that that excels, that discipline excels at solving, and that paradigm excels at solving. If you also want object orientation at its core. I actually think when I've looked at functional programming languages, there's a lot to love. And then I see some of the crazy contortions they have to go through when part of the problem they're solving calls for mutating something. And you go like, holy shit, this is a great paradigm from 90% of the problem. And then you're twisting yourself completely out of shape when you try to solve the last 10. — Ooh, exalt beautiful code is in the next one.
`2:12:03`
— We've talked about that at length and here's a great example that really summarizes the domain specific language quality of Ruby on Rails that you can make code actually pleasant to write and read. Which is really funny to me because as we talked about when I started learning programming, it wasn't even a consideration. I didn't even know that that could be part of the premise, that could be part of the solution. That writing code could feel as good as writing a poem. — class Project, ApplicationRecord belongs_to:account has many participants. Class_name, Person, validates_presence_of:name. — See, you could read it out. You didn't even change. — Anything like a haiku or something. — Right? Isn't that beautiful? — Yeah, it's nice. It's really nice. There's an intuitive nature to it. Okay, so I have specific questions there. I mean ActiveRecord, just to take that tangent. That has to be your favorite feature. — It's the crown jewel of Rails. It really is.
`2:13:04`
It is the defining characteristic of how to work with Ruby on Rails. And it's born in an interesting level of controversy, because it actually uses a pattern that had been described by Martin Fowler in the "Patterns of Enterprise Application Architecture." One of the greatest books for anyone working on business systems. And if you had not read it, you must pick it up immediately. "Patterns of Enterprise Application Architecture," I think it was published in 2001. It is one of the very few programming books that I have read many times over. It's incredible. In it, Martin describes a bunch of different patterns of how to build business systems essentially. And ActiveRecord is a little bit of a footnote in there. The pattern is literally called active record. You can look it up. — Nice. — It's called active record. I wasn't even creative enough to come up with a name of my own. But it allows the creation, the marriage of database and object orientation in a way that a lot of programmers find a little off-putting. They don't actually want to pollute
`2:14:05`
the beautiful object-oriented nature of that kind of programming with SQL. There was a rant by Uncle Bob the other day about how SQL is the worst thing ever. Baba, okay fine, whatever, I don't care. This is practical. We are making CRUD applications. You're taking things out of an HTML form and you're sticking 'em into a damn database. It's not more complicated than that. The more abstractions you put in between those two ends of the spectrum, the more you're just fooling yourself. This is what we're doing. We're talking to SQL databases. By the way, quick aside, SQL was one of those things that have endured the onslaught of NoSQL databases structured list data for a better part of a decade and still reign supreme. SQL was a good thing to invest your time in learning. Every program I'm working with the web should know SQL to a fair degree. Even if they're working with an ORM, an optic relational map or as active record. You still need to understand SQL. What Active record does