AstonJ

AstonJ

Objects vs Processes

First, listen to Joe Armstrong talk about processes…
(32m14s in)

I suppose when you put it like that - it makes total sense. But the funny thing is when OOP was first explained to me I thought that made perfect sense :043:

Does anyone else feel like they are being torn between universes? :lol: It’s actually a fascinatingly new experience for me!

But back to the topic - do you think in processes?

Most Liked

Korbin73

Korbin73

This might get long-winded… Joe makes some incredibly valid points. Like you, when I first learned OOP, it made perfect sense to me. But does it? If you have a bike object, does it make sense that it has a method called bike.ride() on it? Or does it make more sense that an action is HAPPENENING to it like ride(bike)?

In a hotel reservation system, does it make sense that a customer is being modeled like this: customer.check_in()? Or does it make more sense that something is being done to the customer like check_in(customer)?

I had always struggled with the mental model of having a model with actions on it even though I have been in OOP languages for 16 years. It ALWAYS made more sense that something gets done to a model than a object(model) taking action. At the time I learned OOP I knew it “didn’t feel right” but I continued to model my program in such a way where an object gets “injected” (in a loose way) into another object and the model is actually what “takes an action” instead of an action being done to it because that’s how I learned you are supposed to do it. I believe this is the part that Joe is referring to that “defies the law of physics”. Does it makes sense to inject a car rental object into a reservation object so the customer can reserve a car? Or does it make more sense for the reservation process to send a message to the car rental process to reserve a car? I would even go as far to say that OOP is a failed model. Actually, let me rephrase… OOP without message passing is a failed model.

When I talk to programmers and they say that OOP fits their mental model better than functional programming, the first thing you have to ask yourself is if they are saying that because it’s true? Or are they saying that because the only paradigm they have learned is OOP and it’s all they know? By definition, you have try more than one thing to know if it is a better fit for you :slight_smile:

uranther

uranther

And if you program it in NodeJS, your brain will melt!

:043:

In the PHP/Java world, you most definitely need a getter and setter for (almost) every one of those properties, or you are violating the OOP directive. I think this is what Rich Hickey means when he complains about OOP “ceremony” - it is an utter waste of time. Then you get into object reflection when you need to write tests or deal with a broken/leaky interface, and then it really starts to feel as if you are doing something fundamentally wrong. OOP never really made sense to me, but everyone was doing it, so I had to follow along in my work.

sashaafm

sashaafm

Last Post!

AstonJ

AstonJ

Funnily enough @Exadra37 posted a snippet about processes in our Programming Erlang book club on DT a few days ago which I think is a good way to look at them :smiley:

(The whole thread may be worth a read if you are interested in Erlang, Joe, or the book :003:)

Where Next?

Popular in Discussions Top

ricklove
I was just introduced to Elixir and Phoenix. I was told about the 2 million websocket test that was done 2 years ago. From my research, t...
New
und0ck3d
Hello everyone! A few days ago I’ve created a topic here about how people were creating CMSs with Elixir and Phoenix. I’ve been studying...
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New
lucaong
Hello Elixir and Nerves community, I have been working for a while on an open-source embedded key-value database for Elixir, that I call...
230 14403 124
New
Fl4m3Ph03n1x
Background A few days ago I was listening to The future of Elixir from Elixir Talks, with Dave Thomas (@pragdave ) and Brian Mitchell. I...
New
thojanssens1
It would be nice to be able to define a redirect from one route to another from the router.ex file. E.g.: redirect "/", UserController, ...
New
nunobernardes99
Hi there Elixir friends :vulcan_salute: In a recent task I was on, I needed to check in two dates which of them is the maximum and which...
New

Other popular topics Top

Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 44265 214
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New

We're in Beta

About us Mission Statement