DEV Community

Discussion on: Declarative Programming

Collapse
 
sargalias profile image
Spyros Argalias

You make good points, and I completely agree, but let me be a bit pedantic on what I meant.

I meant that the "aha" moment for me was when I completely disregarded the "how" and "what", and instead saw declarative programming as a higher level of abstraction to work with.

It's good to separate concerns and abstract where possible, and functional programming takes that to the extreme. It encourages extremely tiny unit functions with no logic duplication.

That's what 95% of declarative programming is (in my opinion). Abstract / extract everything you can, so instead of 10 lines with a for loop, you've got a single line with a map. Heck, if you could abstract the map away, do that as well. As another example, point-free seems the same to me. Is there any reason for point-free other than not creating the exact same function with points repeated? It just seems like extreme abstraction and separation of concerns.

The "how" and "what" are the consequence of that. Afterwards, keeping the concepts of "how" and "what" in mind is an optional cherry on top.