(no title)
ystvn | 5 months ago
I've heard about Java initiatives to improve it, but can you point to examples of how how Java "is maturing into a syntactically nice language"?
I'm tempted to learn it, but wonder whether it would really become nice enough to become a 'go-to' language (over TS in my case)
ppeetteerr|5 months ago
Here are some actual improvements:
- Record classes
public record Point(int x, int y) { }
- Record patterns
record Person(String name, int age) { }
if (obj instanceof Person(String name, int age)) { System.out.println(name + " is " + age); }
- No longer needing to import base Java types - Automatic casting
if (obj instanceof String s) { // use s directly }
Don't get me wrong, I still find some aspects of the language frustrating:
- all pointers are nullable with support from annotation to lessen the pain
- the use of builder class functions (instead of named parameters like in other languages)
- having to define a type for everything (probably the best part of TS is inlining type declarations!)
But these are minor gripes
gf000|5 months ago
Also, a very wide-reaching standard library, good enough type system, and possibly the most advanced runtime with very good tooling.
theanonymousone|5 months ago
Check jbang.dev, and then talks by its author Max Rydahl Andersen. That could be a starting point.
62951413|5 months ago