Search code examples
theoryabstractiondeclarativeparadigmsimperative

What is the difference between abstraction and declarative programming?


Declarative programming seems to be achievable through abstraction. So what's the difference between abstraction and declarative programming?

[ My thought ]

I will call the person using the class "server" and the person using the class "client".

I think Declarative programming or Imperative programming is not determined by "server". It depends on how "client" uses it. "client" can construct abstracted functions both declaratively and imperatively. So, I think abstraction is a term used in "server" and Declarative programming or Imperative programming is a term used in "client".

I'm lost because I can't find a good explanation. How should I understand it?


Solution

  • Abstraction is the process of hiding the details of a complex system/process and presenting only the essential information to the user. It can be achieved through various ways, like encapsulation, inheritance, and polymorphism in object-oriented programming, or through the use of functions,higher-order functions in functional programming. The goal of abstraction is to simplify the complexity of a system by focusing on the essential features and ignoring the details that are not relevant to the current task.

    Declarative programming is a programming paradigm that emphasizes specifying what a program should do, rather than how it should do it. Here the programmer specifies the desired output, and the program automatically determines the steps necessary to achieve that result. Declarative programming languages often use high-level abstractions and allow the programmer to specify constraints and requirements rather than algorithms. Examples include SQL, Prolog, and Haskell.

    Conclusion:-Abstraction is a general concept that refers to the process of hiding complexity and focusing on the essential features of a system, while declarative programming is a specific programming paradigm that emphasizes specifying what a program should do rather than how it should do it.