News for hackers. Stuff that matters.
Re:Python’s “type hints” are a bit of a disappointment to me by gilbetron on Friday April 22, 2022 @08:47AM (#31120949)
On the small scale, Python is very productive. Once you get to large codebases with a rotating roster of many developers, it becomes a net negative, which is why type specification languages are gaining major inroads. I love Python, but I wouldn't write anything for production at any scale in it anymore. But for small scale stuff, it remains my favorite! (Although, I like static binaries languages, like Go, for a lot of things these days because of the deployment simplicity)
Re:Python’s “type hints” are a bit of a disappointment to me by j4mie on Friday April 22, 2022 @09:24AM (#31121252)
What's your definition of "large codebases" here? My experience is that on Python codebases large (~100k lines) and small, type annotations are generally a net negative, particularly with a "rotating roster of many developers", because of their complexity and detrimental effect they have on readability. As the OP says, incorrect types are worse than no types at all.
Re:Python’s “type hints” are a bit of a disappointment to me by gilbetron on Friday April 22, 2022 @10:11AM (#31121748)
type hinting is a bandaid, I'm not going defend it. My argument is that statically typed languages are better for large scale development.
Re:Python’s “type hints” are a bit of a disappointment to me by j4mie on Friday April 22, 2022 @10:31AM (#31122025)
You still haven't defined "large scale" or "better". And you haven't backed up your argument with any evidence.
Re:Python’s “type hints” are a bit of a disappointment to me by wheelerof4te on Friday April 22, 2022 @09:44AM (#31121431)
How is typing productive in large codebases? If I see a bunch of imports related to typing only, I have to juggle them around in my mind together with stuff that really matters.

Not to mention the notorious circular import problem, that is much more likely in a big codebase.

If I have a custom class, that class has to be passed as a type hint for functions. What If I use that class in another module, but have to import it inside this one that has a type-hint only?

Well, let me introduce you to their genious solution:

  from _future_ import annotations
  from foomod import FooClass

  def myfun(foo: FooClass):
    return foo.bar()
Wonderful, isn't it?
Re:Python’s “type hints” are a bit of a disappointment to me by icedchai on Friday April 22, 2022 @06:20PM (#31128923)
I also find most of the "import typing" stuff to be clutter. I worked at a place that was heavily into adding typing to existing code, some of which was almost a decade old. They spent more than a few person years on that effort, and it's still going on.

Not once did I find the additional typing useful in my actual day-to-day work.

Re:Python’s “type hints” are a bit of a disappointment to me by bayesian_horse on Saturday April 23, 2022 @12:30AM (#31131409)
Scaling a code base doesn't start or end with type checking. Some of the answers to what you are implying is: Use interfaces when using OOP. Consider dependency injection or other Inversion of Control patterns. Maybe don't use OOP as much...
Re:Python’s “type hints” are a bit of a disappointment to me by bayesian_horse on Friday April 22, 2022 @08:59AM (#31121062)
What is "major inroads"? Python is actually rising in popularity and major companies are building big things entirely in Python...

In my opinion there is no excuse not to.

Re:Python’s “type hints” are a bit of a disappointment to me by gilbetron on Friday April 22, 2022 @10:08AM (#31121713)
Python has a tremendous amount of momentum because it has become so popular outside of the traditional software development world, but other languages are picking away at it, even given that momentum. And while I am in a bubble, like everyone else, in my bubble, and those I talk to in my bubble, all see large a shift away from Python.

Adding stronger typing, like type hints, could reverse that, of course.

The reason not to is performance and reliability. Typing helps with the latter, Python is just bad at the former.

Re:Python’s “type hints” are a bit of a disappointment to me by bayesian_horse on Saturday April 23, 2022 @12:31AM (#31131412)
That "shift" away from Python wouldn't be seen in any particular data, right?
Re:Python’s “type hints” are a bit of a disappointment to me by icedchai on Friday April 22, 2022 @09:25AM (#31121267)
Major companies build things entirely in Javascript, too. Popularity doesn't mean anything. Honestly, for a small web app, I'd pick PHP / Laravel over Python. Deployment is way simpler.
Re:Python’s “type hints” are a bit of a disappointment to me by foepys on Friday April 22, 2022 @09:27AM (#31121290)
What you both are experiencing is your bubbles clashing.
Re:Python’s “type hints” are a bit of a disappointment to me by tezzy on Tuesday April 26, 2022 @05:54PM (#31173658)
I have been developing almost exclusively in Python for the last 4 years (occasional C#, Java and PHP) and although my entire team disparages PHP it is really quicker and fewer characters for most stuff.

Luckily IDEs can auto add the imports, but sometimes a slightly mistyped piece of code auto adds an import I need to delete, I love avoiding imports and circular imports in PHP. The other nice thing is avoiding random python behaviour differences in MacOS, Windows and Ubuntu. Code that works fine in CircleCI but not locally. Works on a Mac but not on windows etc… I didn’t experience that with PHP.

Not sure there are a huge number of long term PHP devs who switch to Python or the other way around to have a reasonable opinion.

Re:Python’s “type hints” are a bit of a disappointment to me by gilbetron on Friday April 22, 2022 @10:09AM (#31121720)
This is a rather uninteresting statement, as we all live in bubbles - knowledge of them helps, but really just puts you in a different bubble. Still a bubble.
Re:Python’s “type hints” are a bit of a disappointment to me by bayesian_horse on Saturday April 23, 2022 @12:32AM (#31131420)
I'd say all metrics point to the popularity of Python increasing, while there is no data indicating that people are fleeing Python en masse. Or at all, actually.