FUNCTIONAL AND OBJECT-ORIENTED PROGRAMMING: KEY FEATURES AND DIFFERENCES

Pros and cons of Functional Programming vs Object-Oriented Programming

Inventing something new in the programming world, as elsewhere, is achieved through multiple attempts and manipulations. Sometimes decades go by before these ideas become mainstream and spread across the industry. One of the outstanding examples is Java, one of the leading programming languages today. Before becoming one, it was heavily criticized for being slow and consuming a large amount of memory. The revolution in the machinery, however, changed that situation. As we see, some technological advancements may just be ahead of their time.

Functional programming vs object-oriented programming

Pillars of Object-Oriented Programming

OOP utilizes methods and objects programmed for describing real things. Objects represented by the object-oriented languages can be reusable owing to mutable data features, hence, many things can be created with just a few processes.

  • Abstraction (hiding irrelevant information and keeping the core one)
  • Inheritance (the process of one class or object retaining the attributes of another class)
  • Encapsulation (prevention of unauthorized access to the unrelated data by hiding them)
  • Polymorphism (creation of a new entity by combining several elements)

Fundamentals of Functional Programming

Among the key elements of the FP it is worth singling out the following:

  • First-class function (a function can be built in the runtime, passed as a parameter, returned, and even get assigned some value)
  • Higher-order function (can take functions as arguments and return the functions as values)
  • Pure function (take and return the same value as an input value without any modifications to the data)
  • An anonymous function (a function without a name usually utilized within a short period)
  • Recursion (allows writing concise algorithms based on the input data to the functions)
  • Persistent data structure (a data structure that keeps their previous version when undergoing modifications)
  • Non-strict (lazy) evaluation (an evaluation of a function is performed only when this function is called)

Summary

When it comes to comparing Functional and Object-oriented programming, it is always important to bear in mind the purpose of each of them. Both approaches are targeting functionality, simple comprehension, and swift development. At the same time, they use different storage methods as well as ways to manipulate the data.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Agiliway

Agiliway

Custom software development company offering a wide range of IT Consulting, Web and Mobile development, Quality Management, BI and BigData services.