Wednesday 25 August 2010
Saturday 15 November 2008
Erlang User Conference 2008 in Stockholm
I visited this year's Erlang User Conference in Älvsjö, Stockholm, Sweden and was very impressed by the organizers, sponsors, speakers and the nice Swedish people in general.
Session I:
Session II:
Mickaël Rémond wants to give out this year Erlang User of the Year award to Damien Katz of CouchDB, but Damien could not make it to the conference because of spawn(Fun)
Lunch break:
Session III:
Session IV:
Conference end:
The conference finished with an ErlLounge (food, drink & conversation), which was a great event - thanks a lot to the sponsors and organizers!
Session I:
A lot of FUN: Prof. John Hughes uses the computer to come up with algebraic relations for pure functions and to test them
Session II:
Mickaël Rémond wants to give out this year Erlang User of the Year award to Damien Katz of CouchDB, but Damien could not make it to the conference because of spawn(Fun)
Lunch break:
Session III:
Dr. Kostis Sagonas starts warming up, later he was challenging the crowd to be as nitpicking as the dialyzer tool
Session IV:
Conference end:
The conference finished with an ErlLounge (food, drink & conversation), which was a great event - thanks a lot to the sponsors and organizers!
Wednesday 4 June 2008
The tattered history of OOP
Over at ZDNet, there is an article titled "The tattered history of OOP", which seems to say that Smalltalk's creator Alan Kay was originally after scalable systems and wanted something which reminds surprisingly of Erlang:
Object primitives were used to parse messages sent to objects, and then the messages were matched with methods via. pattern matching. This happened at run time using late binding.And I thought it was just about doing nice GUIs.
[..]
Kay saw objects as “virtual computers”, and made an analogy between objects and Unix processes [..].
[..]
In Kay’s scheme of things classes and methods could be updated at any time, even while the corresponding objects were doing something.
[..]
What Kay considered most important about OOP was not the objects, but the message passing that goes on between them. “The abstraction is in the messages, not the objects.” He’s apologized for years for coming up with the term “object-oriented programming”, because it got everyone focused on the objects, not the messages.
Thursday 1 May 2008
OOP and COP
Today I read the article Erlang for the OO-minded on the MUE - Embrace Change blog. Its author sees Erlang processes as kind of objects and writes about similarities.
To me OOP is a nice way of organizing programs. An object of OOP basically is a compound of data and code components (functions / methods). Plus we got
Before this, people came up with other organization schemes, among them ideas like
IMHO OOP benefited from the fact that an OOP object has similarities to physical objects:
Software patterns are another organizational effort comparable to the invention of data structures for data and algorithms for code. People recognized useful arrangements and usage schemes of objects.
Now lets go to Erlang. The most prominent entities of Erlang are processes. They model tiny units of execution. Each process can be seen as a virtual CPU. The communication between those processes is done by message passing, either asynchronous (don't wait for an answer) or synchronous (wait for an answer).
Processes allow us to split the large execution power of one or several real CPUs into many virtual threads of execution. As an additional treat we get distribution, the ability to do this over several, separated multi CPU machines, connected by a network.
Execution / concurrency is something which is not covered in a nice way by OOP alone. Thus in OOP programming languages it usually shows up somewhere else, like as ugly support for threads or complicated synchronization mechanisms.
It is true what Joe Armstrong wrote in Concurrency Oriented Programming in Erlang:
Thus COP is another way to organize programs, or rather programmed systems, viewed with concurrency in mind. At least Erlang has some more organization in that direction, its OTP libraries and tools, with their patterns and frameworks for concurrency.
Now back to the point of the original MUE article - is an Erlang process related to an OOP object?
My answer is mostly no.
Both are basic building blocks, with boundaries that provide encapsulation, but there it ends. Erlang processes don't carry data themselves and consist of a single method not many.
The strongest argument against is probably a look at the Scala language, which features actors. Here is code from Scala Actors - A Short Tutorial:
Thus the missing bit what the MUE author was really looking for was the actors model. If you can have that in a functional language like Erlang and an OOP language like Scala, it must be something orthogonal.
Actors seem to be an interesting concept. I have only seen the Actor Model and Actor model and process calculi articles on Wikipedia, plus the interesting Why has the actor model not succeeded? article. It is attributed to a paper from 1973, thus 35 years old.
Erlang is from 1985 thus 23 years old. So far I can't remember any reference by Joe Armstrong of the actor model. I somewhat doubt that the Erlang creators studied the mathematical actor papers while conceiving Erlang and then never giving it credit, so it might be some parallel development.
With Erlang and possibly Scala concurrent programming got a bit more mainstream, I also hope for a broader understanding of the theoretical foundations, to allow better use of those tools. Right now that kind of knowledge is limited to a few specialists.
Encapsulation is a good thing.
To me OOP is a nice way of organizing programs. An object of OOP basically is a compound of data and code components (functions / methods). Plus we got
- encapsulation (making parts of the objects more local by restricting access),
- inheritance (a way to organize similar objects) and
- polymorphism (a way to organize the method calls among similar objects).
Before this, people came up with other organization schemes, among them ideas like
- using symbols (use explaining names for code and data entities),
- macros (aggregate several instructions into one larger),
- modules (cut the large code files into smaller ones, make the interfaces explicit),
- algorithms (useful problem solving strategies),
- data structures (useful organization schemes for data).
IMHO OOP benefited from the fact that an OOP object has similarities to physical objects:
- The data components of an object are similar to the states of a physical object.
- The code components of an object are similar to certain actions / transformations / processes which apply to physical objects.
Software patterns are another organizational effort comparable to the invention of data structures for data and algorithms for code. People recognized useful arrangements and usage schemes of objects.
Now lets go to Erlang. The most prominent entities of Erlang are processes. They model tiny units of execution. Each process can be seen as a virtual CPU. The communication between those processes is done by message passing, either asynchronous (don't wait for an answer) or synchronous (wait for an answer).
Processes allow us to split the large execution power of one or several real CPUs into many virtual threads of execution. As an additional treat we get distribution, the ability to do this over several, separated multi CPU machines, connected by a network.
Execution / concurrency is something which is not covered in a nice way by OOP alone. Thus in OOP programming languages it usually shows up somewhere else, like as ugly support for threads or complicated synchronization mechanisms.
It is true what Joe Armstrong wrote in Concurrency Oriented Programming in Erlang:
In languages like (noname) they forgot aboutJoe likes to call the paradigm behind Erlang Concurrency Oriented Programming (COP):
concurrency. It either wasn’t designed in from
the beginning or else it was added on as an
afterthought.
This doesn’t matter for sequential programs.
If your problem is essentially concurrent then this
is a fatal mistake.
A language is a COPL if:He describes the benefits as:
- Processes are truly independent
- No penalty for massive parallelism
- No unavoidable penalty for distribution
- Concurrent behavior of program same on all OSs
- Can deal with failure
Why is COP Nice?Note that Joe mentions the physical world a few times too.
- The world is parallel
- The world is distributed
- Things fail
- Our brains intuitively understand parallelism (think driving a car)
- To program a real-world application we observe the concurrency patterns = no guesswork (only observation, and getting the granularity right)
- Our programs are automatically scalable, have automatic fault tolerance (if the program works at all on a uni-processor it will work in a distributed network)
- Make more powerful by adding more processors
Thus COP is another way to organize programs, or rather programmed systems, viewed with concurrency in mind. At least Erlang has some more organization in that direction, its OTP libraries and tools, with their patterns and frameworks for concurrency.
Now back to the point of the original MUE article - is an Erlang process related to an OOP object?
My answer is mostly no.
Both are basic building blocks, with boundaries that provide encapsulation, but there it ends. Erlang processes don't carry data themselves and consist of a single method not many.
Actress.
The strongest argument against is probably a look at the Scala language, which features actors. Here is code from Scala Actors - A Short Tutorial:
This looks somewhat like Erlang code. We recognize the bang (!) operator to send messages and the receive statement. But no tail recursion and pattern matching.class Ping(count: int, pong: Actor) extends Actor {
def act() {
var pingsLeft = count - 1
pong ! Ping
while (true) {
receive {
case Pong =>
if (pingsLeft % 1000 == 0)
Console.println("Ping: pong")
if (pingsLeft > 0) {
pong ! Ping
pingsLeft -= 1
} else {
Console.println("Ping: stop")
pong ! Stop
exit()
}
}
}
}
}
Thus the missing bit what the MUE author was really looking for was the actors model. If you can have that in a functional language like Erlang and an OOP language like Scala, it must be something orthogonal.
Actors seem to be an interesting concept. I have only seen the Actor Model and Actor model and process calculi articles on Wikipedia, plus the interesting Why has the actor model not succeeded? article. It is attributed to a paper from 1973, thus 35 years old.
Erlang is from 1985 thus 23 years old. So far I can't remember any reference by Joe Armstrong of the actor model. I somewhat doubt that the Erlang creators studied the mathematical actor papers while conceiving Erlang and then never giving it credit, so it might be some parallel development.
With Erlang and possibly Scala concurrent programming got a bit more mainstream, I also hope for a broader understanding of the theoretical foundations, to allow better use of those tools. Right now that kind of knowledge is limited to a few specialists.
Wednesday 30 April 2008
Subscribe to:
Posts (Atom)