|
||||||
Get Started with the Erlang Programming LanguageHow to Evaluate Simple Statements in an Ericsson Erlang ShellThe Ericsson Erlang programming language was developed for their mobile telephony switches and is now open source. It can handle thousands of parallel, distributed events
Most people will know that Ericsson (in partnership with Sony) are famous for producing a wide range of mobile (or cell) phones, and there are many people who will also know that much of the equipment used to build the mobile telephone networks (built by companies such as Vodafone) is also supplied by Ericsson. However, what most people don't know is that Ericsson have created their own programming language known as Erlang, and not only that: they've even made it open source and freely available for anyone to use. Ericsson created Erlang for use with their telecommunication equipment (such as their mobile telephony switches) because they needed a language that is:
They were unable to find any language that could do all of that to their satisfaction, and so Erlang was created in the Ericsson Computer Science Laboratory. Obtaining and Installing ErlangThe Erlang programming language installation application can be downloaded from http://www.erlang.org. Once that's been done then the Erlang emulator can be accessed from the start menu or, if the path is set correctly, then the user just needs to type "erl" on the command prompt. They can then start entering Erlang Code. Using the Erlang ShellThe Erlang shell (shown in figure 1 at the bottom of this article) is just like any Linux shell or the Windows command prompt:
So, for example, the user can type in a string such as: "Hello World".
And the text will be displayed on the screen, or the user could type in: PI = 3.14159265358979.
R = 5.
C = 2 * PI * R.
This will display 31.4159265358979 on the screen (as can be seen in figure 2), and there a few things that should be noted from this:
The next stage is to format the output. Displaying Outputs in an Erlang ShellErlang will immediately evaluate any inputs and display the results of that evaluation. However, in a complex calculation these outputs may be all very confusing. Therefore, the programmer can produce a formatted output by using the io:format method, for example: io:format ("The circumference of a circle of radius ~w is ~w~n", [R, C]).
The io:format takes two inputs:
The output (as shown in figure 3) will be something like: The circumference of a circle of radius 5 is 31.4159265358979
And so, in this way, the programmer can use the Erlang programming language to quickly analyse information and to display it in a useful format. However, all of the code looked at so far can only be used whilst the current Erlang shell is running. It is all lost as soon as the shell is closed. The next step, therefore, is to start creating code that can be reused, and that's discussed in Create and Use Erlang Modules and Functions.
The copyright of the article Get Started with the Erlang Programming Language in Computer Programming Languages is owned by Mark Alexander Bain. Permission to republish Get Started with the Erlang Programming Language in print or online must be granted by the author in writing.
|
||||||
|
|
||||||
|
|
||||||