1. Introduction

Welcome! This is a series of articles with a goal of teaching you programming, via the Odin programming language. I’m going to do my best to cover all aspects of the core language here. If you are already familiar with the basics and want to learn about how to use some of the vendor packages, I have plans for that as well. I’m gradually staring to work on some raylib content to begin with. ...

May 8, 2025

2. Preparing to Program in Odin

Before you start programming, you need to make sure you have the tools you need. I’m not good at planning far ahead into the future, so we are only going to install what we need to get started. Later, when we figure out that we need something else, we’ll install it at that time. To get started, you will need: the Odin compiler a text editor or and IDE a terminal application Getting Odin The first thing to do is install Odin. How to do this will vary a bit depending on which operating system you are using. I mostly use Linux and BSD systems, and my primary work machine has Fedora on it. The Getting Started page on the Odin website shows you how to install Odin for your programming language. ...

May 10, 2025

3. First Programs

I’m going to assume that you have Odin installed at this point. We are going to jump straight into writing our first little program, a program that just prints a message to the terminal and exits. It’s probably the simplest program we can write, so it’s a quick way to test that our setup is working properly. And we can start asking some basic questions. Create a directory (folder). You can call it hellope, or some other name, if you wish. I personally avoid spaces in file and directory names and prefer to not use capital letters, for most part. In the folder create a file that ends with .odin. I will call it main.odin, but hellope.odin works just as well. ...

May 8, 2025

4. Variables and Conditionals

Variables are a requirement for us to be able to write programs that can do something useful. So let’s try to get an understanding of what they are. But before that, let’s write a bit of code as it’s easier to reason about something you’ve at least seen before. First, let’s rewrite the program we learned in the last lesson, but using a variable to hold the greeting. Remember to create a new directory and inside it to create a new file names something that ends in .odin. In this file, write the following code. ...

May 8, 2025

5. Command Line Args

In the last lesson, we learned what variables are and how to use them. We also briefly touched upon the if statement. In this lesson, we are going to learn how to go on step further towards writing dynamic programs by accepting external input. This could come in many forms: the user could be prompted to type something that gets captured into a variable the input could come from a file that is read the input could come from another program on your computer, via a so-called pipe (something we will look at later) the input could come from so-called command-line arguments Allowing the user to pass command-line arguments is probably the simplest of those, so that is what we are going to look into first. ...

May 8, 2025

6. Converting Strings to Other Types

We ended the last lesson by trying to write a program to add numbers together, that were passed in by the user as command-line arguments. This didn’t work, because command-line arguments are strings and the + operator is not supported for strings. String to integer conversion We are going to need a bit of help from another package, called strconv which exists in the core collection. The best way to figure out how something works is to try it out in a little program. ...

May 13, 2025

Answers to Exercises

The answer section is a bit of a work in progress at the moment. Kindly be patient. I am working on providing answers to every exercise. ...

May 10, 2025