Back to home

Procedural ProgramObject OrientedDeclarativeFunctionalReactive
Basics On Programming Paradigms main image

Basics On Programming Paradigms

Procedural Program

  • The ideas that programs are a sense of functions
  • Goes from top to bottom
  • Relies heavily on global state, but any line can change the global state
  • C being a procedural language
  • "Imperative" execution
  • Easy to write, difficult to maintain
  • Prone to difficult bugs

Object Oriented

  • Based around a Primitive: object
  • Objects have well defined interfaces
  • Localised behaviour
  • Objects control state
  • Composition
  • Code is still imperative - pro AND con! - Still telling the computer EXACTLY what to do.
  • Can be more verbose

Declarative

  • Describing what you want to happen, but not telling the computer how to do it
  • Eg. SQL, Regex, HTML
  • Data is self-describing
  • As powerful as the interpreter allows
  • As limiting as the interpreter allows - You want build a game in SQL etc.

Functional

  • What we want to happen but not how
  • Little state
  • Few side effects
  • Easy to reason about
  • Composition
  • Expressive
  • Works great with OO
  • Basis in higher math
  • Cons to think differently
  • Not always the best choice
  • No loops, no control logic - Just telling it what we want to happen

Reactive

  • Primitive: Observable
  • Instead of describing data in terms of other data, we describe it in terms of streams of events - From this, we create a pipeline such that we certain data changes, a lot is processed and changed - Example: spreadsheets!
  • Composition
  • Expressive
  • Data flows unidirectionally
  • Tough to think differently
  • Subscriptions help change the data
1 2 3 4 5 6 7 const cellC2$ = cellA2$ .combineLatest(cellB2$) .map((cells) => cells[0] + cells[1]); cellC2$.subscribe((value) => { console.log(value); });

Dennis O'Keeffe

@dennisokeeffe92
  • Melbourne, Australia

Hi, I am a professional Software Engineer. Formerly of Culture Amp, UsabilityHub, Present Company and NightGuru.
I am currently working on workingoutloud.dev, Den Dribbles and LandPad .

Related articles


1,200+ PEOPLE ALREADY JOINED ❤️️

Get fresh posts + news direct to your inbox.

No spam. We only send you relevant content.