Understanding the Odin Programming Language
A downloadable book
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 Odin concepts. You'll learn about procedures, manual memory management, parametric polymorphism, data-oriented design, and much more.
The target audience is anyone with some programming experience. Odin is a simple yet powerful language, making this book a great introduction to low-level programming, regardless of your background.
A programming language is a tool. By understanding your tools, you will become a better craftsperson. Therefore, this book does not just explain how to write Odin code. It also explains why the language works the way it does.
Chapters (click to expand)
- Introduction
- Hellope! A tiny program
- Variables and constants
- Some additional basics
- Making new types
- Pointers
- Procedures and scopes
- Fixed-memory containers
- Introduction to manual memory management
- More container types
- Strings
- Implicit context
- Making manual memory management easier
- Parametric polymorphism: Writing generic code
- Bit-related types
- Error handling
- Package system and code organization
- You (probably) don't need a build system
- Reflection and Run-Time Type Information (RTTI)
- Data-oriented design
- Making C library bindings (Foreign Function Interface)
- Debuggers
- Odin features you should avoid
- A tour of the core collection
- Libraries for creating video games
- A few more things...
- Where to find more Odin resources
- Thanks for reading!
- Appendix A: Handle-based array
- Appendix B: Using only fixed arrays
- Appendix C: gui_dropdown from CAT & ONION
- Appendix D: Box2D and raylib
- 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.
What people say:
I highly recommend Karl Zylinski's excellently written book on Odin—perfect for anyone who wants to learn and understand the Odin programming language. -Bill "gingerBill" Hall, creator of Odin.
Karl makes a great job at explaining Odin. I had a good experience with garbage collected language like Golang and the book really helped me to transition to a non garbage collected language like Odin. -Review on store.zylinski.se by Kevin D.
I never read, I get distracted easily. But the writing style here is so good, that I didn't have any issues reading through the whole thing in a couple days. -Review on store.zylinski.se by Shaka.
The book's website: https://odinbook.com/
Discuss the book on my Discord server: https://discord.gg/4FsHgtBmFK
Note to EU and UK customers: Itch charges the wrong VAT for e-books. If you live in EU or UK, then you can save money by buying the book from my store: https://store.zylinski.se/b/tnwvO
| Status | Released |
| Category | Book |
| Rating | Rated 5.0 out of 5 stars (26 total ratings) |
| Author | Karl Zylinski |
| Genre | Educational |
| Tags | book, odin, odinlang, programming |
| Links | Homepage |
Purchase
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:
Download demo
Development log
- Version 1.8: Strings chapter overhaul53 days ago
- Version 1.7: Minor fixes and the futureJun 03, 2025
- Version 1.6: Keeping the book up-to-dateMar 21, 2025
- Version 1.5: The biggest update so far!Jan 16, 2025
- Version 1.4Dec 16, 2024
- Version 1.3 and Amazon releaseDec 12, 2024
- Version 1.2: New section on address sanitizer and lots of small fixes!Dec 10, 2024
- Thanks and small updateDec 06, 2024




