6 ms·
imho, go, afaik, is designed to cleanly express concurrency primitives in the context of a single system, and doesn't do 'fault-tolerance' in the erlang sense o
by signa11 13y ago
imho, go, afaik, is designed to cleanly express concurrency primitives in the context of a single system, and doesn't do 'fault-tolerance' in the erlang sense of 'you need >1 machine to be fault-tolerant'. with that lens, it is clear that the optimal way to do concurrency is with shared state, but that gets exported out via channels and go-routines etc.
also, can someone please explain the issues around 'nil' ? i fail to appreciate author's concern about those...
- steveklabnik 13y ago> also, can someone please explain the issues around 'nil' ? i fail to appreciate author's concern about those... Take it from the guy who _invented_ nil: http://qconlondon.com/london-2009/presentation/Null+References:+The+Billion+Dollar+Mistake http://qconlondon.com/london-2009/presentation/Null+Referenc...
- stock_toaster 13y agoIt should be noted that nil in Go is not quite[1] the same as null in C though. For example, if a method defines the return type as a value (say, a string), you cannot validly return a nil (compile error). [1]: http://blog.denevell.org/golang-null-nil.html
- masklinn 13y agoEr… similar code in C: struct foo bar () { return NULL; } is a compilation error as well… (granted it's not an error for strings because C has no strings per-se)
- stock_toaster 13y ago> (granted it's not an error for strings because C has no strings per-se) That was kind of the entire point though.
- masklinn 13y agoSay what? Your statement is that Go's nil is different than C's null. As demonstrated, it is not, C's null is for pointers and Go's nil is also for pointers. The difference is that Go has a value-type string and C does not, but that is only a parenthesised aside in your original comment (as an example of Go value types), nowhere near "the point" let alone "the entire point".
- deleted 13y ago[deleted]
- rdtsc 13y ago> also, can someone please explain the issues around 'nil' ? i fail to appreciate author's concern about those.. The question can be thought of as two parts: 1) Whether nil should be a base value for objects. If something points to type t, should that be allowed to be nil. It is obvious that it should if coming from C/C++/Python, not so obvious if coming from Haskell for example. 2) Should the lack of objects, or should error conditions be represented by nil. Say lack of a an object in a map is indicated by returning nil. Should it throw an an exception instead? Now, go doesn't have exceptions so it needs something like this perhaps. Or maybe panic should happen. To expand on 1). If you are coming from Haskell (or any strong typed language) the thinking is, you are already paying the price for static checking, strong types, compilation step etc. It would be nice to have explicit non-nil types. You can say this function accepts a reference to this object and this cannot be nil. During compile time the typechecker/compiler will do a more rigorous analysis based on that, and barf out an error then instead of during production. Like in Haskell you can explicitly say something may be nil (Nothing): data Maybe a = Nothing | Just a I don't personally lean one way or another here. I just don't have a strong opinion either way. I understand the trade-off. But this is how I interpret what the author means by his issue with 'nil'. Hopefully this helps.
- signa11 13y ago> Hopefully this helps. yes, it does. thank you for your kind explanation.
- demallien 13y agoFor 1), modern C++ style generally frowns upon NULL pointers, preferring to use references, which are guaranteed to be non-NULL.
- dbaupp 13y agoThere is no such guarantee, a NULL reference can be created although it does require a little more effort than creating a null pointer. However, null is just a special case of "invalid" pointer (e.g. point to freed memory), and it's very easy to create an invalid reference, e.g. take a reference into a vector and then push a pile more elements onto it, causing the vector to reallocate and move in memory, invalidating the reference.