Monday, January 29, 2018

Object-oriented programming or Functional Programming?

Recently, I have been introduced to Scala and that got me thinking about the difference between functional programming and object-oriented programming. After trying few programs in Scala as well as in Java and after reading many articles on this, I personally like functional programming now. For me, computer science and the programming world is like a mathematical world. It’s all Math! After all it’s basically all ones and zeroes! But it depends on what you try to achieve with the program too. If you know the problem statement and have a theoretical solution for it in terms of mathematical equations and stuff, along with the required data, then go for functional programming. Its direct implementation of math. Simple and short. But if you need the heuristics of a problem and need a user-friendly program without involving much complex functions and methods, go for OO. I kind of wonder why OO is still more popular than FP. OO is more user friendly, people understand objects easily compared to functions. 
The good news is that Scala is both OO and FP and that’s the strength of Scala, so it is easier to understand than the other hard-core FP languages like Lisp, Haskell, etc. Scala is inter-operable too  with Java (and of course inhabits the same JVM). On the other hand, Java8 has become more like functional programming language too. So the answer really depends on how you plan to approach your problem statement and what you are comfortable with the most. Anyways, I am enjoying both! Maybe in few years, it can be a different approach that would be more interesting to me. 

No comments:

Post a Comment

The Birth of Bitcoin Cash

Firstly, I would like to shed some light on the Blockchain technology. Blockchain is a transparent peer to peer network that allows us to ...