Understanding visibility, immutability, and package management

  1. You can make a whole file private with #+private before package declaration. https://odin-lang.org/docs/overview/#private. As a side note, I’ve found that the need for private procedures is mostly infrequent. I will define procedures I wish to keep internal inside exposed procedures when needed and where possible. If it’s a procedure I use more than once in other procedures and needs to stay internal, then it gets defined on it’s own, but with @(private) or @(private="file").

  2. Immutability becomes extremely clear in a relatively short time through usage. For the most part, when passing to procedures, all variables are immutable. Pointers allow for mutability. There are some exceptions. Karl Zylinski’s book is a fantastic entry point and explains mutability quite well in the early chapters. https://odinbook.com/. On the subject of closures, there’s this thread: how-to-get-out-of-the-closure-mindset, where charles_23195 makes a prescient comment: “If you have no idea what state your program will be in when it gets somewhere, then you probably need to rethink your program.”

  3. After using Odin a while, it’s very clear to me why no package manager or tools are needed. One of the things that helped me get to this point was embracing the notion that by-and-large all the documentation you need is in the source files, vendor or otherwise. The examples found here help https://github.com/odin-lang/examples. Usage of the language got me the rest of the way. If you’ve used other languages, this should come quickly.

Others here in the forums could probably give more concise technical answers. My answers are purely anecdotal.

If you are looking for a deeper understanding of the whys, etc, there’s this: https://www.gingerbill.org/article/ and this: https://odin-lang.org/news/

Update - A few other useful links:
https://zylinski.se/posts/introduction-to-odin/
https://zylinski.se/posts/dynamic-arrays-and-arenas/
https://www.youtube.com/@karl_zylinski
Generic Odin procedures: Parametric polymorphism

1 Like