4 ms·
I code both. > explicit over implicit Go was the first language I used that broke an explicit check for nil/null/None. I had to cast my nil to a different ki
by bb88 3y ago
I code both.
> explicit over implicit
Go was the first language I used that broke an explicit check for nil/null/None. I had to cast my nil to a different kind of nil in order for the program to run correctly.
C/Python/Java/C++ didn't have this issue. Null was always null in each of these languages.
Further, go panics in surprising ways sometimes. A library developer might decide to panic and cause your program to crash, when that library was only used in your program for optional behavior.
- randomdata 3y ago> Go was the first language I used that broke an explicit check for nil/null/None. I had to cast my nil to a different kind of nil in order for the program to run correctly. Maybe I'm reading it wrong, but it reads that you have been accustomed to implicit nil type conversions in other languages and that tripped you up when Go required you to be explicit. It seems Go is the explicit one here. > A library developer might decide to panic and cause your program to crash Go is abundantly clear that panics should never cross package boundaries except in exceptional circumstances. And those exceptions should crash your program. An exception means that the programmer made a mistake and the program is now invalid. There is nothing left to do but crash. It is technically true that a library developer can violate that guidance, but it is strongly encouraged for them to not. The parent did indicate that sometimes the explicitness is only encouraged, not enforced. Not that Go is some kind of explicitness panacea. It has its own fair share of implicitness. But I'm not sure these two are representative.
- deleted 3y ago[deleted]
- lelanthran 3y ago> Go was the first language I used that broke an explicit check for nil/null/None. I had to cast my nil to a different kind of nil in order for the program to run correctly. C/Python/Java/C++ didn't have this issue. Null was always null in each of these languages. I think it makes sense - a `nonexistent<ThisType>` is different from a `nonexistent<ThatType>`. In C, Java, C#, C++ and other languages, null/nil is a value. In Go null/nil has a type. Now that I've used Go a little, I actually miss having error messages for certain things, and comparing a `nonexistent<ThatType>` to a `nonexistent<ThisType>` is actually a logic error in my code that I want to be warned about.