Concurrent Programming in ERLANG (part I)

Page 13

2 Introduction Real-time. Erlang is intended for programming soft real-time systems where response times in the order of milliseconds are required. Continuous operation. Erlang has primitives which allow code to be replaced in a running system and allow old and new versions of code to execute at the same time. This is of great use in ‘non-stop’ systems, telephone exchanges, air traffic control systems, etc., where the systems cannot be halted to make changes in the software. Robust. Safety is a crucial requirement in systems such as the above. There are three constructs in the language for detecting run-time errors. These can be used to program robust applications. Memory management. Erlang is a symbolic programming language with a real-time garbage collector. Memory is allocated automatically when required, and deallocated when no longer used. Typical programming errors associated with memory management cannot occur. Distribution. Erlang has no shared memory. All interaction between processes is by asynchronous message passing. Distributed systems can easily be built in Erlang. Applications written for a single processor can, without difficulty, be ported to run on networks of processors. Integration. Erlang can easily call or make use of programs written in other programming languages. These can be interfaced to the system in such a way that they appear to the programmer as if they were written in Erlang. We have freely borrowed ideas from declarative and concurrent programming languages. The early syntax of Erlang owed much to STRAND [?], though the current syntax is more reminiscent of an untyped ML. The model of concurrency is similar to that of SDL [?]. Our goal was to produce a small, simple and efficient language suitable for programming robust large-scale concurrent industrial applications. Thus, for reasons of efficiency, we have avoided many features commonly found in modern functional or logic programming languages. Currying, higher-order functions, lazy evaluation, ZF comprehension, logical variables, deep guards, etc., add to the expressive power of a declarative programming language, but their absence is not a significant detriment to the programming of typical industrial control applications. The use of a pattern matching syntax, and the ‘single assignment’ property of Erlang variables, leads to clear, short and reliable programs. Erlang was designed at the same time as its first implementation, which was an interpreter written in Prolog [?]. We were fortunate in having an enthusiastic group of users who were, at the same time, developing a prototype of a new telephone exchange. This resulted in an extremely pragmatic approach to language design. Constructs which were not used were removed. New constructs were introduced to solve problems which had caused our users to write convoluted code. Despite the fact that we often introduced backwardly incompatible changes to the language, our users had soon produced tens of thousands of lines of code and were actively


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.