6 ms·
Go is simple. People like complexity. So the write abstractions to feel better about themselves.
by gethly 5mo ago
Go is simple. People like complexity. So the write abstractions to feel better about themselves.
- phplovesong 5mo agoComplexity does not equal language features. Sometimes simple is good, but sometimes simple just simply means more bugs in your code. As a prime example, Go unwillingness to add even the most simple enum kind of type. Having enums (ADTs) with exhaustive pattern matching is NOT complex in any sense or form. It just takes away so, so many bugs you would normally see in production code. One other low hanging fruit is the fact that zero values are in 90% of all cases not what the dev intended. Sure, the mantra goes "make them useful" but thats hard. How to you know if a value (int) was zero initialised, or if the user did in fact input zero as value. No matter, you will need to validate every one of these "zero values" if you want some sort of robustness.
- flossly 5mo agoAdding `null` to C was very simple to add. It added a lot of complexity that the language designer did not see coming (hence the billion dollar mistake he made on that).
- phplovesong 5mo ago`NULL` was originally added to ALGOL back in 1965. C was not even a thing back then. It was obviously a bad choice to port NULL to C, one that ADTs would have perfectly modeled, without the billion dollar cost. In fact C was built sometime around the early 70s, and at the same time the first MLs where also being developed. One added null, while the other added a better mechanism for "nothingness". Bottom line is you cant compare "adding null" and adding a feature that is over 50 years old, one that is battle-tested thru generations, and still holds up. Solid maths does no suffer bitrot.
- flossly 5mo agoALGOL indeed. I stand corrected. https://www.infoq.com/presentations/Null-References-The-Billion-Dollar-Mistake-Tony-Hoare/ https://www.infoq.com/presentations/Null-References-The-Bill...
- 9rx 5mo ago> Go unwillingness to add even the most simple enum kind of type. Go has enums, under the iota keyword. But I imagine you are really thinking of sum types. Technically Go has those too, but must always have a nil case, which violates what one really wants out of sum types in practice. Trouble is that nobody has figured out how to implement sum types without a nil/zero case. That is why you haven't seen a more well-rounded construct for the feature yet. This is not an unwillingness from the Go team, it is more of a lack of expertise. Granted, it is an unwillingness from those like yourself who do have the expertise. What stops you from contributing? > It just takes away so, so many bugs you would normally see in production code. What bugs do you imagine are making it to production? Each pattern matched case has a behaviour that needs to be tested anyway, so if you missed a case your tests are going to blow up. The construct is useful enough that you don't need to oversell it on imagined hypotheticals.
- phplovesong 5mo agoFor example if a have a type with 3 constuctors, and later one new dev adds one more case and forgets to handle it in every call site. No test will catch this 100%, but something like ocaml will just by compiling the program. I know fo is not (i dont want it to be) like ocaml, bit any modern language should have some of the basic safety features baked in.
- deleted 5mo ago[deleted]
- 9rx 5mo ago> later one new dev adds one more case and forgets to handle it in every call site Okay, so you are dreaming of a situation where you allow a new developer who doesn't know anything about how to engineer software unfettered access to your codebase and he goes in and starts mucking about to where he ends up doing things that no sensible human would ever consider acceptable? I accept you like to live dangerously and have no real care for the product you are building. But, still, you've only covered a limited subset of all the similar things this new developer who doesn't know the first thing about building software can make a mess of. Ocaml just isn't going to cut it. To reach the full gamut you need, say, a proper dependent type system. But are you really going to throw all your Ocaml code away and start writing Rocq just to deal with this guy you should have never let touch your code in the first place? Probably not. So, what now? Your only practical option is to fire him and find someone who actually understands how to write software. And at that point your tests will catch such forgetfulness just fine. > No test will catch this 100% Testing cannot exhaust all cases where the search space is infinite as that requires infinite time to evaluate. In this case, you have exactly 4 states. That is evaluated on the order of nanoseconds. If your tests are not capturing every one of those four permutations, it seems clear that you need to stop letting any random Joe who has never done more than some quick vibe coding anywhere near your code. These are solved problems. And, hell, even if you did switch to a language with a proper type system, like Rocq, so you could mathematically guarantee all aspects of your program, the shitty programmer will still fail to write theorems that are free of holes. So don't think that even lets you of the hook in hiring those who live by the vibes. There is simply no escaping the need for solid engineering. When you have that, exhaustiveness checking still remains a useful tool, but you aren't going to forget something and ship broken code to production if you don't have it. This isn't a realistic scenario outside of the contrived. Again, The construct is useful enough that you don't need to oversell it on imagined hypotheticals.