4 ms·
After reading a few chapters and skimming the rest, this looks just fine. It's about the right level for somebody picking up a new language (when the language g
by hansvm 2y ago
After reading a few chapters and skimming the rest, this looks just fine. It's about the right level for somebody picking up a new language (when the language gets much more popular I'd like to see something similar targeting new programmers), and the writing fits together nicely. There are a lot of small things that aren't quite right though, and some of those I'm not sure are even appropriate simplifications pedagogically. A smattering of examples:
> Every object (being constant or variable) that you declare in Zig must be used in some way.
This is true for eagerly evaluated code (function bodies) and false for lazily evaluated code (struct definitions). That latter thing already trips people up because you can have full-on compiler errors defined somewhere and never know because they're never used (depending on your build mode, there will be some root artifacts -- tests for test builds, main for executable builds, export functions for library builds, transitively visible public members for modules -- and only code transitively referenced by those artifacts is compiled). Explicitly stating the opposite is going to confuse some beginners.
> How Object-Oriented programming can be done in Zig through struct declarations
That example is only very lightly object oriented. It doesn't cover runtime polymorphism or inheritance (both possible and occasionally useful, like in the std Allocator definition) or compiler-checked subtyping (not really possible in any useful manner). It's data classes with member functions rather than what a lot of people call OOP. I think the thing actually being taught is probably at the right level for the book, but it should be presented as what it is, _perhaps_ mentioning those other concepts.
> In order to debug your program through a debugger, you must compile your source code in Debug mode
This isn't really true either, and some things are very hard to debug when you're not in a release mode. You just need to ensure the appropriate debug symbols are included, and you can toggle those build options in any build mode.