News for hackers. Stuff that matters.
Re:Node.js adds experimental support for TypeScript by tpm on Thursday July 25, 2024 @09:11AM (#41068279)
Java has type inference. Also if a type alias is just a new name for a existing type, then you can always do something like

  class MyNewClass extends OldClass {};
(of course it's not just a new name, it's also a new class, but it's also still a OldClass, and you are out of luck if OldClass is final or sealed)

Java also has interfaces, of course. And optional properties (using Optional) and strict null checks, when you want that, you can use it.

Re:Node.js adds experimental support for TypeScript by VMG on Thursday July 25, 2024 @09:51AM (#41068693)
> type inference

very limited, for instance you must declare the type of a public method

> alias

as you point out it's not

> Java also has interfaces, of course

but you have to implement them explicitly

> strict null checks, when you want that, you can use it

if we start accepting static analysis tools then C has null checks as well I guess

Re:Node.js adds experimental support for TypeScript by tpm on Thursday July 25, 2024 @10:59AM (#41069472)
> as you point out it's not

so what's the difference except the name?

> if we start accepting static analysis tools

I'm not talking about static analysis. In today's Java you can write code that does not accept nulls, if you want to.

Re:Node.js adds experimental support for TypeScript by svieira on Thursday July 25, 2024 @12:22PM (#41070468)
You cannot write code that will fail to compile `theEntryMethod(null)` unless you only use primitive types. (You can, of course, make that method fail at runtime, but that's not what's being talked about here).
Re:Node.js adds experimental support for TypeScript by guipsp on Thursday July 25, 2024 @09:50AM (#41068684)
Using optional still has the secret third thing problem