A short tutorial - Part 1: Running Wirbel ProgramsFebruary 03. 2012
PreparationsLet's assume you have successfully installed the Wirbel development environment. If not, please have a look at the Installation procedure. Three ways for running a programYou have three ways for running a Wirbel program. First let's write one. Please create a file named hello.w containing the following code: hello.w
print("Hello World.")
The first way to run this is by simply calling it with wirbel: user@host> wirbel hello.w Hello World. The second way is to make use of the so called shebang line. Edit hello.w like this:
#!/usr/bin/wirbel
print("Hello World.")
Now make you program executable: user@host> chmod +x hello.w And feel free to run it like any executable program: user@host> ./hello.w Hello World. The wirbel compilerSo far not much difference from Python or BASH. But Wirbel has a third way: Calling the Wirbel compiler wic and compile the program into machine code. It's really simple. Not a single compiler switch is needed: user@host> wic hello.w The compiler creates the file hello, which is directly executable: user@host> ./hello Hello World. hello is a native ELF binary. Don't believe it? See what file tells you: user@host> file hello hello: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.6.8, dynamically linked (uses shared libs), not stripped As a matter of fact the other two ways of running a Wirbel program automatically call wic to compile the program if the binary is not existant or not up to date and then run it. By the way: The compiled program hello is stand alone and completely independent from the Wirbel development environment. Next Chapter: Variables and Types |
| |||||||||||||||||||||||||||||||||||||||