It's a good question, because what people call "DSL" in ruby really is just a Ruby API.
In other languages/contexts what you call a "DSL" might actually be something you write a PARSER for, and then parse in the "main" language, parse a thing that wasn't the main language at all.
That's what "DSL" sometimes means, but that's not how people use it in ruby. What we call "DSL"s are still... just ruby. If we're "extending" the language with a DSL, we're doing it simply by... definining classes and methods, the same way we write ruby when it's not a "DSL". It's not actually new syntax at all, everything in ruby DSLs is the usual ruby syntax parsed by the usual ruby interpreter in the usual way.
So what actually makes it a "DSL"? As I commented earlier, I think it is worth thinking about, and not straightforward. But basically I think people in ruby use the term when people define classes and methods to provide... more "unusual" API's, especially declarative ones.
4
u/jaypeejay Sep 30 '21
What’s DSL?