Download sample projects
These are tiny programs you can use as a starting point. Download any .hy file and save it to a folder of your choice. Each example is designed around the published Linux compiler’s documented language features.
1. Hello, world!
Section titled “1. Hello, world!”What you’ll learn: the main entry point and printing text.
In a terminal, go to the folder containing the file and run:
hy compile hello.hy -o hellochmod +x hello./helloExpected output:
Hello, Hydrogen!2. Count to five
Section titled “2. Count to five”What you’ll learn: variables, a while loop, and simple maths.
hy compile count-to-five.hy -o count-to-fivechmod +x count-to-five./count-to-fiveThe program prints the numbers one to five. Try changing the limit to ten.
3. Personal greeting
Section titled “3. Personal greeting”What you’ll learn: reading command-line arguments and changing a message.
hy compile greet-you.hy -o greet-youchmod +x greet-you./greet-you AdaThe program prints Hello, Ada! Run it without a name to see the default greeting.
What’s next?
Section titled “What’s next?”Follow the first-program guide, read about control flow, or learn how to group files using a Hydrogen project.
For more involved or experimental examples, browse the compiler’s development samples. These may require a development compiler rather than the published release.