Erlang (programming language)/Tutorials/Hello: Difference between revisions

From Citizendium
Jump to navigation Jump to search
imported>Eric Evers
(New page: =Hello World (serial)= ==Code Example== -module(hello). -export([start/0]). start() -> io:format("Hello, world!\n"). ==Analysis of the example== The Hello World program (se...)
 
(removing incomplete, broken ref)
 
(3 intermediate revisions by 3 users not shown)
Line 1: Line 1:
=Hello World (serial)=
=Hello World (serial)=
==Code Example==
==Code Example==
Line 10: Line 11:
==Analysis of the example==
==Analysis of the example==


The [[Hello World]] program (see above) appears in many programming languages books and articles as a cursory introduction into a language's [[syntax]]. The first hello world program was introduced in the book ''The C Programming Language''<ref name="K&R"/>.
The [[Hello World]] program (see above) appears in many programming languages books and articles as a cursory introduction into a language's [[syntax]]. The first hello world program was introduced in the book ''The C Programming Language''.


<code>-module(hello)</code> tells the [[compiler]] to create a new module(library) called hello. The code tells us the file name for this code: hello.erl.  
<code>-module(hello)</code> tells the [[compiler]] to create a new module(library) called hello. The code tells us the file name for this code: hello.erl.  

Latest revision as of 08:34, 5 May 2024

Hello World (serial)

Code Example

-module(hello).
-export([start/0]).

start() ->
   io:format("Hello, world!\n").

Analysis of the example

The Hello World program (see above) appears in many programming languages books and articles as a cursory introduction into a language's syntax. The first hello world program was introduced in the book The C Programming Language.

-module(hello) tells the compiler to create a new module(library) called hello. The code tells us the file name for this code: hello.erl.

-export([start/0]). exports a function named start with 0 arguments to the world outside of this module called hello.

start() -> tells the compiler that there is a function named start() with no arguments.

io:format("Hello, world!\n"). will make the program output Hello, world! and a new line (\n) on the screen.