Re:Python overtakes Java to become the second-most popular p...
by zmmmmm on Thursday November 05, 2020 @04:25PM
(#25002142)
I was super hopeful about type hints but they fell short of my expectations, unfortunately. It takes you to a place full of kluges and workarounds and hacks which is all .... really unpythonic.
In the end I feel, if you really want that, use a language that treats types as a first class citizen. There are languages with most of Python's attractive features but actual optional typing (we use Groovy), or static with really good inferred types (eg: Kotlin) etc.
Re:Python overtakes Java to become the second-most popular p...
by neverartful on Thursday November 05, 2020 @01:46PM
(#25000751)
I was really happy when I first learned of type annotations being added to Python. However, much of that excitement evaporated when I read that it was just a 'hint' and not something that's enforced.
Re:Python overtakes Java to become the second-most popular p...
by heavyset_go on Thursday November 05, 2020 @02:20PM
(#25001057)
This was also my initial reaction. However, if you couple type annotations with an LSP server[1] that takes the annotations into consideration[2], you'll get on-the-fly type checking in your editor or IDE. That way you can catch type errors as you write your typed Python code.
Besides VS Code, these days lightweight editors like Kate, Sublime Text, Vim, etc can all take advantage of type checking LSP servers for Python.
Re:Python overtakes Java to become the second-most popular p...
by photonios on Thursday November 05, 2020 @02:21PM
(#25001065)
It's not enforced by CPython the interpreter. You run mypy to enforce the type hints: http://mypy-lang.org/
It's quite good.
I've found that using Python for large projects is both fine and productive as long as you utilize type annotations and modules. Ambiguity goes out the window when you do that.