Hacker News new | ask | show | jobs
by throwawaymaths 1178 days ago
I work in a language where all fields are public and it is indispensable in debugging things. You DO NOT want your datatypes hiding things under the hood.

At best, if zig does want to make fields private, they should still be visible, but the compiler should disallow writing to them.

1 comments

I believe you, but I haven't encountered anything like this in my work in a higher-level language, and this is my first push into manual memory management since I studied C in college many years ago.

Can you offer some examples of times when it has been indispensable, so that I can understand when this is useful?

don't remember any off the top of my head. I use elixir, I do often dive into the data structures with IO.inspect(..., structs: false) which exposes all of the "hidden" fields. Enough so that I know how to do this without having to look it up.

I suppose you could also use the debugger, but I value my time.