Declarative, Imperative in computer science


In computer science, declarative programming is a programming paradigm—a style of building the structure and elements of computer programs—that expresses the logic of a computation without describing its control flow. This is in contrast with imperative programming, which implements algorithms in explicit steps.[1]

For example.

// Declarative
function getSharks(){
  var sharks = [];
  for (var i = 0; i < ...) {
  return sharks;

// Imperative
Select * FROM animal WHERE sth='sharks';
Buy Me A Coffee