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 Responses

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

Where Next?

Popular in Discussions Top

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
fireproofsocks
This is more of a general question, but I’m wondering how other people in the community think about the pattern matching in function sign...
New
AstonJ
Are there any Elixir or Erlang libraries that help with this? I’ve been thinking how streaming services like twitch have exploded recentl...
New
AstonJ
I’ve just started the Phoenix part of the utterly brilliant online course by @pragdave. On generating the Phoenix app he uses the --no-ec...
New
CharlesO
Erlang :list.nth simple, but 1 - based nth(1, [H|_]) -> H; nth(N, [_|T]) when N > 1 -> nth(N - 1, T). Elixir Enum.at … coo...
New
fireproofsocks
I’ve been working on an Elixir project that has required a lot of scripting. I usually reach for Elixir because I like it more (and in th...
New
jsonify
So, is Heroku the only free option for hosting Phoenix/Elixir at this point? I’m not ready to commit to paying monthly and was wondering ...
New
chulkilee
Here are the list of HTTP client libraries/wrappers, and some thoughts on HTTP client in general. I’d like to hear from others how they w...
New
AstonJ
If so I (and hopefully others!) might have some tips for you :slight_smile: But first, please say which area you’re finding most challen...
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

Other popular topics Top

malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
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

We're in Beta

About us Mission Statement