Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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#?



A 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.


Not sure if you know what you're talking about. Python has always been a strongly typed language.


Surprised 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.


You’re probably one of those people that says “you mean the world wide web?” when someone says the internet.


No 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.


What 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!)


They're probably suggesting performance differences


the 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++)


Even 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.


Not necessarily ML, more generally - numeric, as in NumPy/scipy/pandas, variety of optimisers, plotting and reporting tools and whatnot.


This is the only reply to my question that makes sense, thanks!

All of the other replies are subjective.


Those 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.


This 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.


Not 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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: