Programming Paradims for Software Engineering
1 Programming Paradigms
- "The notion of programming paradigms is a way to classify
programming languages," – Wikipedia
- This is a wrong view.
- It is a way to classify programming "styles."
- Some PLs have multiple paradigms.
- rosettacode.org Solutions to the same task in different languages.
- rosetta.alhur.es Compare any two PLs solutions
1.1 Procedural Paradigm
- Examples: C/C++, Java, Python, Scala
- AKA Imperative/ Operational Paradigm
- (Almost all) OOP languages belong here.
- Process/Program State is operated on by statements
- Changes made are globally visible.
- RosettaCode.org:: Quick Sort in Java, Scala.
1.2 Functional Programming
- Examples: ML/ OCaml, Haskell, Scala (hybrid)
- No state; functions and expressions have no side-effects
- Obviously, IO and environment changes are needed – handled in
an ad hoc way.
- Functions etc. are "first class" values. (i.e., computable
within the PL)
- Compute a value, and return it as a result.
- RosettaCode.org:: Bubble Sort in Haskell; Quick Sort in Haskell, OCaml
1.3 Logic Programming.
- Examples: Prolog, Datalog
- AKA Declarative Paradigm
- Based on mathematical logic. But, not full scale, but highly
studied subsets in the context of implementations.
- State is a collection of "facts" (axioms + inference rules +
deduced).
- Queries: (Program execution) systematic search in the state
- Queries may have unbound variables. The answer then yields all
possible value that make the query true.
- RosettaCode.org:: Quick Sort in Prolog