News for hackers. Stuff that matters.
Re:(On | No) Syntactic Support for Error Handling by 9rx on Tuesday June 03, 2025 @03:03PM (#44173434)
> lets not forget that the Go team made the same blunder made by Java

To be fair, they were working on parametric polymorphism since the beginning. There are countless public proposals, and many more that never made it beyond the walls of Google.

Problem was that they struggled to find a design that didn't make the same blunder as Java. I'm sure it would have been easy to add Java-style generics early on, but... yikes. Even the Java team themselves warned the Go team to not make that mistake.

Re:(On | No) Syntactic Support for Error Handling by karmakaze on Tuesday June 03, 2025 @03:19PM (#44173600)
At least Java supports covariance and contravariance where Go only supports invariant generics.
Re:(On | No) Syntactic Support for Error Handling by PaulHoule on Tuesday June 03, 2025 @03:49PM (#44173936)
Java has evolved to contain much of “ML the good parts” such as that languages like Kotlin or Scala that offer a chance to be just a bit better in the JVM look less necessary
Re:(On | No) Syntactic Support for Error Handling by throwaway2037 on Tuesday June 03, 2025 @11:43PM (#44177025)

    > Java has evolved to contain much of “ML the good parts”
Can you give some examples?
Re:(On | No) Syntactic Support for Error Handling by yz453 on Wednesday June 04, 2025 @12:50AM (#44177328)
Not OP. IMO the recent Java changes, including pattern matching (especially when using along with sealed interface), virtual threads (and structured concurrency on the way), string templates, are all very solid additions to the language.

Using these new features one can write very expressive modern code while still being interoperable with the Java 8 dependency someone at their company wrote 20 years ago.

Re:(On | No) Syntactic Support for Error Handling by tpm on Wednesday June 04, 2025 @04:35AM (#44178503)
fyi: string templates were just a preview and removed in Java 23
Re:(On | No) Syntactic Support for Error Handling by PaulHoule on Wednesday June 04, 2025 @09:57AM (#44180799)
For Java systems that I work on for my own account there is a lot of stuffing things like SQL queries into resource files so that I don't have to mess around with quotes and such.
Re:(On | No) Syntactic Support for Error Handling by PaulHoule on Wednesday June 04, 2025 @09:56AM (#44180791)
Like a lot of other languages, Java has gotten a big dose of

https://en.wikipedia.org/wiki/Hindley%E2%80%93Milner_type_sy...

To defy it's reputation for verbosity, Java's lambda syntax is both terse and highly flexible. Sum and product types are possible with records and sealed classes. Pattern matching.

Re:(On | No) Syntactic Support for Error Handling by karmakaze on Tuesday June 10, 2025 @05:20PM (#44241576)
I even found a way to make ad-hoc union types of element types from other packages that does exhaustive switch/case checking. I quickly wrote down a PoC so I wouldn't forget[0]. It needs wrapper types and sealed interfaces in the consuming app/package but is manageable and turned out better than other attempts I'd made.

[0] https://github.com/karmakaze/AdHocUnion

Re:(On | No) Syntactic Support for Error Handling by throwaway2037 on Tuesday June 03, 2025 @11:22PM (#44176932)

    > blunder made by Java
For normies, what is wrong with Java generics? (Do the same complaints apply to C# generics?) I came from C++ to Java, and I found Java generics pretty easy to use. I'm not interested in what "PL (programming language) people" have to say about it. They dislike all generic/parametric polymorphism implementations except their pet language that no one uses. I'm interested in practical things that work and are easy for normies to learn and use well.

    > Even the Java team themselves warned the Go team to not make that mistake.
Do you have a source for that?
Re:(On | No) Syntactic Support for Error Handling by moomin on Wednesday June 04, 2025 @01:49AM (#44177594)
Yeah, it _doesn’t_ apply to C# generics. Basically, if you’ve got List<Person> and List<Company> in C#, those are different classes. In Java, there’s only one class that’s polymorphic. This causes a surprising number of restrictions: https://docs.oracle.com/javase/tutorial/java/generics/restri...
Re:(On | No) Syntactic Support for Error Handling by cayley_graph on Wednesday June 04, 2025 @02:37AM (#44177781)
> I'm not interested in what "PL (programming language) people" have to say about it. They dislike all generic/parametric polymorphism implementations except their pet language that no one uses.

That's strange. I seem to recall the PL community invented the generics system for Java [0,1]. Actually, I'm pretty sure Philip Wadler had to show them how to work out contravariance correctly. And topically to this thread, Rob Pike asked for his help again designing the generics system for Go [2,3]. A number of mistakes under consideration were curtailed as a result, detailed in that LWN article.

There are countless other examples, so can you elaborate on what you're talking about? Because essentially all meaningful progress on programming languages (yes, including the ones you use) was achieved, or at least fundamentally enabled, by "PL people".

[0] https://homepages.inf.ed.ac.uk/wadler/gj/

[1] https://homepages.inf.ed.ac.uk/wadler/gj/Documents/gj-oopsla...

[2] https://arxiv.org/pdf/2005.11710

[3] https://lwn.net/Articles/824716/

Re:(On | No) Syntactic Support for Error Handling by tpm on Wednesday June 04, 2025 @02:42AM (#44177812)
Type erasure is what is wrong with Java generics. It causes many issues downstream.
Re:(On | No) Syntactic Support for Error Handling by throwaway2037 on Wednesday June 04, 2025 @04:42PM (#44185288)

    > It causes many issues downstream.
I don't understand this part. Can you give some concrete examples? In my experience, Google Gson and Jackson FasterXML can solve 99.9% of the Java Generic issues that I might have around de/ser.
Re:(On | No) Syntactic Support for Error Handling by tpm on Thursday June 05, 2025 @02:24AM (#44188851)
I could, or you could use google. Neither of those tools can solve any issue caused by type erasure.

Just to give some examples, the instanceof operator does not work with generic types, it's not possible to instantiate a generic type (can't do a new T()), can't overload methods that differ only in generic parameter type (so List<String> vs List<Integer>) and so on. Some limitations can be worked around with sending around explicit type info (like also sending the Class<T> when using T), reflection etc., but it's cumbersome, and not everything can be solved that way.

Re:(On | No) Syntactic Support for Error Handling by pjmlp on Friday June 06, 2025 @01:31PM (#44203162)
Should I repost the blog posts where they acknowledge the failure to look into languages like CLU?