学生姓名(Name) :


Language features of Elixir and Go


Download 44.18 Kb.
bet6/6
Sana10.11.2023
Hajmi44.18 Kb.
#1763724
1   2   3   4   5   6
Bog'liq
attachment N1

Language features of Elixir and Go:
Next I will explore some of the features of Elixir. In Elixir everything is an expression. Another choice is that the code is divided into the statements and expressions. The expressions are language constructs composed of variables and operations, which when evaluated return a result. An example of expression is a + b, which calculates together variables a and b. Statements on the other hand affect the flow of the program without returning results. While loop is a common example of a statement. While loop executes itself until the given condition is false without returning a result.
Go programs start executing from a package called main.Go programs are usually divided into packages. One package includes variables,types, functions and sub-packages. Package in Go is defined by creating a folder with a package name. This folder then contains files belonging to the package. Package can be divided to multiple files to make the code cleaner and more manageable. Subpackage is created just by adding a folder inside of the parent package. Import string for the package would be "package" and for sub-package "package/sub-package".
Erlang and OTP:
When talking about Elixir it is impossible not to talk about Erlang at the same time. This is because a lot of the libraries in the language come from Erlang. Elixir also benefits from all the features provided by the Erlang runtime system (ERTS) and Open Telecom Platform (OTP). OTP and Erlang are actually so intertwined that when the name Erlang is used it means the combination of both language and OTP runtime system and libraries.


Concurrency and channels:
One of the main features of Go language is easy concurrency by using Go routines. Go routines are lightweight threads scheduled by the Go run-time environment. This scheduling happens in predetermined points. Some of these scheduling points are channel sending and receiving, thread blocking on syscall, garbage collection and starting new a thread using the go keyword.
Download 44.18 Kb.

Do'stlaringiz bilan baham:
1   2   3   4   5   6




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling