Skip to content

Commit 975fba0

Browse files
jonasgeilergadilashashank
authored andcommitted
Erlang chapter (#43)
* working on Erlang part, added a lot of text, waiting ffor grammar corrections * fixed mdlint error, now Travis works * deleted blank lines * Update advantages.md * Update disadvantages.md * grammar edits * Some edits * Update misc.md * Update SUMMARY.md * Update disadvantages.md * Update history.md * Update SUMMARY.md
1 parent 09c8394 commit 975fba0

8 files changed

Lines changed: 215 additions & 0 deletions

File tree

book/SUMMARY.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,20 @@
5555

5656
* [Conclusion](languages/python/conclusion.md)
5757

58+
* [Erlang](languages/erlang/README.md)
59+
60+
* [Introduction](languages/erlang/intro.md)
61+
62+
* [History](languages/erlang/history.md)
63+
64+
* [Advantages](languages/erlang/advantages.md)
65+
66+
* [Disadvantages](languages/erlang/disadvantages.md)
67+
68+
* [Some interesting facts](languages/erlang/misc.md)
69+
70+
* [Conclusion](languages/erlang/conclusion.md)
71+
5872
* [JavaScript](languages/js/README.md)
5973

6074
* [Introduction](languages/js/intro.md)

book/languages/erlang/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Hello
2+
3+
> This chapter was made by Skayo.
4+
5+
Welcome in the Erlang part.
6+
Hope you'll enjoy reading it.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Advantages of Erlang
2+
3+
Some of the Erlang advantages are:
4+
5+
* **Concurrency**
6+
7+
* **Built in dispersion**
8+
9+
You can create processes with any node on any node.
10+
11+
* **Error handling**
12+
13+
When the process breaks down, it leaves and sends a message to the process a control who can take the appropriate action - e.g. restart or end broken process and start the next one.
14+
15+
* **Dynamic and strong typing discipline**
16+
17+
* **Support for multiprocessor systems**
18+
19+
* **Hot code upgrade**
20+
21+
You don't have to stop system to update code.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Conclusion
2+
3+
Erlang has a crazy syntax, and that's the reason why some don't like it.
4+
I like it, because I like its creators, Ericsson company.
5+
I think Erlang should have more fans, maybe not the fans of the syntax, but at least fans of this language.
6+
It has amazing features and need more attention than it has now.
7+
8+
## Sources
9+
10+
* [Wikipedia](https://en.wikipedia.org/wiki/Erlang_(programming_language))
11+
12+
* [Erlang official website](https://www.erlang.org/)
13+
14+
* [Erlang Solutions](https://www.erlang-solutions.com/)
15+
16+
## Regarding authors
17+
18+
This chapter was made by [Skayo](https://github.com/Skayo).
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Disadvantages of Erlang
2+
3+
* Programmers find it difficult to use erlang due to its relatively
4+
difficult syntax.

book/languages/erlang/history.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# History
2+
3+
## Meaning of 'Erlang'
4+
5+
The name *Erlang* was given in honor of the first scientist in the field of telecommunications: **Agner Krarup Erlang (1878-1929)**
6+
7+
Sometimes the name of language is also interpreted as **Er**icsson + *Lang*uage = **Er***lang*.
8+
9+
## In Ericsson lab
10+
11+
**Between 1982 and 1986**, in Ericsson labs were conducting research on the suitability of some existing programming languages in terms of creating apps for **telecommunications** needs,
12+
which required **long-lasting** and **trouble-free operation with a large number of threads**.
13+
The features of each language were analyzed, identyfiying potential problems that they could have caused.
14+
Despite the gradual narrowing of the set of considered languages, it was established that **none** of them meet the company's requirements, therefore it was decided to design a **completely new language from scratch**.
15+
16+
## Long story in short
17+
18+
The author of the language is **Joe Armstrong**.
19+
He modeled Erlang on the **Prolog language** and wrote first Erlang interpreter in it.
20+
In **1990**, Erlang was shown publicly at the **ISS '90 conference**, which resulted in increased number of users.
21+
But the first implementation of the language was so inefficent that in the **late 1980s** itself, work began on a faster version.
22+
**It's final release took place in 1991**.
23+
**A Year later**, the first book about Erlang was published and in **1993**, Ericsson launched an independent department
24+
assigned with the development and distribution of the system and tools for it.
25+
26+
In **1998**, Ericsson launched **AXD301** switch with software that contained a milion lines of code in Erlang, which achieved a reliability index of **99.9999999%** (that's the real number!), which meant that in a year of usage, the system could
27+
have **at most 0.0315 seconds of downtime due to a failure**.
28+
Shortly thereafter, Ericsson banned its affiliates from using Erlang in new products due to its proprietary nature.
29+
**This caused a conflict between Ericsson and Armstrong, who left the company with the team.**
30+
**At the end of the same year**, the Erlang implementation code was **opened sourced and made available as free software**.
31+
The ban was withdrawn later and **Armstrong** returned to work with Ericsson in **2004**.

book/languages/erlang/intro.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Introduction
2+
3+
## Inception
4+
5+
**Erlang** first appeared in the Ericsson laboratory and it is successfully used in projects requiring **high scalability and resistance to failures**.
6+
7+
It is a **functional**, **dynamic language** with strict typing in which the main focus was on concurrency and **processing capabilities distributed**.
8+
9+
Erlang **was a proprietary programming language** used by **Ericsson**, but since **1998** when the source code was open sourced
10+
and is gaining popularity day by day.
11+
12+
It is successfully used in **commercial products** (for example: **WhatsApp**) around the world that go many times beyond its **telecommunications roots**.
13+
14+
> The file extension for Erlang are **.erl** and **.hrl**
15+
16+
## Erlang features
17+
18+
* **Concurrency**
19+
20+
Processes are the **basic elements** in the structure of applications written in Erlang.
21+
The implementation of concurrent processes is **independent** of the system and does not use mechanisms specific to the given environment like threads, for example.
22+
Creating and managing Erlang processes is very simple, while in other languages ​​concurrency provides many problems and is the source of a small number of different types of errors.
23+
Erlang processes are **much lighter** than system ones (about 300 bytes per one process), thanks to which the processes of creating and destroying processes are *relatively* cheap computationally and memory.
24+
In a single Erlang system **possible** is to create up to one million processes without significant performance degradation.
25+
**In Computer Language Shootout in the competition for sending messages between thousands of threads (thread-ring) solution written in Erlang ranks first in terms of performance and code volume**.
26+
Communication between processes in Erlang (due to the fact that the processes do not divide shared memory) takes place by sending asynchronous messages.
27+
A queue is associated with each process **FIFO**, used to receive messages.
28+
The receiving process determines whether process the message or not.
29+
Every process has its own mailbox, in the form of a queue in which they are stored messages sent by other processes until they are read.
30+
Receiving messages is done by the **pattern matching mechanism**.
31+
After reading the message, the Erlang process returns to **execution**.
32+
To create messages can be used **any data structure** (integers, floating point, characters, atoms) and even functions.
33+
34+
* **Dispersion**
35+
36+
The dispersed mechanism is **built into** the language. You can create processes with any node on any node.
37+
The process *can* be created on remote node, and communication with it is transparent (communication with the remote process is carried out in **exactly the same way as with local process**).
38+
39+
* **Error handling**
40+
41+
Error handling generally takes place through the **supervision of some processes over others**.
42+
When the process breaks down, it leaves and sends a message to the process a control who can take the appropriate action - e.g. restart or end broken process and start the next one.
43+
This approach to programming increases reliability and makes the code less complicated.
44+
In addition, the process, the control and supervised process do not have to be on the same physical machine, thanks to which it is relatively easy to program systems high availability, in which particular functions are performed by efficient nodes at a given moment.
45+
46+
* **Hot code replacement (Hot code upgrade)**
47+
48+
*Many* systems **can not be stopped for software exchange purposes**.
49+
**In Erlang you can exchange the code in the running system** (in the system co-exist for a moment both codes), and thus install bug fixesand upgrades without stopping the system.
50+
51+
* **Support for multiprocessor systems**
52+
53+
From the **R11** version, Erlang's environment *can* automatically exploit the potential hidden in multi-core processors and systems multiprocessor.
54+
Previously, to use such a system belonged run several copies of the virtual machine, which unfortunately increased memory consumption, and increased the cost of sending messages unnecessarily between processes on one computer.

book/languages/erlang/misc.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Some interesting facts about Erlang
2+
3+
* WhatsApp messaging system is build on Erlang, it supports over 800 million users and 30 billion messages per day
4+
5+
* bet365 uses Erlangin their Online Gambling & Betting industry.
6+
7+
* Erlang transports 40% of all telecom data
8+
9+
* Erlang can be used in everywhere on the backend
10+
11+
* 3 of the leading banks are built on Erlang
12+
13+
* 2 of the leading blockchains are built on Erlang
14+
15+
## Example of **Hello World** code written in Erlang compared to other languages
16+
17+
### **Erlang**
18+
19+
```Erlang
20+
-module(hello).
21+
-export([hello_world/0]).
22+
hello_world() -> io:fwrite("hello, world\n").
23+
```
24+
25+
After this is done, you'll need more work.
26+
Save it as hello.erl and compile it from the erlang shell.
27+
Don't forget the full-stop ("period" in American English) at the end of each command, as shown:
28+
29+
Erlang (BEAM) emulator version 4.9.1 [source]
30+
Eshell V4.9.1 (abort with ^G)
31+
c(hello).
32+
{ok,hello}
33+
34+
(on unix systems you start the erlang shell by typing "erl" at the command line.
35+
On Windows, open a command prompt window and type "werl", or find the Erlang icon in the programs menu).
36+
To run the program from the Erlang shell:
37+
38+
hello:hello_world().
39+
hello, world
40+
ok
41+
42+
### **JavaScript**
43+
44+
```JavaScript
45+
"use strict" // This declares strict mode and using it is a good security practice.
46+
console.log("Hello world!"); // semicolon is not mandatory but recommended
47+
```
48+
49+
### **Kotlin**
50+
51+
```Kotlin
52+
fun main(args: Array<String>) {
53+
println("Hello world!")
54+
}
55+
```
56+
57+
### **Python**
58+
59+
```Python
60+
print "Hello world!"
61+
```
62+
63+
### **Ruby**
64+
65+
```Ruby
66+
puts "Hello world!"
67+
```

0 commit comments

Comments
 (0)