“The only way to learn a new programming language is by writing
programs in it. The first program to write is the same for
all languages: Print the words hello, world”
—The C Programming Language
Kernighan and Ritchie
C is used for writing major applications, including C compilers. Perl is used for scripting. Mythryl is a wide spectrum language, used for both writing compilers and for scripting. There are a number of ways of running Mythryl code. In this section we will focus on just two, interactive evaluation and scripting.
Interactive evaluation of Mythryl code is done by typing my at the Linux prompt. This starts up Mythryl in an incremental mode in which lines of code are read, compiled and executed one at a time. This can be an effective way of experimenting with individual Mythryl language features:
linux$ my eval: printf "Hello, world!\n"; Hello, world! eval: ^D linux$
Type control-D to exit the interactive loop.
Mythryl scripting is done by using a text editor to create in an appropriate directory (folder) a text file (say "my-script") containing Mythryl source code which starts with the usual scripting shebang line:
#!/usr/bin/mythryl printf "Hello, world!\n";
Set the script executable and run it in the usual Linux fashion:
linux$ chmod +x my-script linux$ ./my-script Hello, world! linux$
There are also other ways of executing Mythryl code, such as from the Linux commandline:
linux$ my -x '6!' 720 linux$
We will not have use for these until we get to more advanced tutorials.