I started hacking with TRS-80 Basic long ago. By the time I went pro in my early 20's, I had already developed a strong preference for declarative systems, so much so that I would from time to time create one if it made the solution at hand more robust. Having studied Physics instead of CompSci, I came to this preference outside of any knowledge of the existing arguments for/against or the vocabulary used in the literature. For me it was a simple process: discern common patterns in the imperative code, establish a data structure that captured them, write something to process them.
The commercial motivation was always the correctness guarantee, but the yak-shaving exercise of building the system offered the satisfaction that purely commercial concerns could not provide.
Now, in the dawn of the age of LLM coding, I find the agents are "unreasonably effective" at coding to declarative systems. The entire reference for the data format or DSL can fit in context, and LLMs are naturally more reliable against a constrained system. Compare to CSS, highly unconstrained, where I find code duplication, then conflict, then the inevitable `!important` flags begin to proliferate.
Yet, as anybody who enjoys the benefits of declarative systems will tell you, it can be lonely. The world prefers a general purpose imperative system. I believe the biggest reason is that the open-ended imperative system does not force us into a mapping exercise before we get to work. The code is like a whiteboard, where ideas are tried and modified in flight.
But I'd like to hear from others. Which do you prefer and why? In what situations?
I was trying to figure out what you meant by "declarative" because CSS is declarative. (My understanding is: "declarative means you say (declare) what you want, but not how to get it." Usually SQL is the poster child of declarative languages.)
I think you're really talking about a mix of preferring data (vs actions/calculations) and DSLs (which aren't necessarily declarative)
Eric Normand has some thoughts you might appreciate:
- How a problem might take 1000 SLOC to solve directly, but only 10 SLOC with a DSL (plus up to 500 SLOC for the DSL itself; still fewer lines total) https://ericnormand.me/podcast/magical-leverage-languages
- Data vs calculations vs actions: https://ericnormand.me/podcast/what-is-an-action
---
I think data can be very powerful. For example, someone explained to me:
> I've been helping my non-tech father with Home Assistant. I've honestly been shocked with how far "community extensions" + "user configuration" can take you. Every time we hit a bug, I go "time to hit github" but without fail chatgpt and him are able to tweak a setting to get it working.
If you make your system configurable (config==data), you can skip the whole compile/build step!
reply