ZII cannot be used with all data types. As a simple example consider a pointer which is never supposed to be null - which is many if not most pointers. Zero initializing such a pointer gives it the wrong value.
-
-
Replying to @andy_kelley @Lokathor and
"Pointer that can't be null" is not a data type, it's a data type plus a condition. ZII obviously cannot be "used with all conditions" because the definition of ZII is that it is telling you that zero is the default state of everything. But that's the point of it!
2 replies 0 retweets 6 likes -
Replying to @cmuratori @andy_kelley and
The point of ZII is that it is the right condition to use, because app memory is always zero on allocation, and thus by definition if you structure the program this way, you have no overhead while still having initialization determinism.
1 reply 0 retweets 2 likes -
Replying to @cmuratori @Lokathor and
(1) not true for embedded and other OS's (2) the hot path is going to be using recycled memory from an allocator in which case the memory is undefined, not 0
1 reply 0 retweets 2 likes -
Replying to @andy_kelley @cmuratori and
I think the point of disagreement with the two philosophies is fundamentally what the purpose of a type system is for and what you think it can possibly do.
1 reply 0 retweets 1 like -
Replying to @TheGingerBill @andy_kelley and
For you
@andy_kelley, you want to ensure safety through the type system as much as possible. Which means being explicit on an individual unit. The reason I said "make the zero value useful" is to emphasize the aspect of values rather than types.1 reply 0 retweets 1 like -
Replying to @TheGingerBill @andy_kelley and
The main aspect of what
@cmuratori calls ZII are the following (I might be wrong): It is how [modern] computers work the most efficiently (zero memory is the default), and thus not having to initialize explicitly manually is a lot faster.3 replies 0 retweets 3 likes -
Replying to @TheGingerBill @andy_kelley and
If the memory is coming from your own allocator, it's not going to be zeroed, at least not for free.
1 reply 0 retweets 1 like -
Replying to @croloris @andy_kelley and
Why not? You're assuming a lot about my own allocator. Which is faster? Zeroing a block of memory or initializing each element individually?
1 reply 0 retweets 1 like -
Replying to @TheGingerBill @andy_kelley and
It depends a lot on the use-case I guess. For ZII to work you do have to zero everything, but you don't necessarily have to initialize *each* element of a struct. If you only need 1 or 2 fields for a given code path, the rest can be left untouched.
2 replies 0 retweets 1 like
No you can't? CPUs can't "touch" less than 64 bytes at a time. Unless you are not touching entire 64-byte blocks of the struct, this is strictly a lose, because zeroing is never slower than initializing, and may be faster.
-
-
Replying to @cmuratori @TheGingerBill and
The point was about the cost of coming up with individual values. My point is just that ZII doesn't seem to me the strictly better way of doing things as it's being purported in this thread. Anyway, I'm out, sorry for the interruption.
0 replies 0 retweets 0 likesThanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.