Hello World (Dylan)

From LiteratePrograms

Jump to: navigation, search
Other implementations: Ada | ALGOL 68 | Alice ML | Amiga E | Applescript | AspectJ | Assembly Intel x86 Linux | Assembly Intel x86 NetBSD | AWK | bash | BASIC | Batch files | C | C, Cairo | C, Xlib | Candle | Clojure | C++ | C# | Delphi | Dylan | E | Eiffel | Erlang | Forth | FORTRAN | Fortress | Go | Groovy | Haskell | Hume | IBM PC bootstrap | Inform 7 | Java | Java, Swing | JavaScript | LaTeX | Lisp | Logo | Lua | Maple | MATLAB | Mercury | OCaml/F Sharp | occam | Oz | Pascal | Perl | PHP | Pic | PIR | PLI | PostScript | Prolog | Python | Rexx | Ruby | Scala | Scheme | Seed7 | sh | Smalltalk | SQL | Standard ML | SVG | Tcl | Tcl Tk | Visual Basic | Visual Basic .NET | XSL

This is a simple Dylan program that prints a string to the console, and then uses a for-loop to print the numbers 1 to 10. Dylan runs code at the top level of the startup module when the program starts, making this particularly simple.

<<hello-world.dylan>>=
module: hello-world
format-out("Hello World!\n");
for (i from 1 to 10)
  format-out("%d\n", i);
end for;

Using the Gwydion d2c tool, you can build this into a binary with the following command-line, where the "-s" denotes "static linking":

d2c -s hello-world.dylan
Download code
Views
Personal tools