Skip to content

Instantly share code, notes, and snippets.

@co89757
Last active August 29, 2015 14:05
Show Gist options
  • Save co89757/a370aaf6cbd0dd1296c7 to your computer and use it in GitHub Desktop.
Save co89757/a370aaf6cbd0dd1296c7 to your computer and use it in GitHub Desktop.
COMP404 COMM.01 Draft

Comparative study of programming paradigms

Overview

Procedural programming is the most primitive programming paradigm. It treats compuation as a set of sequential steps. It packages a set of repeatable steps in functions that takes input arguments. The most popular language for procedural programming is C. It iterative and sequential and has little overhead therefore high execution speed and small size. It is often used to optimize the performance of a certain portion of code. But it doesn't scale well with large systems and becomes hard to maintain as the software grows.

Object-oriented programming (OOP) stands for a programming paradigm that are marked by 'objects' that encapsulate data fields and behaviors ('methods'). It also imposes access control on class members to keep users from tampering with internals of a class. Hence it has better safety and decomposition.OOP works by interaction between objects. It also enables inheritance and polymorphism. Inheritance means that a class can derive from a superclass , thus inheriting all the data and methods from its parent class. This feature helps code reuse. A derived class can also modify/override some methods of parent class to achieve polymorphism, that is, different behaviors in response to common method calls. Most languages, like C++, handles overriding based on the run-time class of the object. It is suitable for large software system and has the benefit of better maintainability. It also has weaknesses. Mainly, it requires careful planning and design. It also takes more size than procedural programming because of the overhead of classes and objects. Consequently, it also runs slower than procedural.

Functional programming is a more recent trend. Its most salient hallmark is its treatment of computation as evaluation of expressions. There is no statement, only expressions. Computation is viewed as data flows rather than control flows as in imperative programming. Functional programming draws on the idea of pure functions, i.e. functions that always returns the same output with the same input. It thus has no side-effects and doesn't involve mutable data and state. It treats functions as first-class citizens, which means functions can be passed around as arguments and return values just like other data types. The absence of side effects, i.e. its 'purity' also helps testing and debugging. It is particularly good for parallel computing and multithreading since there is no data dependency between two pure expressions. One of its drawbacks is less efficiency as their data structures are not as straightforward to computer hardware and compilers must make significantly more effort. Its applications is also a bit limited to mathematical abstractions. It also doesn't scale well in larger SW systems.

Declarative programming is marked by asking 'What' to do rather than 'How' to do things, such as SQL. It is good for problems with clear definition and logic. It hides the implementation details of actions; so it is difficult for programmers to understand the actual operations under the hood. ###References

Object Oriented Programming: Disadvantages of OOP

WikiPedia of OOP

Advantages and Disadvantages of Object-Oriented Programming (OOP)

FP wikiPedia page

Declarative WikiPage

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment