News for hackers. Stuff that matters.
Re:Go Enums Still Suck by ikari_pl on Thursday March 28, 2024 @07:45AM (#39849982)
The more code I need to READ to understand what I'm looking at, the less optimized for maintenance it is. If it takes 5 lines to understand that the map I'm looking at is effectively used as a set, it's worse than if I had a Set abstraction.

Of course now I do, 20 of them, because when there's no built in, there will be packages made by the community.

Re:Go Enums Still Suck by sethammons on Thursday March 28, 2024 @07:50AM (#39850034)
Congrats, you just inherited this code and have to fix it:

    Mercury 0.378,2439.7,3.3e23,57910000,88,0.0000000001,0,false
There is no way to infer what any of the values are. They are practically magic numbers. How do you know if you swapped a pair of numbers there and what that will do to the application? You have to mentally map all those things.

It is vastly, overwhelmingly more new-dev friendly to use:

    MERCURY: Planet{
  planet:              mercury,
  Gravity:             0.378,
  RadiusKm:            2439.7,
  MassKg:              3.3e23,
  OrbitKm:             57910000,
  OrbitDays:           88,
  SurfacePressureBars: 0.0000000001,
  Moons:               0,
  Rings:               false,
 },
Re:Go Enums Still Suck by zarldev on Thursday March 28, 2024 @08:01AM (#39850136)
the values are specified in the definition of the iota type.

``` type planet int // Gravity[float64],RadiusKm[float64],MassKg[float64],OrbitKm[float64],OrbitDays[float64],SurfacePressureBars[float64],Moons[int],Rings[bool] ```

Re:Go Enums Still Suck by sethammons on Thursday March 28, 2024 @08:03AM (#39850151)
yeah, and now, mentally count how many values you are in, don't lose count now! Why offload that to your brain where you could miscount instead of using structured data?
Re:Go Enums Still Suck by rat9988 on Thursday March 28, 2024 @08:11AM (#39850233)
Because your whole argument is misconstructed. There are cases where longer code is better, but there are many cases where longer is worse too. Because the tools the language provide, on top of being more succint, make the intent more obvious.
Re:Go Enums Still Suck by Debilski on Thursday March 28, 2024 @09:03AM (#39850773)
I’m wondering why we don’t use any type and definition-aware IDEs that could render the first line as a proper table (especially once there is a list of items of the same type involved). With headers and aligned fields. Similar to how Word would do it with inline tables.

Ideally of course with a switch to change to the second, more verbose definition.

Re:Go Enums Still Suck by CharlieDigital on Thursday March 28, 2024 @09:08AM (#39850856)
Rider (and probably all JetBrains IDEs?) have inlined parameter names and types as hints.

https://www.jetbrains.com/help/rider/Inline_Parameter_Name_H...

Re:Go Enums Still Suck by MSFT_Edging on Thursday March 28, 2024 @09:16AM (#39850951)
That would tie languages to language tools and IMO be a downgrade from having a slightly more verbose language that is independent of tooling.
Re:Go Enums Still Suck by zeven7 on Thursday March 28, 2024 @09:12AM (#39850904)
Maybe this data should be stored in a CSV and edited in Google Sheets/Excel.
Re:Go Enums Still Suck by hbogert on Saturday March 30, 2024 @04:59PM (#39878595)
I've got a job for you, mine at my previous company!
Re:Go Enums Still Suck by deelly on Thursday March 28, 2024 @08:19AM (#39850313)
Huh, for me its opposite, I`m ok with reading/fixing/updating few pages of code if its easy to read and easy to update.

Short code with multiple levels of abstractions, with dynamic inheritance, and with a lot of dependency inversion, etc. etc... I don't like it. I will spend a lot more time (probably) just digging into code while trying to understand it.