News for hackers. Stuff that matters.
Re:Goenums: Type Safe Enum Generator for Go by lionkor on Saturday April 26, 2025 @05:54PM (#43807547)
Wait, Go doesn't have enums? Why not?
Re:Goenums: Type Safe Enum Generator for Go by o11c on Saturday April 26, 2025 @06:41PM (#43807871)
To 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.

Re:Goenums: Type Safe Enum Generator for Go by bsaul on Saturday April 26, 2025 @06:45PM (#43807907)
"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 ?

Re:Goenums: Type Safe Enum Generator for Go by willtemperley on Saturday April 26, 2025 @08:39PM (#43808486)
This. I find Swift and Rust enums, which are indeed very similar, to be incredibly good at modelling the real world. For example the standard geospatial vector types which are heterogeneous and even recursive in the case of GeometryCollections can be modelled and operated upon very cleanly.
Re:Goenums: Type Safe Enum Generator for Go by za3faran on Saturday April 26, 2025 @09:52PM (#43808850)
Have you tried them in Java?
Re:Goenums: Type Safe Enum Generator for Go by sebazzz on Sunday April 27, 2025 @07:59AM (#43811309)
Java enums are more or less a “multiton” (as in singleton - for each value each)
Re:Goenums: Type Safe Enum Generator for Go by vips7L on Sunday April 27, 2025 @09:23AM (#43811739)
And if you want rust style enums in Java you can use sealed types.
Re:Goenums: Type Safe Enum Generator for Go by protolyticmind on Sunday April 27, 2025 @01:28AM (#43809649)
Rust has IMHO the best implementation of enums ... Mixed with match it is super powerful
Re:Goenums: Type Safe Enum Generator for Go by aldanor on Sunday April 27, 2025 @07:52AM (#43811268)
Don't forget, Rust was first implemented in Ocaml, You can guess where those best enums come from.
Re:Goenums: Type Safe Enum Generator for Go by sureglymop on Sunday April 27, 2025 @02:15PM (#43813970)
Kotlins enum classes are quite similar, probably even inspired by rust or prior ML languages. And there's `when` as an alternative to match.

Kotlins syntax is in general a bit underrated imo and I disagree that Java is up to par.

Re:Goenums: Type Safe Enum Generator for Go by nsingh2 on Saturday April 26, 2025 @06:36PM (#43807836)
Go 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.
Re:Goenums: Type Safe Enum Generator for Go by lionkor on Saturday April 26, 2025 @07:06PM (#43808069)
They 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.

Re:Goenums: Type Safe Enum Generator for Go by ironmagma on Saturday April 26, 2025 @08:15PM (#43808373)
Compilation time is fast, and it’s debuggable. Typescript would be the main competitor in my mind, but compilation with TS is slow and you have no parallelism without native extensions.
Re:Goenums: Type Safe Enum Generator for Go by niux on Sunday April 27, 2025 @02:09PM (#43813924)
Not anymore, since the Typescript compiler has been re-written... in Go.
Re:Goenums: Type Safe Enum Generator for Go by ironmagma on Sunday April 27, 2025 @07:36PM (#43816070)
That’s still a work in progress. And is it really faster than Go compilation? Just because it’s written in Go doesn’t guarantee that.
Re:Goenums: Type Safe Enum Generator for Go by tacitusarc on Saturday April 26, 2025 @07:19PM (#43808146)
Have 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.

Re:Goenums: Type Safe Enum Generator for Go by pjmlp on Sunday April 27, 2025 @04:52AM (#43810452)
Many 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.
Re:Goenums: Type Safe Enum Generator for Go by sambeau on Saturday April 26, 2025 @08:25PM (#43808413)
Go is a tiny language. I can easily hold it all in my head. I don't think I can say that about any other language I've used. Not even C.
Re:Goenums: Type Safe Enum Generator for Go by homebrewer on Saturday April 26, 2025 @08:50PM (#43808524)
It is a passable replacement for CLI utilities (so basically Python or bash) thanks to the rich ecosystem, easy cross-compilation, and static linking, which makes deploying the result easy while also avoiding the horrible mess and pain of handling Python dependencies, or remembering dozens of tiny incompatibilities between various flavors of UNIX utilities.

Unlike Rust, one is not required to have three digit IQ to use the language, so that's why I've been using it where previously I would have resorted to Python (and then either copy venvs around, or write packages for my packages to ship dependencies of my dependencies).

I too fail to see why would anybody use it for anything else, especially compilers or more complicated server stuff where you really benefit from having a proper type system, but people do, so I must be missing something...

Re:Goenums: Type Safe Enum Generator for Go by za3faran on Saturday April 26, 2025 @09:58PM (#43808874)
It's a better Python, that's where I see most of the real world use cases. After dealing with Python for a while now, I would take golang any day of the week lol. But for backend systems, there are far superior alternatives.
Re:Goenums: Type Safe Enum Generator for Go by pjmlp on Sunday April 27, 2025 @04:54AM (#43810459)
The only thing it does better than Python is being a compiled language.
Re:Goenums: Type Safe Enum Generator for Go by flkenosad on Saturday April 26, 2025 @10:47PM (#43809063)
It's great for large software projects that need tons of random contributers. For example, Gitea.
Re:Goenums: Type Safe Enum Generator for Go by pjmlp on Sunday April 27, 2025 @02:10AM (#43809796)
C is only simple in theory.
Re:Goenums: Type Safe Enum Generator for Go by Yasuraka on Sunday April 27, 2025 @02:46AM (#43809924)
> Web servers and services?

That's it, mostly. CRUD is also a huge part of the industry, unlike "Serialization/deserialization", which are a means to an end.

> Either nodejs, something static on an existing webserver, or rust for backends.

Horrendous choices, I daresay.

Why do people use Java and C# ?

Re:Goenums: Type Safe Enum Generator for Go by zarldev on Sunday April 27, 2025 @06:39AM (#43810893)
>That's it mostly...

Whole kubernetes, docker, traefik and many other cloud native tools are written in go.

Re:Goenums: Type Safe Enum Generator for Go by Yasuraka on Sunday April 27, 2025 @05:08PM (#43815149)
They are my daily bread and I sloppily lumped them in with "web [...] services", but in hindsight they ought to be a separate category - fundamentally about a different layer,infrastructure, and might not even be networked.
Re:Goenums: Type Safe Enum Generator for Go by pjmlp on Monday April 28, 2025 @10:35AM (#43821974)
Many tools on DevOps ecosystem are now going through the RIIR phenomenon, and I bet, had Rust 1.0 been available when Kubernetes decided to migrate away from Java, after Go heads joined the team (see FOSDEM talk on the matter), or Docker moving away from Python, most of those tools would have been written in Rust instead.
Re:Goenums: Type Safe Enum Generator for Go by Yasuraka on Monday April 28, 2025 @11:17AM (#43822438)
> most of those tools would have been written in Rust

I seriously doubt it for the same reason that Google, with all of its expertise and tooling for it, didn't choose C++, twice.

Re:Goenums: Type Safe Enum Generator for Go by pjmlp on Monday April 28, 2025 @12:06PM (#43823008)
You may doubt it, I keep my certainty, given how much Go is being used at Google, versus Java, Kotlin, C++ and Rust.
Re:Goenums: Type Safe Enum Generator for Go by Yasuraka on Tuesday April 29, 2025 @01:44AM (#43829031)
The Rust of today wouldn't be chosen over the Go of a decade ago, it is fundamentally a bad fit, for similar reasons that the already mature C++ wasn't. Java (similar to C#) would've been viable mainly due to maturity and ecosystem effects, Kotlin/Native might be a contender in another half decade, sooner if the team were to shift priorities.

I say this not just for Kubernetes etc., but greenfield projects today as well.

Re:Goenums: Type Safe Enum Generator for Go by pjmlp on Tuesday April 29, 2025 @08:56AM (#43831949)
Meanwhile on the field,

https://deislabs.io/posts/still-rusting-one-year-later/

I gather you are aware of Deis Labs history, Microsoft acquisition and such, do you want other CNCF companies that have pivoted into Rust?

Re:Goenums: Type Safe Enum Generator for Go by Yasuraka on Tuesday April 29, 2025 @12:50PM (#43835077)
More like, an attempt in the field from 2 years ago

> [Warning] This project is currently not actively maintained.

But there is a library by them to build containerd shims with which is maintained: https://github.com/containerd/runwasi

Let's just entertain the idea and pretend that this is a notable project and that one would count it as DevOps tooling. Here are the top 10 across the CNCF in terms of size, courtesy of GitHub's API:

    C++: 3195829832
    Java: 2908175049
    Go: 2005598094
    C: 1225503783
    Python: 931070259
    LLVM: 594277917
    C#: 484071185
    Rust: 460427159
    TypeScript: 428904119
    JavaScript: 273074800
This is the best-case scenario, including irrelevant categories like databases and VMMs that ought to be written in Rust (or C++).

As far as Microsoft itself goes, they have a new push to ~~lock-in~~ embrace and extend cloud customers:

https://blog.radapp.io/posts/2024/04/16/radius-accepted-as-c...

As far as recent projects that gained traction with the CNCF go, I found some nice write-ups:

https://blog.palark.com/cncf-sandbox-2023-h1/

https://blog.palark.com/cncf-sandbox-2023-h2/

https://blog.palark.com/cncf-sandbox-2024-h1/

    Go: 30
    Rust: 4 (once to implement another lang)
    Python: 2
    Java: 1
    and 2 that are mixed (Go+{C,Rust})
Fun fact, one of the 30 is Eraser - by Deis Labs.
Re:Goenums: Type Safe Enum Generator for Go by pjmlp on Sunday April 27, 2025 @04:48AM (#43810439)
Even back in its heyday what helped C take off was AT&T not being allowed to profit from their Bell Labs research.

Do you think UNIX was sold at VMS, MVS, System/360 prices, even with university discounts, every university on the planet would have been rushing to adopt it on their timesharing systems?

The lawsuits done by AT&T years later, the prohibition of Lion's book, and Sun introducing the concept UNIX developer license, shows how it would have gone.

Re:Goenums: Type Safe Enum Generator for Go by alpaca128 on Sunday April 27, 2025 @07:47AM (#43811235)
C has tagged unions, though. That's the wild thing about Go, it doesn't even cover all basic C features.
Re:Goenums: Type Safe Enum Generator for Go by JyB on Saturday April 26, 2025 @08:21PM (#43808399)
The generics addition is extremely incoherent indeed. Makes sense why there was a lot of push back.
Re:Goenums: Type Safe Enum Generator for Go by hfgjbcgjbvg on Saturday April 26, 2025 @10:39PM (#43809026)
They never should’ve done it but the way they did do it is the best way they could’ve done it.
Re:Goenums: Type Safe Enum Generator for Go by sureglymop on Sunday April 27, 2025 @02:19PM (#43813990)
It's just weirdly bolted on. For example, it's challenging to make fully generic methods when interfaces are implicitly implemented. They should have designed the language better from the start. It also has too many C-isms imo. It had a bit of an identity crisis as to what it wants to be from the start.
Re:Goenums: Type Safe Enum Generator for Go by HideousKojima on Saturday April 26, 2025 @06:28PM (#43807781)
>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

Re:Goenums: Type Safe Enum Generator for Go by tyre on Saturday April 26, 2025 @08:02PM (#43808322)
sorry is the point here that enums are too complicated to understand?
Re:Goenums: Type Safe Enum Generator for Go by pjmlp on Sunday April 27, 2025 @02:09AM (#43809791)
Apparently, like most modern language features in the last 50 years or so.
Re:Goenums: Type Safe Enum Generator for Go by lionkor on Saturday April 26, 2025 @07:07PM (#43808080)
So they made it easy to have data races in a language all about concurrency, bravo. Not buying it.
Re:Goenums: Type Safe Enum Generator for Go by ad_hockey on Sunday April 27, 2025 @05:44AM (#43810635)
It'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

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

Re:Goenums: Type Safe Enum Generator for Go by lionkor on Sunday April 27, 2025 @04:07PM (#43814699)
That'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.
Re:Goenums: Type Safe Enum Generator for Go by ikiris on Saturday April 26, 2025 @10:11PM (#43808925)
it kind of does and doesn't
Re:Goenums: Type Safe Enum Generator for Go by saghm on Saturday April 26, 2025 @10:43PM (#43809043)
I'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.
Re:Goenums: Type Safe Enum Generator for Go by pjmlp on Sunday April 27, 2025 @04:45AM (#43810433)
I 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.