Odin · terminal · a gentle introduction

Odin and Me

A gentle, exercise-driven introduction to the Odin programming language through small, complete text-mode console programs.

Odin and Me walks you through a shelf of small, complete console programs: a temperature converter, a word-counting tool, a handful of ASCII figures, a number-guessing game, and a DOS-style screen built from raw ANSI escape sequences. Everything converges on Muninn, a box-drawn, menu-driven console note-keeper whose notes persist to a file between runs. No graphics, no audio, no third-party libraries, no package manager, just the terminal and Odin's standard library. Gentler than the sibling books, and the natural place to start if you're new to Odin itself.

Contents

  1. -PrefaceWhy this book exists, who it's for, and the ground rules.
  2. 1Setup & first programInstall Odin, set up your editor, and print your first line of output.
  3. 2Enough OdinVariables, loops, switch and procedures: a working knowledge to build on.
  4. 3Talking to the terminalRead user input, parse it safely, and write an interactive temperature converter.
  5. 4Strings, runes & word countBytes versus runes, safe slicing, and a line/word/character counting tool.
  6. 5ASCII figuresNested loops as a drawing tool: triangles, a diamond and a number pyramid.
  7. 6Structs, enums & a guessing gameProgram state in a struct, an enum-driven difficulty, and a complete guessing game.
  8. 7Menus & the DOS lookRaw ANSI escapes for colour, cursor control and box-drawing, wired into a menu loop.
  9. 8Files & a first save/loadRead and write a whole file, and a note-keeper that survives being closed and reopened.
  10. 9Building Muninn: the note storeThe Note and Store types, and add/find/delete/list/search over a dynamic array.
  11. 10Muninn gets a faceA real menu wired to the note store: a complete, usable Muninn.
  12. 11Making it robustor_return, a reusable validated-input helper, and honest error reporting.
  13. 12ShippingA release build, cross-compiling, and where the book's journey goes next.
  14. App AOdin quick referenceA one-page cheat-sheet of the Odin used in this book.
  15. App BFull source listingsThe complete, verified source of the finished Muninn project.
  16. App CBeyond the bookWhere a real console-application toolkit goes further than this book chose to.
  17. App DTroubleshootingThe traps that recur across the book, gathered in one place.
  18. App ELinks & referencesEverything the book cites, grouped, plus credits.
  19. App FChangelogEdition history and changes to the manuscript and reference code.

The finished project

Every code sample in the book is real and compiled. The complete source is in Appendix B, and requires only the Odin compiler to build and run. Want more like this? My Toys page collects the rest of my browser experiments, and the Programming section has more write-ups.

Once you're comfortable: the other two books

Odin and Me is the entry point of the set. Yo Odin builds a WebAssembly arcade game from scratch, and Odin't Know That builds a native desktop game with vendor:raylib. Either is the natural next step once you're comfortable with the language.

Going deeper on Odin

This book teaches the slice of Odin a text-mode console application needs. For the whole language, read Karl Zylinski's Understanding the Odin Programming Language, warmly recommended.