DEV Community

Cover image for Declarative vs Imperative - Vader Buys a Cake
Odai Athamneh
Odai Athamneh

Posted on

Declarative vs Imperative - Vader Buys a Cake

Photo by TOMMY VAN KESSEL on Unsplash


There are 2 main programming paradigms:

  • Declarative. What to do. Think SQL.
  • Imperative. How to do it. Think C++.

๐ŸŽ‚ Vader Buys A Cake

As a memory trick, let's imagine buying a chocolate cake with each approach.

  • Declarative: You go to the bakery and declare you want one. You don't care how it gets done, you just want the final product.
  • Imperative: You stand over the baker and tell him exactly what to do. The imperial march plays in the background.

Other Paradigms

Here's how a few other common approaches can be categorized:

๐Ÿ“ข Declarative ๐ŸŽ‚ Cake
Procedural Programming Logical Programming
Object Oriented Functional Programming
Parallel Processing Database Queries

Top comments (0)