this post was submitted on 26 Jul 2023
13 points (100.0% liked)

Python

6230 readers
3 users here now

Welcome to the Python community on the programming.dev Lemmy instance!

📅 Events

October 2023

November 2023

PastJuly 2023

August 2023

September 2023

🐍 Python project:
💓 Python Community:
✨ Python Ecosystem:
🌌 Fediverse
Communities
Projects
Feeds

founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] zeusbottom@sh.itjust.works 3 points 1 year ago (6 children)

It’s very weird to me that Python, as an inherently untyped language, is trying to bolt on stronger typing through modules like Protocol and typing.

If typing is a good thing, why not make it an optional first-class part of the language? Maybe make strong typing a one liner option at the top of a source file? This growing maze of modules and recommendations is so unwieldy. For example, the typing module works kind of in conjunction with language elements that aren’t what newbs learn in Python 101, like type specifiers in function args. I feel like this stuff is driving Python away from simplicity.

[–] rglullis 3 points 1 year ago (3 children)

I don't get this complaint.

Python is not adding typing, it's just improving on its static type checker. Nothing is really changing at runtime. Even if your type annotations are completely wrong, your code will run just fine. It's up for the developers and the team to know how much they will benefit from adopting it.

[–] zeusbottom@sh.itjust.works 1 points 1 year ago (2 children)

I’m not complaining, just reflecting that it is weird to me. The static type checker is almost an admission that type checking is a Good Thing, but Python continues to resist adding runtime checking. Modules like typing and Protocol don’t seem to do anything at runtime, and because of that are deeply weird to me - what kind of include doesn’t have runtime code? I haven’t seen anything quite like it in any other language I’ve coded in. It just seems included for the coders’ IDE to throw warnings, and that’s it.

Then again, it’s entirely possible I just don’t get around much. I’m not a software guy, I’m hardware, and occasionally I’ll write a tool or website to help with a specific task.

I suppose the alternative is just as weird or weirder, where there are almost two separate languages, one strongly typed and one not typed at all.

[–] pileghoff@programming.dev 4 points 1 year ago* (last edited 1 year ago) (1 children)

How would they add runtime checking without breaking all existing code?

But I think warning people is a good start, because those checks can be added to your CI pipeline and reject any incoming code that contains warnings. That way you can enforce type checking for a subset of modules and keep backwards compatibility.

[–] Sigmatics@lemmy.ca 1 points 1 year ago

By making it opt-in. But that's not much different from static typing then, except that it won't actually work when you screw up typing

load more comments (2 replies)