4 ms·
I'm glad that strong typing is getting popular and it's not just for weak minds anymore. But (for new projects anyway) what's the point of using Python with ty
by booleandilemma 6y ago
I'm glad that strong typing is getting popular and it's not just for weak minds anymore.
But (for new projects anyway) what's the point of using Python with types instead of using a real typed language like Java or C#?
- high_density 6y agothe point of using python? ML libraries! that's the 99% case of python-only case. Other than that, I actually don't know... a lot of other languages now have interpreted-dev envs... (btw, I'd rather use Kotlin than java --- it's like Java++)
- booleandilemma 6y agoThis is the only reply to my question that makes sense, thanks! All of the other replies are subjective.
- pjmlp 6y agoEven there, many of those libraries are written in C, Fortran and C++. On can use any bindings to those libraries, including using modern versions of Fortran and C++ directly.
- aldanor 6y agoNot necessarily ML, more generally - numeric, as in NumPy/scipy/pandas, variety of optimisers, plotting and reporting tools and whatnot.
- jasonpeacock 6y agoThose are compiled languages, while Python is an interpreted language. You're comparing apples and oranges. Interpreted languages are quick to develop/quick to learn, and with the support of typing that same "quick prototype" can easily mature into a full application without needing to be re-written in a "real" language.
- dehrmann 6y agoThis isn't an interesting distinction for quick prototypes because the difference is basically python task.py vs javac Task.java java -cp . Task And if you're in and IDE (in fairness, they're not popular for quick prototypes), you're just clicking the play button either way.
- pjmlp 6y agoNot really given that there are REPLs for Java, C#, OCaml, Haskell, F#, Scala. There are also toolchain options for running the code interpreted, JIT compiled, AOT compiled, or a mix of the previous options. Languages are orthogonal to the toolchains.
- duckerude 6y agoA use case is library code. I've had good results using type annotations internally in a library for education and research. Static typing would be overkill for most of the users of the library but it's useful for developing the library itself. Aside from that, an advantage is that the type system is more expressive than that of Java or C#. Most common Python idioms work just the same way with or without type annotations, so you can continue to write functions that take either int or str arguments (for better or worse) and the typechecker will understand your use of isinstance and make sure everything checks out. (But there are other fully statically typed languages that are also more expressive than Java or C#.) You can also continue to do weird metaprogramming and monkeypatching, and though the typechecker is not always able to make sense of it you can often wrap it in a safe interface so you can still get assurances for the rest of the project.
- joshuamorton 6y agoWhat makes Java's typing more "real" than python's? I find typed python more pleasant and expressive than similar Java, for a variety of reasons, among them, I find python's type system to be superior to Java's (and getting even better faster!)
- t-writescode 6y agoThey're probably suggesting performance differences
- human_error 6y agoNot sure if you know what you're talking about. Python has always been a strongly typed language.
- booleandilemma 6y agoYou’re probably one of those people that says “you mean the world wide web?” when someone says the internet.
- b5n 6y agoSurprised to see you downvoted on HN for being right. In a thread specifically regarding python typing you would think getting the basics right is kind of important. I don't see the hype here, just use a statically typed language if it's an important consideration for the project.
- lmm 6y agoNo it hasn't. Python has things that it calls types, but they're not types: you can't determine the "type" of an expression from the "type" of its components.