Readit News logoReadit News
Gadiguibou commented on Go: What we got right, what we got wrong   commandcenter.blogspot.co... · Posted by u/veqq
campbel · 2 years ago
I like zero values because when I create a struct I can know for certain accessing a non pointer won't crash the program. That's a pretty good value add. My type system also knows this, so I don't have to worry about asserting non nil values or adding needless if value == nil checks.
Gadiguibou · 2 years ago
I understand that you like zero values as an alternative to initialization of objects as nil like Java does it. I think the parent comment explains pretty well what the issues with this approach are. Taking Rust as an example (because that's what I'm most familiar with), it's possible to simply enforce that variables are initialized explicitly or that safe constructors are provided, avoiding all the nil safety issues.
Gadiguibou commented on Push ifs up and fors down   matklad.github.io/2023/11... · Posted by u/celeritascelery
RHSeeger · 2 years ago
> It's a shame that so many see changeability and performance in opposition with each other. I've yet to find compelling evidence that such is the case.

In the article, when I saw this

> For f, it’s much easier to notice a dead branch than for a combination of g and h!

My first thought was "yes, but now if anyone _else_ calls h or g, the checks never happen (because they live in f). I'd much rather have h and g check what _they_ need in order to run correctly. That way, if another call to one of them is added, we no longer need to rely on _that_ call correctly checking the conditions. Plus it avoids duplication.

But... and this goes back to the original point from your post... this is a matter of code being correct over time; changeability. If you're worried about performance, then having the same check in 2 different places is a problem. If you're not (less) worried, then having the code less likely to break later as changes are made is helpful.

Gadiguibou · 2 years ago
You can also often encode those checks in the type system like in the Option example near the start of the article.
Gadiguibou commented on     · Posted by u/Gadiguibou
Gadiguibou · 2 years ago
See this for more context: https://github.com/HigherOrderCO/hvm

u/Gadiguibou

KarmaCake day1916November 8, 2020View Original