by Zababa · 5y ago · 0 comments
import java.util.ArrayList;
var cars = new ArrayList<String>();
Python would be: cars: list[string] = []
The big difference seems to be that ArrayList is not a "default" data structure in Java, but it is in Python. While I like the Python example better, I'm not offended by the modern Java.I assume for more advanced work like the one OP mentions you'd still want to stick to Python because of the superior ecosystem, but I was pleasantly surprised by Java.
Can't believe I'm writing this, but I actually like modern Java.
This obsession with killing perfectly good languages with strongly typed hints is completely undermining the point.
To go back to the code example, if you want to express the same thing in Python as in Java, you have to add a type hint to be able to statically check the code. A good thing about Python is that you can choose when and if you want to use a static type hint, while in Java you're forced to use them.