Post

Functional/Sequential/Procedural/Imperative/Declarative Programming

Screenshot 2024-08-14 at 00 29 40

❤️ Imperative 명령형

🆚 Declarative
focus more on how

  • Procedural Programming
  • OOP

💙 Declarative 선언형

🆚 Imperative
program by expressing logic of computation withoug talking about control flow
focus more on what needs to be done than how
declare the result we want

  • Logic Programming
  • Functional Programming
  • Database

❤️ Procedural Programming 절차 지향

procedures that perform specific tasks
sequence, steps, procedure
focuses on the order of procedures

  • if order changes, the result will change
  • 👍🏻 similar to computer operation, fast in running
  • C, Pascal, Fortran

❤️ OOP 객체 지향

object: instance of class
organize code around object and their interaction

  • Encapsulation, Abstaction, Inheritence, Polymorphism
  • 👎🏻 slower than procedual programming
  • Java, C++, Python, Ruby

💡 https://soheeparklee.github.io/posts/cs-4OOP/

❤️ Parallel Processing

  • program instructions by dividing them among multiple processors

💙 Logic Programming

abstract model of computation
knowledge and problem to solve

💙 Functional Programming

mathematical functions
pure functions: don’t alter state or rely on external state

  • Pure functions
    • more than one pararmeter
    • no variable other than parameter
  • Function composition
  • Avoid shared state
  • Avoid mutating state
  • Avoid side effects

  • Haskell, Scala, functional features in Python and JS
1
2
3
4
var arr = [1, 2, 3, 4, 5];
var map = arr.map(function (x) {
  return x * 2;
}); // [2, 4, 6, 8, 10]

✔️ Functional Programming in JAVA

  • lamda
  • stream api
  • functional interface

✅ Sequential Programming

linear execution of instructions
each statement is executed in order

  • part of procedural programming

🆚 Procedural Programming

  • Procedural programming is a broader paradigm that includes sequential execution
  • also involves organizing code into procedures
  • include loops and conditionals
This post is licensed under CC BY 4.0 by the author.