Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The whole thing still runs in and has to interact with the real world where everything is governed by time and state. You can't avoid having the impedance mismatch somewhere in your stack.


The inability to deal with time and state is not fundamental to functional PLs (though possibly a difficulty for pure FPs). Erlang handles time, state, AND space (though isn't that just time?) fantastically. Perhaps unsurprisingly, the lead creator was a Physics PhD (candidate dropout? I don't remember). Concepts of giving up on absolute synchronicity, for example, reliability of transmissions across unreliable channels, permeate the feel of the (functional) system. It is decidedly not pure functional programming though, as the choice of a functional system was made more of a pragmatic / developer ergonomic choice than a theoretical one.


Yes it is, and Erlang isn't a counterexample. As you noted, it's not a "pure" FP, and it is exactly the messaging elements that let it handle these things.

Q: Erlang "object-oriented" after all?

A: Yes.

http://erlang.org/pipermail/erlang-questions/2009-November/0...


In a talk he admitted that Erlang is the unification of OO and FP, although he didn’t realize it when he created the language.

He also mentioned Hoare‘s CSP as an inspiration with the caveat that he didn’t agree with the lock-step synchronization as messages should be async. Makes sense from a physicist‘s perspective.


I'm sorry, I have a lot of respect for Joe Armstrong but this is simply something he got wrong, probably because he didn't fully understand smalltalk objects. Before he 'admitted' as such, he understandably thought OO was stroustrop style OO. Then someone pointed out to him that originally OO was smalltalk OO, which admittedly looks vaguely like erlang message passing. But there are critical differences.


something can be both object-oriented and functional. they're not exclusive.

However, although erlang's process model superficially looks like smalltalk objects, if you design your erlang program like a smalltalk program, your performance will suffer and you will be in a world of hurt when stuff breaks. The point of message passing concurrency in erlang is to create failure domains, not to organize your code.

In short, please do not structure your erlang program like smalltalk OO, and it is definitely not what a contemporary programmer would call OO.


> something can be both object-oriented and functional. they're not exclusive

Indeed: not a "pure" FP, and it is exactly the messaging elements that let it handle these things

> However, although erlang's process model superficially looks like smalltalk objects

Did anybody claim Erlang objects were like Smalltalk objects?


When anyone claims erlang processes are like objects they are referring to the message passing nature of the processes, which is directly analogous to smalltalk objects. There is no other reasonable way to call erlang object oriented. I am aware that Joe Armstrong got swept up in this analogy. My point is following this superficial similarly to it's logical conclusion will result in shit code, so you really shouldn't make that analogy.

It's so bad there is an explicit admonition against doing it in the elixir std lib docs.


> the message passing nature of the processes

Yes.

> which is directly analogous to smalltalk objects.

No. Definitely not "directly", because Smalltalk messages are synchronous, whereas Erlang messages are asynchronous.

Both are special cases of the general concept of "messaging", and arguably the Erlang instance more closely matches what Alan Kay had in mind. (See his description of objects and messages as lots of little autonomous computers exchanging messages).

> I am aware that Joe Armstrong got swept up in this analogy.

Not sure what you mean with "swept up". He realised it is obviously true. Considering he created the language, he might have had an idea of what he was talking about.

> so you really shouldn't make that analogy.

You shouldn't naively equate Erlang messaging with Smalltalk messaging, but the only who has done this here is you.

¯\_(ツ)_/¯


> Definitely not "directly", because Smalltalk messages are synchronous, whereas Erlang messages are asynchronous.

I think you have a problem comprehending English. Directly does not mean exactly. Most of the rest of what you wrote is basically rehashing what I am claiming.

> Considering he created the language, he might have had an idea of what he was talking about.

No shit. However, he did not know as much about OO, or the history of OO, because he was at the time it was picking up steam very much busy building erlang. 2009 is around the time of the turning point in Joe's understanding of OO:

http://erlang.org/pipermail/erlang-questions/2009-November/0...

> "swept up"

Someone pointed out the full history of OO to him, he realized that his naive understanding of OO (Basically, C++ objects) was not complete, and he quickly grabbed on to his new understanding. Ok great. It also sounds diplomatic, and also now everyone who complained that his language was not OO and therefore bad can be shut up. What would you do?

> but the only who has done this here is you

Nope, so is Joe Armstrong.


Of course, but in the end everything is an abstraction. You can use functional reactive programming to expose a stateful API, for example; there’s nothing wrong with that.

And on the other end of the spectrum, if you go low level enough you realize that everything is stateful in the machine, so you will need to build (or already have) functional abstractions on top of that.

Bottom line, it’s almost impossible to have a single paradigm on all levels of your stack.


Monadic IO, Uniqueness types (as in: Clean), voluntarily working in a pure subset until the End of the World (Scala), effect-first languages, etc. We can impose actual semantics upon an ultimately imperative computer. Is it restrictive? Yeah, but that's, like the point, man. Restricting what can happen allows us to reason about what might happen given a piece of 'random' code. In an imperative-only world, Capabilities serve a similar function.

The fact that the world is made up of elementary particles subject to the 'laws' of thermodynamics has very little impact on the semantics we choose for our programming languages. (If you want to take your appeal to 'nature' that far.)


I was replying to a comment that specifically bemoaned that the low level hardware is not functional.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: