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

DHH · 2025-07-12 · source ↗ · whole document (23)

Rails manifesto: Principles of a great programming language

`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

`2:15:06`

is not so much try to abstract the SQL away behind a different kind of paradigm. It's just making it less cumbersome to write. Making it more amenable to build domain models on top of other domain models in a ways that you don't have to write every damn SQL statement by hand. — We'll just say the active record is an ORM, which is a layer that makes it intuitive and human interpretable to communicate with a database. — Even simpler than that. It turns tables into classes and rows into objects. I actually think SQL is very easy to understand most of it. You can write some SQL golf too. That's very hard to understand. But SQL at its base, and much of the criticism against SQL was it was written for human consumption. It's actually quite verbose, especially if you're doing things like inserts over and over again. It's quite verbose insert into table parentheses, enumerate every column you want to insert, values, parentheses, every value that fits with that column. It gets tedious to write SQL by hand,

`2:16:09`

but it's actually very humanly readable. Active record just takes that tedious away. It makes it possible to combine things in a way that a humanly describable language just doesn't. It composes things into methods and you can combine these methods and you can build structures around them. So I don't dislike SQL, I dislike a lot of things in programming. I try to get rid of them. SQL wasn't really one of them. It was just a sense of I don't wanna write the same thing over and over again. It was a, can we be a little more succinct? Can we match it just slightly better to the optic orientation without trying to hide away the fact that we're persisting these objects into a database. That's where I think a lot of ORMs went wrong. They tried to live in the pure world of objects. Never to consider that those objects had to be consistent into a SQL database and then they came up with convoluted way of translating back and forth. Active record says, do you know what? Just accept it. This record, this object is not gonna get saved into some NoSQL database.

`2:17:09`

It's not gonna be saved. It's gonna be saved into SQL database. So it's just structure the whole thing around that. It's gonna have attributes. Those attributes are gonna respond to columns in the database. It's not more complicated than that stuff making it so. — Yeah, but I should say, so I personally love SQL because I'm an algorithms person and so I love optimization. I love to know how the databases actually work so I can match the SQL queries and the design of the table such that there is, you know, optimal, squeeze the optimal performance out of the table. Okay, based on the actual way that that table is used. So I mean, I think that pushes to the point that like there is value in learning in understanding SQL. I wonder, because I started looking at active record and it looks really awesome. Does that make you lazy? Not you, but a person that rolls in and starts using Rails you can probably get away with never really learning SQL, right?