4 ms·
Yeah noticed that too. Was just talking to a co-worker the other day about how static types are sometimes, and they were saying how any sufficiently large code
by rdtsc 13y ago
Yeah noticed that too. Was just talking to a co-worker the other day about how static types are sometimes, and they were saying how any sufficiently large code base written by average developers will have more and more things like that (void*) casts and so on. So then type safety kind of goes out of the window.
For languages like Go you look at static types from 2 sides - 1) it is there for safety and reliability (so in this case if it couldn't be circumvented it would that way) or 2) it is there to speed things up. Then Go is like a faster Python but casting things left and right erasing types will make the code blow up.
So taking the second approach, I don't see it as terribly. But maybe someone coming from Java or Haskell might be really offended by that line of code.
- NateDad 13y agoA minor nitpick - it's still type safe in Go, you can check the type of what's in interface{} and convert the value to that type. You'll never have to worry about getting complete garbage out. However, it's not pretty, and the boxing to and from interface{} is not free.