Re:Why Today's Python Developers Are Embracing Type Hints
by ktosobcy on Sunday September 28, 2025 @06:36AM
(#45403286)
Well, we do coalesce on certain things... some static type languages are dropping type requirements (Java and `var` in certain places) :D
[ Parent
| on HN ]
Re:Why Today's Python Developers Are Embracing Type Hints
by moefh on Sunday September 28, 2025 @06:48AM
(#45403350)
There's no dropping of type requirements in Java, `var` only saves typing.
When you use `var`, everything is as statically typed as before, you just don't need to spell out the type when the compiler can infer it. So you can't (for example) say `var x = null` because `null` doesn't provide enough type information for the compiler to infer what's the type of `x`.
Re:Why Today's Python Developers Are Embracing Type Hints
by procaryote on Sunday September 28, 2025 @04:06PM
(#45407497)
> `var` only saves typing.
this is a lovely double entendre
Re:Why Today's Python Developers Are Embracing Type Hints
by constantcrying on Sunday September 28, 2025 @06:43AM
(#45403329)
var does absolutely nothing to make Java a less strictly typed language. There is absolutely no dropping of the requirement that each variable has a type which is known at compile time.
Automatic type inference and dynamic typing are totally different things.
Re:Why Today's Python Developers Are Embracing Type Hints
by hirvi74 on Sunday September 28, 2025 @06:11PM
(#45408555)
I have not written a line of Java in at least a decade, but does Java not have any 'true' dynamic typing like C# does? Truth be told, the 'dynamic' keyword in C# should only be used in the most niché of circumstances. Typically, only practitioners of Dark Magic use the dynamic type. For the untrained, it often leads one down the path of hatred, guilt, and shame. For example:
dynamic x = "Forces of Darkness, grant me power";
Console.WriteLine(x.Length); // Dark forces flow through the CLR
x = 5;
Console.WriteLine(x.Length); // Runtime error: CLR consumed by darkness.
C# also has the statically typed 'object' type which all types inherit from, but that is not technically a true instance of dynamic typing.