[erlang-questions] Erlang and Ada

ok ok@REDACTED
Fri Mar 30 03:44:18 CEST 2007


On 29 Mar 2007, at 10:00 pm, Ramon Diaz-Uriarte wrote:

> I was looking for a comparison of Erlang with Ada and could find very
> little (I searched comp.lang.ada, the erlang list, and lambda the
> ultimate, and did a variety of goodle searches). I understand that the
> two languages have different origins and have been mainly applied in
> different areas (telecom --Erlang-- vs. aviation and military --Ada).
> But it seems both are unique among "major languages" in the support
> they provide for concurrent and distributed programming using message
> passing. Why, then, so few comparisons among the two?

I have copies of the Ada 81, Ada 83, Ada 95, and Ada 2005 standards.
I haven't finished reading the last of these, as I only got it recently.
However, I can certainly assure you that there is nothing in any of the
previous Ada standards concerning distribution.  Ada was designed to be
a clean general-purpose programming language with a special emphasis on
embedded systems, which is one reason why the Ada standards do not  
require
garbage collection.  The SPARK Ada subset, that is, the subset supported
by the SPARK verifier, doesn't even include dynamic allocation, although
that is certainly part of the full language.

Nor does Ada use message passing.  It uses the *rendezvous*, which is
a bit like message passing except that it is synchronous and unbuffered.
If one Ada task wants another task to do something, it has to wait until
the other task is ready to receive the request.  The 'select' statement
of Ada is very similar indeed to Erlang's 'receive', but the one is
unbuffered synchronous and the other buffered asynchronous.

The different backgrounds lead to another important difference.
Erlang is designed for systems where you expect to upgrade the software
while it is running without taking the system down; this is the famous
"hot loading", and amongst other things it presupposes a network over
which the changes can be distributed.  Ada was designed for conventional
applications and for embedded systems, where you are expected to follow
a development process that gets the program "right the first time".   
There
is no notion in the Ada language of any kind of dynamic loading.   
(Which is
not to say that Ada can't use dynamic linking on those operating systems
that have it, only that it's not part of the standard language or  
libraries
in the same way that it's not part of the standard C language or  
libraries.)

Interestingly, both Ada 95 and Erlang/OTP allow a kind of dotted  
module name,
and from my point of view they both got the dotted names inside out,  
but Ada
95 "child packages" really have some point to them.  (For example an Ada
package can have *private* children that other packages cannot see.   
Neither
Java nor Erlang can manage that.  Also, Ada children can be allowed  
to see
inside their parents, which again neither Java nor its slavish  
imitator in
this respect, Erlang, allows.)

Arguably the single most important difference between Ada and Erlang is
that Ada is an imperative language relying on destructive updates to
variables and arrays, while Erlang is mostly functional.  One of the  
things
that makes Ada a nice language for concurrency is that it doesn't SHARE
mutable data between tasks.  The nearest it comes is something called a
'protected record', which is essentially a 'monitor' (or a Java  
object all
of whose methods are synchronised and with no exported fields).   
Nevertheless
it is only really at home on shared *memory* machines.

Ada doesn't have any form of pattern matching other than a 'case'  
statement
which is similar to (but MUCH cleaner and far easier to get right) the
C/C++/Java 'switch' statement.  It _could_ have something fancier;  
Mesa did.





More information about the erlang-questions mailing list