5 ms·
Wait, Go doesn't have enums? Why not?
by lionkor 2y ago
Wait, Go doesn't have enums? Why not?
- HideousKojima 2y ago>The key point here is our programmers are Googlers, they’re not researchers. They’re typically, fairly young, fresh out of school, probably learned Java, maybe learned C or C++, probably learned Python. They’re not capable of understanding a brilliant language but we want to use them to build good software. So, the language that we give them has to be easy for them to understand and easy to adopt. - Rob Pike
- lionkor 2y agoSo they made it easy to have data races in a language all about concurrency, bravo. Not buying it.
- ad_hockey 2y agoIt's possible to have data races if you ignore the language conventions[1]. But even then, Go has provided an effective data race detection tool since 1.1: https://go.dev/blog/race-detector https://go.dev/blog/race-detector I've been using Go on a large codebase for a number of years, and I haven't found data races to be a problem in practice. [1] https://go.dev/doc/effective_go#sharing https://go.dev/doc/effective_go#sharing
- lionkor 2y agoThat's fantastic, good job! "Just be good enough at your job" is why C++ is fully concurrency- and memory safe, too. But, you know, its not, that's not how juniors use it, and boy do they write a lot of codebases I end up maintaining.
- tyre 2y agosorry is the point here that enums are too complicated to understand?
- pjmlp 2y agoApparently, like most modern language features in the last 50 years or so.
- nsingh2 2y agoGo seems like such a strange language to me. I like its simple syntax, but it's strange that they compromised and added generics to the language but balk at basic things like sum types, pattern matching and type safe enums. Their simplicity design philosophy seems a bit incoherent.
- lionkor 2y agoThey might be trying to do another C, that is so simple that it will be ubiquitous? They're failing to understand that C would never take off it invented today. Go is nowhere on my list of languages I would use - there is simply nothing it's great at. Serialization/deserialization? Rust. Multithreading? Rust. Low level high performance stuff? C, Zig. Quick scripts? Bash, python, JavaScript, Rust. Really fast concurrency? C++ or Rust. Web servers and services? Either nodejs, something static on an existing webserver, or rust for backends. I completely fail to see where Go excels. Large, statically linked binaries that aren't even concurrency safe...? Really? No enums? Odd syntax (I like Rust, C++ and Haskell, I find Go's syntax odd still). Like so many Google products, it solves a problem that nobody I know has. And I guess they can afford concurrency bugs, who cares, its only a language primarily for concurrency.
- tacitusarc 2y agoHave you used Go? Most of your criticisms are, in my experience, incorrect. But ultimately there are tradeoffs, and Go seems to be a divisive language. In my experience, Go excels at pushing you towards solving the problem rather than yak shaving. And in my opinion that is worth it’s relatively minor frustrations.
- pjmlp 2y agoMany of us that critise Go, no only have been around the ecosystem since the pre-1.0 days, we also happen to have a broad experience in programming languages since the days writing complete applications in Assembly was pretty much daily business.
- ironmagma 2y ago
- o11c 2y agoTo be fair, enums represent a different and incompatible concept in every language I know. It's possible to support everybody's needs in a single language, but I'm not aware of any language that has done it yet.
- bsaul 2y ago"enums represent a different and incompatible concept in every language I know." Enums has always felt very natural in every modern languages i've tried (swift and rust, for example), even with associated values. The underlying "sum type" concept also is very intuitive, and seems very complementary to structs for example. Can you expand a bit on what you mean ?
- __s 2y agoSum types are cool. Many languages implement enums which are not tagged union sum types (even when language has rich sum types) https://en.cppreference.com/w/c/language/enum https://en.cppreference.com/w/c/language/enum https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/enums https://learn.microsoft.com/en-us/dotnet/csharp/language-ref... https://docs.python.org/3/library/enum.html https://docs.python.org/3/library/enum.html https://api.rubyonrails.org/v5.2.4.5/classes/ActiveRecord/Enum.html https://api.rubyonrails.org/v5.2.4.5/classes/ActiveRecord/En... https://sorbet.org/docs/tenum https://sorbet.org/docs/tenum https://docs.oracle.com/javase/tutorial/java/javaOO/enum.html https://docs.oracle.com/javase/tutorial/java/javaOO/enum.htm... https://dart.dev/language/enums https://dart.dev/language/enums https://www.postgresql.org/docs/current/datatype-enum.html https://www.postgresql.org/docs/current/datatype-enum.html https://dev.mysql.com/doc/refman/8.4/en/enum.html https://dev.mysql.com/doc/refman/8.4/en/enum.html https://zig.guide/language-basics/enums https://zig.guide/language-basics/enums https://www.erlang.org/eeps/eep-0013 https://www.erlang.org/eeps/eep-0013 https://hackage.haskell.org/package/planet-mitchell-0.1.0/docs/Enum.html https://hackage.haskell.org/package/planet-mitchell-0.1.0/do... https://www.ibm.com/docs/en/openxl-fortran-aix/17.1.1?topic=attributes-enumend-enum-fortran-2003 https://www.ibm.com/docs/en/openxl-fortran-aix/17.1.1?topic=...
- willtemperley 2y ago
- ikiris 2y agoit kind of does and doesn't
- saghm 2y agoI'm not sure what you mean by this. It definitely doesn't have enums, not even in the C sense of "type alias for integers with names for specific constant values. Yes, it has iota, but that's orthogonal to enums; you could use it to define bitmasks, for example. While you can certainly use it in combination with a type alias to make something resembling an enum, I'd argue that's still not actually "having enums"; you could do the same thing in C with typedefs and constants even if it didn't have enums.
- pjmlp 2y agoI hardly consider the iota / const dance meaningful, it is like telling macro assemblers kind of have. Granted, Niklaus Wirth removed them from Oberon-07, then again even as big fan of his work, that isn't the Oberon version I prefer, rather Active Oberon.