# Thought: Relation between different programming paradigms

**URL:** <https://forum.elixirforum.com/t/thought-relation-between-different-programming-paradigms/2114>\
**Category:** General Prog (Archived)\
**Tags:** functional-programming, oop, philosophy, programming-paradigm, actor-model\
**Created:** [October 25, 2016, 3:53pm UTC](https://forum.elixirforum.com/t/thought-relation-between-different-programming-paradigms/2114 "2016-10-25T15:53:13Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Qqwy](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/qqwy/32/1349_2.png) [@Qqwy](https://forum.elixirforum.com/u/Qqwy)\
**Post date:** [October 25, 2016, 3:53pm UTC](https://forum.elixirforum.com/t/thought-relation-between-different-programming-paradigms/2114/1 "2016-10-25T15:53:13Z")

</div>

Today we had a guest lecture at the university for the course Information Security, that was given by a philosopher. It was very interesting, talking about the influence of technology on our lives and the implications that would have. But that’s for another topic.

One of the things it touched upon, was that humans are the creatures that are able to separate their consciousness from their body. (There might be other animals that can do this, but we don’t know) This, the ability to consider things from different viewpoints, has allowed us to plan ahead, overcome many difficult situations, and solve problems in _a more general_ way than possible when not considering multiple perspectives.

I then realized: Maybe the different programming paradigms can be subjected to the same kind of reasoning:

 ![](https://forum.elixirforum.com/uploads/default/original/2X/8/8ce7c9084cbb7f79c0dbf6f60d305da4e3b64d39.png)

Looking at it from this angle/with this analogy, it seems to me that the Actor-Model is the paradigm that allows us to solve problems in the most generic, adaptable way; i.e. solve the most problems.

What do you think?

---

<div class="post-metadata">

**Author:** ![AstonJ](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/astonj/32/15_2.png) [@AstonJ](https://forum.elixirforum.com/u/AstonJ)\
**Post date:** [October 25, 2016, 5:08pm UTC](https://forum.elixirforum.com/t/thought-relation-between-different-programming-paradigms/2114/2 "2016-10-25T17:08:21Z")

</div>

In case @jaysoifer forgets to comment about it here 😃

[https://twitter.com/jaysoifer/status/790958305669738496](https://twitter.com/jaysoifer/status/790958305669738496)

---

<div class="post-metadata">

**Author:** ![DianaOlympos](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/dianaolympos/32/4353_2.png) [@DianaOlympos](https://forum.elixirforum.com/u/DianaOlympos)\
**Post date:** [October 25, 2016, 9:17pm UTC](https://forum.elixirforum.com/t/thought-relation-between-different-programming-paradigms/2114/3 "2016-10-25T21:17:37Z")

</div>

I have other way to see it, but it would be hard to answer here.

I don’t know if you follow the Morning Paper by Adrian Colyer (do it, it is not hard to google) but he recently talked about the Liskov paper on ADT. There is one important thing here, it is that ADT are about the _operations_ done on the data.

Basically, OOP come from Simula. Nothing else. Now OOP is mainly applying a hierarchical classification on tops of programs. It is about separating programs _while staying in the same context_. By definition, OOP is a 19th century taxonomy applied to programming.

FP… is not really that well defined anyway. Mainly because OOP should have never been separated from imperative anyway. And because it mix two differentway to look at code (dynamic homoiconic LISP like vs ADT Lazy point free pure Haskell/ML like).

Actor fit more in the SmallTalk/Lisp side because it is basically Closure running in isolation with an additional mailbox.

---

<div class="post-metadata">

**Author:** ![gregvaughn](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/gregvaughn/32/954_2.png) [@gregvaughn](https://forum.elixirforum.com/u/gregvaughn)\
**Post date:** [October 25, 2016, 10:49pm UTC](https://forum.elixirforum.com/t/thought-relation-between-different-programming-paradigms/2114/4 "2016-10-25T22:49:18Z")

</div>

I hate to be contrary, but the very phrase “object oriented” was first said by Alan Kay, who designed the Smalltalk language (with much Simula influence, certainly). So I don’t think it’s fair to consider _only_ the Simula heritage to define “OOP”. It’s not a common terminology, but I refer to the taxonomical approach as Class Oriented. Moving on …

How does your definition (or Adrian Colyer’s) of OOP mix both homoiconic LISP with lazy point free Haskell? Homoiconic and lazy and point-free are three things I never see in “OOP” (or class oriented) programs.

---

<div class="post-metadata">

**Author:** ![DianaOlympos](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/dianaolympos/32/4353_2.png) [@DianaOlympos](https://forum.elixirforum.com/u/DianaOlympos)\
**Post date:** [October 26, 2016, 12:28pm UTC](https://forum.elixirforum.com/t/thought-relation-between-different-programming-paradigms/2114/5 "2016-10-26T12:28:26Z")

</div>

so let’s look at it.

1. I know totally the history of the _word_ OOP. And what i mean here is that the part of Smalltalk that made it mainstream are the one coming from Simula. Should we name the Actor model OOP because Hewitt got the idea from Smalltalk too ? And let not talk about how Alan Key himself keep yelling that what we got is not what he meant… I still use OOP as it means nowadays, but if we want to go in philosophy 😛

2. My definition does not mix with OOP. There i point to FP as a whole. And i point out that the whole idea of putting together homoiconic and lazy have some ground but should not be pushed too hard either. They have fundamental different ways to answer some things.

3. In the end, i was mainly pointing that the links made between actor, OOP and FP on top were really limiting. I advise to listen to Liskov talk at the Heidelberg forum this year. While i don’t agree with everything, she point an important thing : in her ways to look at ADT, subclasses and a hierarchy of subclasses are useless and even probably overly complex.

4. Because ADT can work in any of these paradigm. ADT work well being in LISP late binding via ad hoc polymorphism or via typeclasses. They are, in a lot of way, orthogonal to the interpretor paradigms but more linked to the linker paradigm and the interface we define between our things. In OOP you put the operation into the object in itself while in FP it is the functions that got the definition of what they accept and their own different implementation. But for the interpreter, once it is linked, there is no difference.

---

<div class="post-metadata">

**Author:** ![Qqwy](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/qqwy/32/1349_2.png) [@Qqwy](https://forum.elixirforum.com/u/Qqwy)\
**Post date:** [October 26, 2016, 5:58pm UTC](https://forum.elixirforum.com/t/thought-relation-between-different-programming-paradigms/2114/6 "2016-10-26T17:58:30Z")

</div>

@DianaOlympos.

Homoiconicity, Lazyness, Pattern Matching and Partial function application are all features that occur frequently in Functional Programming languages, but I believe most (all?) of them can be introduced in imperative or (Adrian Colyer’s) OOP-style languages (which are usually very imperative as well), although it might be hard. (So I diagree with you on this, @gregvaughn; while it might have less benefits to port these functionalities to non-FP languages, I believe it to be possible.)

I think these features distract from the -in my opinion- core concept of Functional Programming: **Immutability**.

Or, in other words, the way that identity/state (what I clumsily called consciousness/data in my graph) is treated in FP. [There is a great article on the rationale behind Clojure that goes into more detail about this](http://clojure.org/about/state).

Abbreviated: In Imperative languages (and most (Colyer-style) OOP languages), executions happens by _mutating_ the state of the things you have. A variable is a ‘box’ that you put something in, which is then changed at a later time. This means that you can never be sure what a variable actually contains. In these languages, Identity ≡ State.

In FP, variables are just ‘names’ we give to a data structure, and then it will never change. A new state is the result of a function called on the old state. This means that Identity ≠ State; instead, an Identity _has_ a state. This means that you do not have to be afraid of the floor changing under your feet, as in the current scope (regardless of what is going on concurrently), the value that a variable refers to will never change.

* * *

I think that immutability is the important aspect that FP has, which allows you to easily build predictable(and therefore maintainable, concurrent, etc.) applications.

---

<div class="post-metadata">

**Author:** ![mkunikow](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/mkunikow/32/235_2.png) [@mkunikow](https://forum.elixirforum.com/u/mkunikow)\
**Post date:** [October 26, 2016, 9:20pm UTC](https://forum.elixirforum.com/t/thought-relation-between-different-programming-paradigms/2114/7 "2016-10-26T21:20:40Z")

</div>

For me Actor-Model is type of Concurrency Mode from book [Seven Concurrency Models in Seven Weeks](https://pragprog.com/book/pb7con/seven-concurrency-models-in-seven-weeks). You can use Actor-Model using OO language as Functioanl langauge.

---

<div class="post-metadata">

**Author:** ![Qqwy](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/qqwy/32/1349_2.png) [@Qqwy](https://forum.elixirforum.com/u/Qqwy)\
**Post date:** [October 27, 2016, 6:32pm UTC](https://forum.elixirforum.com/t/thought-relation-between-different-programming-paradigms/2114/8 "2016-10-27T18:32:03Z")

</div>

@mkunikow yes, you are totally right. I had’t considered languages like e. g. Pony, which attempt to combine OOP and the Actorr-Model.

I am very interested to hear about the other ways of doing concurrency. Besides the Actor-Model I knoe of State-Transactional Memory (keep a log of read/writes, when a conflict happens, revert and reread) and plain ol’ Mutex-land with all headaches that come with it. What are the other three?

---

<div class="post-metadata">

**Author:** ![DianaOlympos](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/dianaolympos/32/4353_2.png) [@DianaOlympos](https://forum.elixirforum.com/u/DianaOlympos)\
**Post date:** [October 27, 2016, 8:25pm UTC](https://forum.elixirforum.com/t/thought-relation-between-different-programming-paradigms/2114/9 "2016-10-27T20:25:21Z")

</div>

Well the thing is, if you remember [“Why FP Matters?” by John Hughes](https://www.cs.kent.ac.uk/people/staff/dat/miranda/whyfp90.pdf), the answer of the “special” thing of FP is higher kind functions.

And no, you can’t import that into OOP easily, because if you can do that, why even have object, if your functions can be independant ? You reach the good old problem that Java is dealing with these days (and Go too) with primitives and object reacting differently.

You can totally do an imperative language with immutable data. It is doable. In a lot of way, that is what things like Rust allow you to do 😛 … OK Rust is stealing a lot from FP. In a lot of way, ZFS in itself is doing that with CoW, or Postgres with their CoW too.

The thing i was pointing with Colyer is more that he mix polymorphism with objects 🙂

The important thing is the glue that functional give us. Now in Elixir/erlang, functional was chosen mainly because it was more _declarative_ and because the only way to do proper message passing is through copying. So immutable data make sense. The higher kind of functions were essential to produce actors, because they are just a closure spawned independently.

But there is no currying nor lazy evaluation because Erlang was _not meant_ to be a functional language. It just happened to be the way to implement the “share nothing, message passing” way.

---

<div class="post-metadata">

**Author:** ![mkunikow](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/mkunikow/32/235_2.png) [@mkunikow](https://forum.elixirforum.com/u/mkunikow)\
**Post date:** [October 28, 2016, 7:50pm UTC](https://forum.elixirforum.com/t/thought-relation-between-different-programming-paradigms/2114/10 "2016-10-28T19:50:04Z")

</div>

I don’t know all concurrency models 🙂  
These are interesting:

###[Functional reactive programming (FRP)](https://en.wikipedia.org/wiki/Functional_reactive_programming)

like [http://reactivex.io/](http://reactivex.io/).  
[The introduction to Reactive Programming you’ve been missing](https://gist.github.com/staltz/868e7e9bc2a7b8c1f754)

### [Communicating sequential processes (CSP)](https://en.wikipedia.org/wiki/Communicating_sequential_processes)

This one is used in:

- Clojure (core async) [Clojure core.async Channels](http://clojure.com/blog/2013/06/28/clojure-core-async-channels.html)
- GO ([Go channels](https://gobyexample.com/channels) )

###Articles

Sorry but code is in Scala 🙂  
[Which shoe fits you? Comparing Akka Streams, Actors, and Plain Futures](https://tech.zalando.com/blog/comparing-akka-streams-actors-and-plain-futures/)

[Modern concurrency: Erlang, Scala, Go, Clojure](http://kachayev.github.io/talks/kharkivpy%230/)
