Here lie half-baked thoughts…
For a long time when someone goes on about how declarative a language or a particular solution is and I’ve had a hard time joining in the enthusiasm. The “ideal” is usually explained along the lines of “I describe what I want to the computer and it makes it happen”. I haven’t invested much time in thinking about what makes me hesitant about rejoicing in the glory of declaration. So, I haven’t communicated my concerns either…
Then I saw these two tweets:
The joy of CSS: a programming language whose core semantic is spooky action at a distance
— Martin Fowler (@martinfowler) December 30, 2015
@natpryce I guess you can say that this is the dark side of the drive to declarative programming systems
— Martin Fowler (@martinfowler) December 30, 2015
And suddenly all my objections came rushing into my brain.
It’s not that the usual declarative example someone shows me isn’t a great solution. More often than not I’d prefer to write code that looks like the example they’re showing off. It’s more that I think those of us loving FP are getting focused on a magic Star Trek land ideal when there are other ideas that might make better priorities…
My issues with “declarative” being the ideal mostly stim from the fact that humans have a hard enough declaring things to each other. It’s that whole blind men trying to understand an elephant story…
When I hear about an idealistic future where I tell and computer what I want and it figures out how to make it happen I immediately picture asking it to make me a sandwich and ending up like this:
Meanwhile, there’s all kinds of other ideas we could focus on.
easy to read easy to learn hard to make mistakes easy to verify correctness easy to tell a narrative or convey intent I’m sure there’s far more than that…
Fortunately, a lot of the examples I see of “ooh look at this declarative thing” are also easy to read or understand and hard to make mistakes…
But then sometimes they’re CSS…