Erlang is an open source programming language created in 1986 by Joe Armstrong and Robert Virding and Mike Williams.
#30on PLDB | 38Years Old | 29kRepos |
git clone https://github.com/erlang/otp
Erlang ( ER-lang) is a general-purpose, concurrent, functional programming language, as well as a garbage-collected runtime system. The term Erlang is used interchangeably with Erlang/OTP, or OTP, which consists of the Erlang runtime system, a number of ready-to-use components mainly written in Erlang, and a set of design principles for Erlang programs. The Erlang runtime system is known for its designs that are well suited for systems with the following characteristics: Distributed Fault-tolerant Soft real-time, Highly available, non-stop applications Hot swapping, where code can be changed without stopping a system. Read more on Wikipedia...
-module(square).
-export([square/1]).
square(A) -> A*A.
-module(main).
-export([main/0]).
main() ->
io:fwrite("Hello, world!\n").
-module(erlang_hw).
-export([start/0]).
start() ->
io:format("Hello World~n").
%% Hello World in Erlang
-module(hello).
-export([hello/0]).
hello() ->
io:format("Hello World!~n", []).
#!/usr/bin/env escript
-export([main/1]).
main([]) -> io:format("Hello, World!~n").
%% Second version
-module(counter).
-export([start/0, codeswitch/1]).
start() -> loop(0).
loop(Sum) ->
receive
{increment, Count} ->
loop(Sum+Count);
reset ->
loop(0);
{counter, Pid} ->
Pid ! {counter, Sum},
loop(Sum);
code_switch ->
?MODULE:codeswitch(Sum)
end.
codeswitch(Sum) -> loop(Sum).
after and andalso begin bnot bor bsl bsr bxor case catch cond div end fun if let not of or orelse receive rem try when xor
Feature | Supported | Example | Token |
---|---|---|---|
Standard Library | ✓ | io:format("Hello, World!~n"). | |
Integers | ✓ | % [+-]?(?:[2-9]|[12][0-9]|3[0-6])#[0-9a-zA-Z]+ | |
Floats | ✓ | % [+-]?\d+.\d+ | |
Conditionals | ✓ | ||
Functions | ✓ | ||
Print() Debugging | ✓ | io:format | |
Message Passing | ✓ | ||
Line Comments | ✓ | % A comment | % |
Macros | ✓ | -define(Const, Replacement). -define(Func(Var1,...,VarN), Replacement). | |
hasExports | ✓ | -export([start/0, codeswitch/1]). | |
File Imports | ✓ | -include("my_records.hrl"). -include("incdir/my_records.hrl"). -include("/home/user/proj/my_records.hrl"). -include("$PROJ_ROOT/my_records.hrl"). -include_lib("kernel/include/file.hrl"). | |
Directives | ✓ | -define(TIMEOUT, 200). ... call(Request) -> server:call(refserver, Request, ?TIMEOUT). -undef(Macro). | |
Comments | ✓ | % A comment | |
Shebang | ✓ | #!/usr/bin/env escript | |
Strings | ✓ | "hello world" | |
Case Insensitive Identifiers | X | ||
Semantic Indentation | X | ||
MultiLine Comments | X |