News for hackers. Stuff that matters.
Re:Fourteen Years of Go by qaq on Saturday November 11, 2023 @07:23AM (#38229712)
Good tooling out of the box. Very predictable dev. trajectory. Became my go to language for most personal projects. My only remaining ask would be sum types.

The stack I settled on:

Postgres + sqlc

templ (kindah jsx for go) + htmx

Barely have to write any js/ts now

Re:Fourteen Years of Go by BD103 on Saturday November 11, 2023 @09:11AM (#38230411)
Sum types are amazing! Once I got introduced to them in Rust, it was hard to go back to languages like Java where the enum type is pitiful in comparison.
Re:Fourteen Years of Go by kaba0 on Saturday November 11, 2023 @10:00AM (#38230845)
Java literally has algebraic data types, see sealed classes/interfaces and records.
Re:Fourteen Years of Go by diarrhea on Saturday November 11, 2023 @11:17AM (#38231589)
Not familiar with Java, but C# has sealed classes as well. They are not the real deal. You can fake your way around to achieve something resembling sum types, but the deep language integration like in Rust is simply unattainable. For example, ADT and pattern matching go hand in hand, so you want syntax-level, first class and powerful support for structural pattern matching as well. Not sure about Java, but last I used it C# had only relatively basic support.
Re:Fourteen Years of Go by kaashif on Saturday November 11, 2023 @11:51AM (#38231938)
Java actually does have pattern matching like this:

    int eval(Expr e) {
        return switch (e) {
            case ConstantExpr(var i) -> i;
            case PlusExpr(var a, var b) -> eval(a) + eval(b);
            case TimesExpr(var a, var b) -> eval(a) \* eval(b);
            case NegExpr(var e) -> -eval(e);
            // no default needed, Expr is sealed
        }
    }
But it only got that recently.
Re:Fourteen Years of Go by kaba0 on Saturday November 11, 2023 @12:16PM (#38232221)
And further improvements are expected.
Re:Fourteen Years of Go by diarrhea on Saturday November 11, 2023 @03:20PM (#38234114)
Wishing that eco system the best then! ADTs and pattern matching are the best thing since sliced bread.

Sometimes I wonder: will they become table stakes in the future, or will we wake up to their (currently unknown) downsides in a decade or two? Think of how exceptions are now considered a poor pattern, compared to errors as values.

Re:Fourteen Years of Go by hyeomans on Saturday November 11, 2023 @09:57AM (#38230814)
Do you like doing complex joins with sqlc?
Re:Fourteen Years of Go by qaq on Saturday November 11, 2023 @11:42AM (#38231831)
This is such a small fraction of queries on my projects that I don't really pay much attention to it to be honest.
Re:Fourteen Years of Go by can3p on Saturday November 11, 2023 @11:23AM (#38231648)
Thanks for mentioning templ, looks interesting. Templates are one of the fields where go has some space for improvements
Re:Fourteen Years of Go by qaq on Saturday November 11, 2023 @12:08PM (#38232139)
Really enjoy using it VS code plugin is pretty good.