summaryrefslogtreecommitdiff
path: root/doc/colm/0_04_hello_world.adoc
diff options
context:
space:
mode:
Diffstat (limited to 'doc/colm/0_04_hello_world.adoc')
-rw-r--r--doc/colm/0_04_hello_world.adoc67
1 files changed, 67 insertions, 0 deletions
diff --git a/doc/colm/0_04_hello_world.adoc b/doc/colm/0_04_hello_world.adoc
new file mode 100644
index 00000000..0406a159
--- /dev/null
+++ b/doc/colm/0_04_hello_world.adoc
@@ -0,0 +1,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'