Conceptual integrity in Erlang

Fred Brooks said that conceptual integrity was paramount in system design. Niklaus Wirth said that if we add things to a language we should throw away other things.

Here is a proposal for a few small additons to Erlang.

If we accept these proposals - we can throw away a lot of things and make Erlang even more powerful.

The basic ideas

Bang Bang

Bang bang is a new operator.

A !! B

Is syntactic sugar for: sysd:rpc(A, B) - which is "more or less" a remote proceedure call.

The A in A !! B is a Pid, a process name, or a list of Pids and process names.

[A, B, C] !! X

returns [V1, V2, V3] where V1 = A !! X, V2 = B !! X and V3 = C !! X, all computed in parallel.

Files and Bang Bang

Recall that we said earlier that everything is a process, and that all processes have names.

Files are processes.

If F is a file, then F !! read reads the file.

The following code fragment read and file and copies it to a new location:

{ok, Bin} = "/home/joe/abc" !! read, "/home/joe/def" !! {write, Bin}

Files can be named in a number of different ways. This example reads 4 files in parallel:

[A, B, C, D] = ["/home/joe/foo", "//", "", "ftp://www.some.where/pub/joe/a_file"] !! read

Distribution and Bang Bang

If a process name is of the form //Node/Name then the operation will be performed on a remote node instead of on the local node.

{ok, Bin} = "//" !! read, "/home/joe/def" !! {write, Bin}

Makes the previous program into a distributed version of the same thing.

Spawning and bang bang

In the beginning of the universe several magic processes are assumed to exist. These have names like /dev/... - these process are pre-defined and do magic things.

In particular. /dev/spawn is a process spawning device. If you send /dev/spawn A an Erlang Fun it will send you back an Erlang Pid


Pid1 = "/dev/spawn" !! fun() -> looper() end), Pid2 = "//" !! fun() -> ... end,

Creates two Erlang processes, one on the local node the other on

AND we can throw away the Erlang primitive spawn. It's replaced by the spawn device.

Naming of processes

Here are a few of the standard devices.

/dev/spawnprocess spawner
/dev/stdout stdout
/dev/log/spool/errors error logger
/dev/code code server
/proc/Name processes
/Path/To/File files
/dev/dets dets
/dev/ets ets
/dev/mnesia mnesia
http://Host/File read only files
//Node@Hist/Process remote processes

Ets and Dets and Bang bang

emacs logo Valid CSS!