summaryrefslogtreecommitdiff
path: root/doc/colm/0_04_hello_world.adoc
blob: 0406a15934f8be273435a5d28224ee5b6aa871e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
Hello world
===========

The obligatory 'hello world' program:

[source,chapel]
.hello_world.lm
----
include::code/hello_world.lm[]
----

We run it with:

[source,bash]
----
/opt/colm/bin/colm hello_world.lm
----

This creates a executable chmod+x file with the same name:


[source,bash]
----
ls -l hello_world
----

----
-rwxr-xr-x 1 peter peter 29848 Nov  2 10:06 /tmp/hello_world
----

When we execute it:

----
./hello_world
----

We'll see:

----
hello world
----

We can strip the file to check if we can reduce the executable.
[source,bash]
----
strip ./hello_world
ls -l hello_words
----

----
-rwxr-xr-x 1 peter peter 10360 Nov  2 10:10 /tmp/hello_world
----

== Deja-vu: python2-python3
TIP: It turns out that print is also a function that can have multiple arguments.

[source,chapel]
.hello_world_ext.lm
----
print( 'hello ', "world" "\r\n" )
----

We also notice that:
* the quotes can be single and double
* there is no need for a concat operator
* the whitespace is not significant
* the newlines '\n' appear to be '\r\n'