I've always felt it was verbose and the need for classes for everything was a bit of a overkill in 90% of circumstances (we're even seeing a pushback against OOP these days).
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!)
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