DEV Community

Discussion on: Imperative vs Declarative programming. Your enemy is not object-oriented programming.

Collapse
 
jmarkmurphy profile image
Mark Murphy • Edited

I'm not sure what you described is declarative. In fact, you explicitly told how to do it. Not in as much detail as the first example, but there us definitely still an explicit sequence of events.

Declarative languages don't just hide a procedure behind a method name. Take SQL for example. You describe what rows you want from the database, and SQL goes about retrieving them. It could be just reading through the whole table and picking out the selected rows, using an index, or something entirely different, and which method it chooses has less to do with the way the code was written than it has with the structure of the database and the characteristics of the data. Not arguing against proper abstraction, but just saying that abstracting out details doesn't make a technique declarative.