A downloadable book

Buy Now$19.99 USD or more

Do you want to learn the Odin Programming Language and demystify low-level programming?

Understanding the Odin Programming Language is a book that teaches both basic and advanced concepts. You'll learn about procedures, manual memory management, parametric polymorphism, data-oriented design, and much more.

A programming language is a tool. By understanding your tools, you will become a better craftsperson. Therefore, on top of how to write Odin code, this book also provides explanations of why things work the way they do.

The target audience is anyone with some programming experience. Odin is a simple yet powerful language, making it a great introduction to low-level programming, regardless of your programming background.

Chapters (click to expand)
  1. Introduction
  2. Hellope! A tiny program
  3. Variables and constants
  4. Some additional basics
  5. Making new types
  6. Pointers
  7. Procedures and scopes
  8. Fixed-memory containers
  9. Introduction to manual memory management
  10. More container types
  11. Strings
  12. Implicit context
  13. Making manual memory management easier
  14. Parametric polymorphism: Writing generic code
  15. Bit-related types
  16. Error handling
  17. Package system and code organization
  18. You don't need a build system
  19. Reflection and Run-Time Type Information (RTTI)
  20. Data-oriented design
  21. Making C library bindings (Foreign Function Interface)
  22. Debuggers
  23. Odin features you should avoid
  24. A tour of the core collection
  25. Libraries for creating video games
  26. Things I did not cover
  27. Where to find more Odin resources
  28. Thanks for reading!
  29. Appendix A: Handle-based array
  30. Appendix B: Using only fixed arrays
  31. Appendix C: gui_dropdown from CAT & ONION
  32. Appendix D: Box2D and raylib
  33. About the author


Formats (you get both!):

  • HTML: A pretty and portable HTML file, specially suited for computers.
  • eBook / EPUB: Specially suited for e-readers and eBook apps.

The book's website: https://odinbook.com/
Discuss the book on my Discord server: https://discord.gg/4FsHgtBmFK

Updated 6 days ago
Published 17 days ago
StatusReleased
CategoryBook
Rating
Rated 5.0 out of 5 stars
(11 total ratings)
AuthorKarl Zylinski
GenreEducational
Tagsbook, odin, odinlang, programming
LinksHomepage

Purchase

Buy Now$19.99 USD or more

In order to download this book you must purchase it at or above the minimum price of $19.99 USD. You will get access to the following files:

HTML (computer, tablet, phone) 3.2 MB
eBook / EPUB (e-reader, tablet, phone) 1.1 MB

Download demo

Download
Sample (HTML) 1.3 MB

Development log

Comments

Log in with itch.io to leave a comment.

(2 edits) (+3)

Although Odin is rather a simple programming language, there are elements that one could find not so obvious and straightforward. This book helps to dispel misunderstandings and incorrect assumptions about Odin's inner behavior. And, honestly, it's neat to have such condensed source of information on hand, considering modest popularity of the language and lack of literature besides official overview and occasional articles.

That said, I have several nitpicks:

1) I think that not freeing memory in the end of a program is not generally a good advice, since, I believe, there are some OSes that do not free memory once a program is terminated.

2) In chapter 13.2

destroy_level :: proc(level: Level) {
    vmem.arena_destroy(&level.arena)
}

should be

destroy_level :: proc(level: ^Level) {
    vmem.arena_destroy(&level.arena)
}

since you'd get

Error: Cannot take the pointer address of 'level.arena'

otherwise.

3) In chapter 18.4

If you want a file to not compile on macOS and not compile on Linux, then add this to the top of the file:
#+build !windows
#+build !linux

should probably be

#+build !darwin
#+build !linux

4) In chapter 12.4

if logh_err == os.ERROR_NONE {
    log.destroy_file_logger(logger)
    os.close(logh)
}

there is no need to close handle, because

log.destroy_file_logger(logger)

looks like

destroy_file_logger :: proc(log: Logger, allocator := context.allocator) {
    data := cast(^File_Console_Logger_Data)log.data
    if data.file_handle != os.INVALID_HANDLE {
        os.close(data.file_handle)
    }
    free(data, allocator)
}

and calling

os.close(logh)

may lead to the

An invalid handle was specified.

error.

(+3)

Thanks a lot for the kind words and for buying the book!

Thank you for the list of issues. I have fixed 2, 3 and 4.

Regarding 1: There is no modern OS that leaks after shutdown. While there are some really old OSes where this could happen, Odin doesn’t support any of those OSes anyways. However, a good reason to do the deallocation at the end is to keep third-party memory analysis programs, such as Valgrind, happy. I have added a note about that in the book (update coming later today or tomorrow).

(+4)

After many years coding in C and C++ I decided to switch to Odin. I've watched a couple of your videos on YouTube and decided to buy a book. Enjoying it so far. Thank you very much!

Its definitely better to buy this book to learn Odin than trying to search for brief pieces of information on this language on the internet.

(+2)

Thoroughly enjoying the book so far! Very approachable and informative.

(3 edits) (+4)

Hey Karl, the book is fantastic, I have learned so much about this language even in the space of a few days. One observation I wanted to ask, in section 10.2.5 you illustrate an application for maps by building a set, and say that Odin doesn't have any special support for sets, but I thought bit sets were exactly that?

https://odin-lang.org/docs/overview/#bit-sets

It even supports "overloading" of operators so you can do unions and such. Is there a fundamental difference here? Thanks again for such a great book!

EDIT: D'oh, my bad, your set example using a map allows sets of arbitrary type whereas bitsets are more limited. Never mind!

(1 edit) (+3)

Thank you! It’s great that you inform me about this confusion, because I should really make sure to stress the difference between them. After all, they both contain the word “set”. I’ll add fixing this to my TODO list.

(1 edit) (+3)

The updated version (https://zylinski.itch.io/odinbook/devlog/848116/version-12-new-section-on-address-sanitizer-and-lots-of-small-fixes ) has fixed this.

(+7)

Read three pages and zero cats. Disappointed.
Well-written, easy to read and even to understand (sometimes). I like it a lot. 

(+3)

Thanks 😻

(1 edit) (+9)

As far as I’ve read, the book is great , well structured and well written. It’s a must have for all the Odin programmers, ans perhaps for all the programmers who want to discover the great coding language that Odin Is.

(1 edit) (+3)

Thank you! Happy that you like it

(+8)

I've just barely started it and I'm already loving it! Everything is organized clearly and beautifully, explanations are easy to follow with nice illustrations that help a lot!

(+2)

Thank you 💖

(+8)

Such a well-written and beautifully-designed book on Odin! Thank you for your hard work!

(+2)

Thanks for the kind words!