Friday, November 10, 2006

Cumulative DSLs

I like first class constructs. Every time the language gurus out there manage to find an old thing they overlooked, a thing which wasn't first-class yet, and promote it to a first-class citizen, the programming world gets better. At least for those who aren't prevented from using the language by company rules.

It's not an issue of fairness at all. I'd like everything to be first-class, but not for the same reason that I'd like everyone to be allowed to vote, think, speak and live respectably. In fact it's quite the opposite: I'm being completely selfish.

I don't want the language designers to be involved in my design decisions. I want all the power for myself, because the solutions I dream up are fabulously elegant and who do they think they are, thinking in general-purpose terms and leaving the actual programmers that do the real work trapped with their domain-specific problems.

So I (sometimes) end up reinventing the wheel by writing my own domain-specific language. But my languages are small and boring and what I really wanted was all the general-purpose stuff plus this one new weird kind of method dispatch. And while we're at it, also throw in a new kind of literal for this custom type I always use. And a new module system which handles versions. And this new scoping rule for variables whose name begins with $$. If my general-purpose language had first-class dispatchers and first-class literal parsers and first-class module-resolution rules and first-class scoping rules, then I could implement all of this at my leisure. So what's stopping people from implementing a general-purpose language in which every single thing would truly be utterly and completely first-class?

I have an hypothesis: language designers are doing their best, but getting it right is simply really really hard.