Hello World#

You have just downloaded Open Dylan and installed it in /opt/opendylan. So how do you write the canonical Hello World app? This example assumes the bash shell is used. You may need to adjust for your local shell.

$ export PATH=/opt/opendylan/bin:$PATH
$ dylan new application --simple hello-world
$ cd hello-world
$ dylan build --all
...lots of output...
$ _build/bin/hello-world
Hello, world!

Ta da! Now a quick review of the steps with a little bit of explanation.

First you must set PATH so that the dylan and dylan-compiler commands will be found. ./_build/bin is where dylan-compiler puts the executables it builds.

Note

Some of these differ on Windows, so please be sure to read Notes for Windows Users if you are on Windows.

dylan new application --simple hello-world creates a directory named “hello-world”, and several files. The --simple flag says to skip generating a test suite library.

  1. hello-world.lid lists the files in the project. The order in which the files are listed here determines the order in which the code in them is loaded. The library definition file should always be first.

  2. library.dylan contains the library and module definitions. These can be extended as your project grows in complexity.

  3. hello-world.dylan contains the main program code.

  4. The registry directory is how dylan-compiler locates each used library. When using the dylan tool, this directory is generated for you. See Using Source Registries for details on the registry format.

  5. dylan-package.json describes the new “hello-world” package. This is where you can specify dependencies, the package location, etc. See the dylan-tool documentation for more on this. Note that the existence of this file turns the “hello-world” directory into a dylan workspace.

The first time you build hello-world all used libraries are built, all the way down to the dylan library itself. Subsequent builds only need to recompile hello-world itself and are therefore much faster.

Note

Don’t confuse the dylan library with the dylan executable program. The dylan library contains the core Dylan language features that are not implemented inside the compiler. The dylan program is a tool to help manager Dylan projects and is created from a library called dylan-tool.

The compiler places its output in the _build directory in the current working directory. This includes the libraries and executables that it builds. You can run the executable from this location, as noted above.