Comments
Log in with itch.io to leave a comment.
Created an account just so I could comment.
What a fantastic book. Best 20 bucks I've spent in a long time. I love that you spend time explaining how things work under the hood, it really helps interanalize the language. Your example code is also very easy to follow and helps clarify things a lot. A good example is worth a 1000 words :)
If I can offer some minor feedback. Section 16.1 talks about boolean returns. The example you give is scanning a slice for a string. If a matching string isn't found the procedure returns false, which you refer to as an error. I think there is a subtle but important distinction here, because that's actually a successful result, not an error. The string doesn't exist in the slice, which is an expexted situation and useful information for the callee. In this case the boolean isn't so much conveying error information, as it is the status of the query. Still a very useful use case, but distinct from an error. Errors, at least IMO, should be reserves for a failure related to the inability to properly complete the work being done by a proceedure, such as a network failure or inability to read a file (outside the scope of that example obviously).
This section also seems like it comes really late in the book. As I was reading I kind of expected to find that section somewhere near the section on procedures, since it's part of dealing with procedure returns.
Edit: I realize the bulk of that comment ended being the feedback part. Sorry about that. Seriously great book. Thank you so much for writing it :)
Hi Karl,
thank you for the update! Is it possible that you forgot to change the version number in the html file to 1.8?
Cheers
Hi. It should be 1.8, I just tried redownloading it. Can you try again please?
You"re right. My bad. Maybe some cache thingy. Thanks!
Hi Karl!! Will you print your book as a PDF too?? And will you do a new one about Odin and game programming??
Hi!
If you mean convert it to PDF file, then you can do it yourself. You can print both the HTML or ePub to PDF, depending on your tastes. Just use the “Print to PDF” option when opening the print dialogue.
If you mean print to physical book, then no, I am not planning that right now. The book was designed to be a bit interactive (links etc). It doesn’t come out as nice when I remove that stuff.
I’ve not planned another book anytime soon!
/Karl
Really enjoying the book so far!
I'm probably not the target audience of this book (very little programming experience) and I'm managing to follow along/understand everything, but with that said I really wish this book had exercises spread throughout it. Similar to that of a math textbook or something along those lines where a few exercises follow after a section.
Hi, reading the book now, it’s fantastic, I’ve found my C-replacement! Can’t wait to get to the parts on allocators and debuggers!
One thing I’ve noticed is that there’s not much about
switchin there, beside how it’s used with enums and unions. For example I love how it can deal with ranges for numbers likecase 0..<10:, orcase 'a'..='z':, or that there is nodefault:, but instead it usescase:. I think these would be worthwhile additions.Have a nice day!
Thanks for the nice words and for the feedback!
I’ll add those things to my proposal list for things to add. Those specific things may indeed be unknown to people coming from other languages.
looks interesting but 20 is too much for a book for those like me who don't live in US or EU
Really well-written book. While deciding which language to use for my pet project, I was couldn't decide between Odin and Zig. Both languages currently lack some of the standard library features I would prefer. While their syntax and philosophy are quite different, I didn’t have a strong preference for one over the other. So, I decided to base my choice on the quality of learning materials. This book ultimately tipped the scales in favor of Odin.
I couldn't find info on using multithreading in Odin in the chapter list - does the book include info on how to handle threads?
Hi, it does not have a lot on multi-threading. There’s only a single example on how to start a thread. The focus is more on understanding the core features of the language. There’s an especially strong focus on memory management.
Fair enough! Just wanted to check before I hit the buy button. :) Do you know of any good resources for diving deeper into multithreading in Odin?
I think this is the first odin book, I have seen, unless maybe you check the docs.
There aren’t any great multi-threading guides yet! I just made a super basic threading example: https://github.com/odin-lang/examples/blob/master/thread/basics/thread_basics.odin
However, I’d like to make something bigger too, perhaps something similar to a job system or such.
One thing you can look at is Jakub’s “jobs” repository: https://github.com/jakubtomsu/jobs
Awesome, thanks! Will keep those in my back pocket.
Coming from managed langs (mostly JS runtimes), threads are still something of a new concept, so just need a bit of a runway to get me going.
Hello :wave,
I am considering buying the book, but before I do it, I have the following question:
I have noticed that periodically you update the content of the book (based on readers' feedback, new ideas which pop up in your mind, when it comes to what in your opinion would be useful for people to know etc.). Do I need to pay 20$ (+ VAT etc.) for every new version that gets published? Should the answer to the previous question be "No, you do not have to pay additional money" - then how do I get access to the latest up to date version of the book (in the "Development log" section of this web page)?
I've never used itch.io before, which is why I am unfamiliar with how things work.
P.S. - considering all the positive feedback you are receiving - it feels like you'd benefit significantly from promoting your content more actively :) I only found the book by pure luck.
Kind regards,
Hi, you get the updates for free. Only if I did a major overhaul (like a proper second edition) would I perhaps charge extra for it. But for these smaller updates, no, they are free!
Yeah, the feedback is great. But honestly, the book is selling quite well. I have been promoting it a lot! But thanks for for the concern
Have a nice day!
Dunno if something can be done about this, but itch.io charged 25,5% for VAT, when the VAT for books in Finland is 14%.
Not asking for a refund or anything, but some other potential buyers may care more about this.
Waiting eagerly to read the book, your YouTube videos are a great source of inspiration!
Update: You can now also buy the book through Payhip. They support calculating book VAT properly: https://payhip.com/b/tnwvO
Original comment: Thanks for buying!
Sorry about the VAT. It’s an itch issue, they don’t have the correct setup to do the proper VAT for books in EU. It’s unfortunately like this for all books sold on Itch. They are aware of the problem, but no fix seems to be in sight.
Only way to fix it seems to be adding another market place that supports the correct VAT (and also supports selling a HTML book). I’ll look into it at some point, but it will take some time.
Have a nice day!
Been working through the book slowly. Overall this has been really good so far.
Some feedback from someone who hasn’t done a ton with Pointers.
The chapter on pointers talks a lot about what pointers/addressables do, but doesn’t really discuss why we need pointers. Maybe it’s because Odin isn’t object oriented, likely because of the immutability aspect.
I have an idea, on this, but I feel like having examples on what not using pointers would do would be helpful. Most of the languages I’ve used so far, haven’t really been ones that used a lot of pointers.
Like, I’m pretty sure if I’m not using pointers, I’m essentially creating new data at new memory locations and losing the old memory or I’m running into errors.
I thought the addressables section may touch on this more, but not in as a direct way as I was hoping.
From the Addressable section, this confused me as well: “In which case element_pointer would not point to the tenth element of array. Instead, it would point to an in-between value.”
I think this is where emphasizing about getting a copy would be better. I had no idea what you meant by in-between value. I ended up doing some searching and confirmed my theory that element_pointer would contain a pointer to a copy of the data that would have been in the array.
I can see someone who isn’t as far along the path being very confused. I kinda feel like I understand, but will definitely have to do some simple experiments to confirm I’m understanding what I suspect.
Thank you for reading and for the feedback Michael!
I’ve added your comments to my TODO and will look at them when I make an update for the book.
Like you say, perhaps the chapters needs more examples. For now, just note that in the subsequent chapters, I will touch upon different cases when pointers are useful and when they should be avoided. Hopefully as your read on, more and more questions will be answered.
Also very much enjoying the book so far - just want to +1 this - I found this comment whilst googling to satisfy my confusion around the "in-between value" part. I think this might be an area of confusion for people without a robust understanding of pointers. Perhaps a few diagrams in this areas would help explain the difference between what is happening in these scenarios:
element := array[10]
element_pointer := &element
element_pointer2:= &array[10]
I've also been experimenting and think it's connected with copying, but haven't fully grokked it. I'm sure I will have figured this out soon and forgotten why I was confused, but just wanted to note it in case there is a way to make this clearer - or perhaps the confusion is a necessary part of learning...
Thank you!
In version 1.5, which I uploaded yesterday, I have changed these formulations a bit. Based on the feedback I got, I try to use the word “copy” instead of “in-between value”. In hindsight that is an easier way to talk about it. Please check it out and let me know if it was an improvement or not.
But like you say, perhaps a diagram would be good.
Have a nice day!
You want more Odin? Then this book is a must :)
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
otherwise.
3) In chapter 18.4
should probably be
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
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
may lead to the
error.
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).
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.
Thoroughly enjoying the book so far! Very approachable and informative.
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!
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.
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.
Read three pages and zero cats. Disappointed.Well-written, easy to read and even to understand (sometimes). I like it a lot.
Thanks 😻
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.
Thank you! Happy that you like it
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!
Thank you 💖
Such a well-written and beautifully-designed book on Odin! Thank you for your hard work!
Thanks for the kind words!