Hello World

From Erlang Community

(Difference between revisions)
Revision as of 00:28, 5 September 2006 (edit)
Bfulgham (Talk | contribs)

← Previous diff
Revision as of 00:30, 5 September 2006 (edit) (undo)
Bfulgham (Talk | contribs)

Next diff →
Line 21: Line 21:
This is the first program many C programmers write, but it isn't the best way to start programming Erlang. Erlang makes extensive use of the functional style and it is better to become acquainted with this style before delving into input and output. This is the first program many C programmers write, but it isn't the best way to start programming Erlang. Erlang makes extensive use of the functional style and it is better to become acquainted with this style before delving into input and output.
-[[Category:CookBook]]+[[Category:CookBook]][[Category:Common Idioms]]

Revision as of 00:30, 5 September 2006

Problem

You want to write the classic "Hello World!" program in Erlang.

Solution

This is very easy in Erlang:

1> "Hello World!".
"Hello World!"
2> io:fwrite("Hello World!\n").
Hello World!
ok

Discussion

Erlang provides an interactive prompt, called the Read-Eval-Print-Loop (REPL), that allows you to type some simple function definitions into Erlang and have them evaluated immediately. This allows for much more immediate feedback than compiled languages.

This is the first program many C programmers write, but it isn't the best way to start programming Erlang. Erlang makes extensive use of the functional style and it is better to become acquainted with this style before delving into input and output.

Erlang/OTP Projects
Personal tools