12/08/2018, 17:08

Erlang - Concurrent Functional Programming in the Telecommunications Industry

Now, let 's forget your computer. Iam going to use my eyes and tell you about what I see. Some people are coding, the anothers are talking. My friend is taking a cup of coffee. All of them are concurrent. So today, we will talk about the parallel activities as sets of communicating parallel ...

Now, let 's forget your computer. Iam going to use my eyes and tell you about what I see. Some people are coding, the anothers are talking. My friend is taking a cup of coffee. All of them are concurrent. So today, we will talk about the parallel activities as sets of communicating parallel processes. We have seen some words like concurrent, simultaneous, parallel mean almost the same thing. But in programming, we need to be more precise. Especially, we need to distinguish between concurrent and parallel programs. If we have single-core computer, we can not say parallel programing. Because at the same time, we can do only one thing on it. However, we can build concurrent program, because of the time-shares. We can make schedule, and use time between the diffrent tasks, maintaining the illusion that the different tasks run in parallel. We can keep this mind into telecommuication, which is developmental in today.

There are many difficult demands, such as large number of concurrent activities, systems distributed over several computers, large and complex software systems, software maintenance (reconfiguration, etc...), while the system is in operation, fault tolerance to hardware failures and software errors,... The concurrent functional programming, Erlang, producted to solve it. Erlang was developed by Ericsson. Its first release is in 1986, and the first open source release of the language in 1998. Althought Erlang is fuctional programming, but it has many benefits:

  • Performance is improved. Imagine you have two tasks: A, which takes 10 minutes and B, which takes 15 minutes. On a single CPU doing both, it takes 25 minutes. But in two CPUs. they take 15 minutes. Today, multi-core is popular, so if you have a suitable problem and a suitable computer, your program can run faster (only you write in concurrent program).
  • The application needs to handle a large number of concurrent activities. An Erlang program is built up of modules which are separately compiled and loaded. Only explicitly exported functions can be called from another module. Because of the number of concurrent activities, our program has so many threads. We have to make a solution for all requests quickly. Concurrency is supported by the Erlang implementation without help from the operating system. Processes have no shared memory and communicate by sending and receiving messages asynchronously. Erlang implements can support application with the large number of concurrent processes (20.000 - 30.000).
  • It should be easily distributable over a network of computers. We can make distributed system by Erlang. An Erlang program is lightweight and has located on a computer (perhaps running different operating systems), connected over a network.
  • There should be a facility to make the application fault-tolerant to both software and hardware errors. Fault tolerance is similar to scalability. The keys to fault tolerance are independence and redundancy. Erlang programs are made up of many small independent processes. To protect the entire computer (or data center), we need to detect failures in remote computers. Althought Erlang was designed for building fault-tolerant telecommunications systems, but that technology can be applied as well to building fault-tolerant scalable web systems or cloud services.
  • The application should be scalable. This means that it should have the ability to span across multiple servers with little or no change. Concurrent programs are made from independent processes. Because of this, we can easily scale the system by increasing the number of processes and adding more CPUs. A program can crash. When it makes error, only that program stops, the remains keep running.
  • It should be easily upgradable and reconfigurable without having to stop and restart the application itself. Erlang allows program code to be changed in a running system (hot code loading). When a new version of a module is loaded, newly spawned processes will run the new version while on-going processes continue and finish undisturbed. It is thus possible to install bug fixes and upgrades in a running system without disturbing its (currently running) operation.
  • The application should be responsive to users within certain strict timeframes. Erlang supports programming "soft" real time systems, which require response times in the order of milliseconds.

Long garbage collection delays in such systems are unacceptable, so Erlang is able to reclaim memory in small parts of the system every time the garbage collector is invoked. In the real world, every things happen in sequentially. The mismatch between the parallelism in the real world and the sequentiality in our programming languages makes controling problems in a sequential language difficult. In Erlang, we can match parallel activities onto Erlang concurrency in a straightforward manner. This results in clear and easily understood code. Erlang processes communicate with other programs or the operating system using the same message passing mechanism as is used between Erlang processes. If required for reasons of efficiency, C programs can be directly linked into the Erlang run-time system. These are some general things about Erlang. Hope you have clear and exciting experiment with Erlang - concurrent functional programing.

Referrence:

  • https://www.ibm.com/developerworks/library/os-erlang1/index.html
  • https://link.springer.com/content/pdf/10.1007/978-0-387-35404-0_15.pdf
0