If you have not already installed Ox 9.0 and setup OxEdit, do that first.
The canonical first program in Ox:
01a-hello-world.ox
1: #include "oxstd.h"
2: main() {
3: println("hello world ");
4: }
Output should appear that looks something like this
--------------- Ox at 12:12:42 on 06-Jan-2023 ---------------
Ox 9.06 (Windows_64/Parallel) (C) J.A. Doornik, 1994-2022 (oxlang.dev)
hello world
If you have not executed hello world.ox
, STOP.
Right click on the 01a-hello-world.ox
link and save the file to your computer. If necessary, move the file to your working Ox directory.
Open OxEdit. Click File->Open
or Ctrl-O. Find 01a-hello-world.ox
and open it.
Alternative to the previous two steps: Copy the code in the box above. Open OxEdit. Click File -> New
. Paste the code in.
Run the program by either Run -> Ox
or click on the left running man icon on the tool bar, which does the same thing. (If you created a new file you will be asked to save the file first. Save it to your working Ox directory.)
Why start with a program that just prints a dumb message?
There is a story and a reason. The original
hello world
program appeared on the first page of Chapter 1 of
The C Programming Language by Kernighan and Ritchie (1978). In 1978 just to get the words "hello world" to appear on a screen or a paper printout was a big hurdle that involved many issues. These issues were (and still are) hard to describe and resolve in a book. Kernighan and Ritchie began with the simple task that required resolution of all those difficult issues, because there was little point in teaching the rest of the C language if the student could not get it to print out a message. Once past the hurdle the reader could more easily absorb the details in the book knowing they could get their C program to do something.
To this day a good place to start any book about programming that may be picked up by a novice asked them to first run
hello world
. The hurdles are much lower for the target reader of this book than the typical reader of Kernighan and Ritchie in 1978. But computers are still mysterious to many bright people, including students of economics. Even people with computing experience find that getting this simple task to work is a good way to start learning a new computer language.
Exercises
Hello, Cleveland.
- Modify
01a-hello-world.ox
to print out dialogue from a favorite movie or play. Have your code also display a link to the clip or the script.
- Example
- Your Ox code might produce
David St. Hubbins: ROCK AND ROLL!
Derek Smalls: HELLO, CLEVELAND!
https://youtu.be/QiEglUjqWj0?t=103
- Learn how to use the formatting code
\n
so that Ox will print out each line of dialogue separately with only one println()
statement.
- Find the Ox function that will convert a bit of text (called a string) to all upper case letters. That is, this Ox function will take
hello, Cleveland
and convert it to
HELLO, CLEVELAND
. Use it in your code.