Category Archives: Functional programming

The difference between OO programming and Functional programming

I had this explained to me in the pub last night… I hope through all the beer I got it right!!

With Object Orientated programming you have objects and to do anything you must ask each object to change itself. So for example if you have a stock and you the value has changed you need to send a message to the object asking it to change its value. Objects cannot receive multiple messages at the same time so a process called “locking” is required to lock all but one of the messages and queue them up so that they can be dealt with one at a time.

With Functional programming the value in question (you don’t have objects) doesn’t change but instead you get new values every time something new happens. (Confused yet – I know I am!) But it does make sense if you take a simple sum: 1 + 2 is 3 right? 3 is a new value. You didn’t ask the “object known as 1” to change it’s meaning to become the same of the value of 3 right? So with Functional programming multiple requests can be dealt with very quickly because each one doesn’t require a fundamental change of the original object’s value.

Clear?

So what? You’re a recruiter.

I know, and I know this is probably so simple that its all wrong but it makes me happy feeling that I understand a tiny bit more about what Java actually is.