Pistrie
For some reason I started thinking about Alan Kay’s definition of OOP, and I remembered that he emphasized the importance of messaging. Since Elixir has processes which communicate via messages I thought it would be fair to say that Elixir is at least partly comforming to the purest definition of object-oriented design.
Thoughts? Discuss.
Trending in Discussions
As the title says, please share what you’ve been up to with Elixir. Whether that’s been learning it, looking into it, making stuff with i...
New
The obligatory hello world thread!
Who are you and where are you from? :stuck_out_tongue:
New
@chrismccord : I just saw the Extract AGENTS.md from Phoenix.new into phx.new generator commit to the phoenix project.
My initial shotgu...
New
I was working on an Ecto migration and I needed a timestamp. So, for the nth time, I looked up the different data types for timestamps, a...
New
Fly’s CEO posted this recently - Turn And Face The Strange · The Fly Blog
It says that Fly is going all-in on sprites, which is a worry ...
New
We’re evaluating API mocking tools for OpenAPI-based projects and would love to hear what other teams are using.
We’re particularly inte...
New
Is there a word for the ~> symbol used in Version strings?
Do you also just call it a Squiggle Arrow™ ?!
New
Other Trending Topics
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
Chat & Discussions>Discussions
Latest on Elixir Forum
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #blog-post
- #phoenix_html
- #iex
- #graphql
- #ai
- #genstage
- #elixirconf-us
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex










Showing Posts 1 to 10- Show Best Posts
- Show All Posts (oldest first)
- Show All Posts (newest first)
soup
Some rando called “Joe Armstrong” has said the same thing:
Ralph Johnson, Joe Armstrong on the State of OOP - InfoQ ~7m30s
(Elixir was not out at this time.)
D4no0
If we were to put abominations like inheritance aside from classical OOP languages, elixir/erlang abstractions (namely genservers) are not that different from a class in let’s say java. Message passing actually is a solution to a thing that was solved differently by languages like java, concurrency.
All processes(objects) in elixir/erlang are already a concurrent entity, in contrast to an object in java, that is a data structure (state machine). These are 2 different views regard to concurrency, one says that it is better to have small concurrent ready parts and the other one says that we can have chunks of code that we might want later to make concurrent.
It is easy to understand why languages like java were designed this way, for a very long time all the code would run on a single cpu or core and in terms of that, this approach is much more efficient in both short term and long term.
Now I can’t say for sure, however I think erlang never had in mind (at least at the beginning) the concurrency model to be scaled on multiple cores like we use it today, it was designed to have the fault tolerant nature and small concurrent pieces (processes) with their own memory and communication channel was the way to achieve it. Maybe @rvirding can shed some light on their decissions.
jeremyjh
From a performance standpoint, I cringe at the thought of using concurrency to implement abstraction and encapsulation, but it is interesting to see how far you can take this idea. Tony Arcieri (of Celluloid and Revactor fame in Ruby-world) developed a language more than a decade ago called Reia which took this idea to its logical conclusion by implementing something with Rubyish object semantics on top of Erlang by using message passing. I also know that the earliest incarnations of Elixir had more rubyish semantics, don’t know if it was at all similar to this idea; that was before I got involved in 2013.
LostKobrakai
You can still have oop in elixir: GitHub - wojtekmach/oop: OOP in Elixir! · GitHub
D4no0
Could you formulate more on that? because as far as I see, elixir/erlang does seem to be a sane scalable solution in a nowadays world of concurrency.
dmitriid
The question of OOP/not-OOP is somewhat irrelevant without considering the context: concurrent isolated entities communicating with each other.
See “Joe Armstrong & Alan Kay - Joe Armstrong interviews Alan Kay” https://www.youtube.com/watch?v=fhOHn9TClXY
And a slide from there:
dmitriid
Also, I clean forgot that Alan Kay answered this question on Quora:
jeremyjh
When you send a message between processes in Elixir, the data passed as arguments are copied into the heap of the receiving process. When you call a method on a Ruby (or Java, C# apart from unboxed primitive arguments) object, any arguments are passed by a reference, memory is not copied. This makes Erlang more resilient and scalable in the large and avoids complications like concurrent garbage collectors, but in the small there are overheads that do not exist in traditional systems. Also these are not the only overheads; when objects are bound to processes in this way, they can become a bottleneck, and they introduce more complicated failure modes (which Elixir/BEAM is well equipped to manage, but they still exist).
These are some of the reasons why we don’t advise people to use
GenServeras a general abstraction method in Elixir, but to only use it when concurrency is actually one of the problems to be solved, rather than a mechanism for solving unrelated software design problems.LostKobrakai
To be fair, while this is better for performance it’s also one of the things, which causes a lot of grief with OOP. You not only have a lot of stateful stuff, but also seemingly everybody has access to public state all the time.
D4no0
I totally agree with you from the performance standpoint, however I want to introduce another point: software resilience in context of the development. Languages like c#, java, ruby offer those optimizations on behalf of development complexity.
While this is kind of a stupid argument from an engineering point of view, I could argue that nowadays the ability to write resilient software with minimal investments (developers and time) is as important if not more important than performance.