Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Actor model vs object oriented model

I searched in the web for a long time and couldn't find the concrete disadvantages of object oriented model which are overcome in Actor model. Please help me with some pointers and explanations on it.

Thanks in advance.

like image 508
Suga Raj Avatar asked Dec 19 '16 04:12

Suga Raj


People also ask

What are actors in Object Oriented Programming?

An actor is someone or something outside the system that interacts with the system. A use-case is a sequence of actions a system performs that yields an observable result of value to a particular actor.

What is object oriented programming model?

Object-oriented programming (OOP) is a computer programming model that organizes software design around data, or objects, rather than functions and logic. An object can be defined as a data field that has unique attributes and behavior.

What is actor based simulation?

An Actor Based Simulation Driven Digital Twin For Analyzing Complex Business Systems. Abstract: Modern enterprises aim to achieve their business goals while operating in a competitive and dynamic environment. This requires that these enterprises need be efficient, adaptive and amenable for continuous transformation.


2 Answers

The term Object Oriented Programming originally came from Alan Kay and Smalltalk. It emphasized messaging passing as its primary feature. This is what OOP originally meant.

Once C++ and Java came along the term object oriented programming took on a slightly different meaning. It morphed to what some people call "class-oriented programming".

The Actor model re-emphasizes the originally OOP concept of message passing being the core fundamental.

Actor model pros:

  • Works better in a distributed system
  • Simpler to understand architecturally in many cases
  • Models real world phenomena / complex systems with multiple "actors"
  • Largely compatible with functional programming styles (see Smalltalk)

Actor model cons:

  • Harder to reason about an algorithm because it doesn't exist in just one place. It's gets split across different actors / files and you have to chase it down and follow code.
  • Similarly, multiple algorithms can be mixed among multiple actors. So you might go to a file and read an Actor's code to follow the algorithm but get confused because other algorithms are also mixed into the same Actor.
  • Traditional semaphore–style locking not possible. Must use STM–style which can be more complicated.
  • Harder to get "return values". The Actor model is "fire and forget". You have to figure out how to get "return values" back to the original requester. This adds lots of overhead because now you have to set up a way to receive it and pass the context (uniqueId / taskId) through the entire system. You also need to manage the state to hold that information around until the "response" comes back. Without the actor model they would just be local variables in a block scope.
like image 108
Brennan Cheung Avatar answered Nov 06 '22 16:11

Brennan Cheung


Disadvantages of OO model:

  1. Traditional OOP languages weren’t designed with concurrency. It was very easy to introduce race conditions since it was using a shared state.
  2. The programmers had to identify and fix all possible problem areas by using locking mechanisms.
  3. Locking is easy to implement for simple programs. But as the programs got complex, the implementation of locking has also become complex.

Actor model overcomes the problem by using share nothing model so that concurrency is not affected and locking mechanism is not needed.

like image 21
Suga Raj Avatar answered Nov 06 '22 17:11

Suga Raj