There's also something fundamental about taking a dynamic language like Python or JavaScript and adding typing versus taking a static language and adding dynamic typing (e.g.`auto` in C#). The dynamic language allows modifications that are _really_ convenient if not a little hacky that you just can't easily express without big refactors in static codebases. Things like tagging objects with properties, making quick anonymous structs (before that became a thing in modern languages) so you can return tuples of values, other constructs like dynamic functions or whatever. Progressive typing is just so much more expressive
Assuming you meant C++ - no, auto is not a even a tiny bit dynamic. It's still fully static typing, but with type inference.
The compiler will still prevent you from calling a method which doesn't exist.
As you say though, not everybody gets to choose their language, and I certainly wouldn't choose Python if I could possibly help it, so if we can add good static types to Python, it's still not a great language, but it's much improved by static types.
If anyone built a typescript layer on top of Python, I’d cheer that effort. If that new thing from the article will be that, I’m stoked.
People asking why statically typed python: consider that it's the #1 language on GitHub (assume ts and js are different) and LLMs are really good at generating it.
In my case, I have, in the pursuit of my engineering goals, had to dig into a Python component that I did not normally work on or intend to work on. I am thankful it had type hints.
I don't have anything against typing. I just get annoyed when it gets out of control in a language it wasn't part of to begin with. Just look at how complex typescript typing is to see where it can go.
Used pragmatically it's fine. When it's out of control we might as well switch to another language.
Seems pretty plausible that someone can dislike python and still like a job because it checks other boxes.
I hate every language! For different reasons. But I still like programming.
> But most people in our profession get to choose their job, don't they?
Let's say someone has only worked in Python professionally but dislikes it. They spent nights & weekends learning Rust. Now they want a Rust job. Because a Rust project would not hire a Python programmer, this person who hates Python is stuck working on Python projects.
It's attitudes exactly like "Why would a Python project hire a Rust programmer?" that keep people stuck in languages they don't hate. Those attitudes are the reason a senior software engineer with over a decade in the field can't switch tech stacks. Without that attitude, job postings would be written for programmers, not python programmers, and the job market would be better for it.
Choose, yes, but from a finite set.
> Men make their own history, but they do not make it as they please; they do not make it under self-selected circumstances, but under circumstances existing already, given and transmitted from the past. The tradition of all dead generations weighs like a nightmare on the brains of the living.
— Karl Marx, "The 18th Brumaire of Louis Bonaparte"
Looking at my Python before I began using type hints and data structures such as dataclasses, typevars, etc I was still type-checking a function's argument, but it was very manual and messy. Nowadays, my code is so much cleaner, concise, less error-prone, and much easier to revisit after a long period away. IMO there isn't a single downside to leaning heavily into types, even if they're sorta "fake" like they are in Python.
And full typing is also a great first step for rewriting in another language.
Type hints fix this by allowing you to ensure your contracts are upheld while your team continues to move. If you don't find yourself needing them, you probably don't have a team that's trying to ship and iterate super quickly, or your project is still at the one-off script scale.
This is grossly incorrect.
Personally, I'm one of those people that got converted over to statically typed languages, as I spent a large part of my early career in startups using Ruby. I don't think I could ever go back after using Go, TypeScript, and Rust over the past decade or so.
you can obviously still use it untyped to hack together scripts, but I still find myself leaving annotations for clarity.
I've been using it since the mid 2.x days and find the style we were writing back then to be incredibly dated.
I used to prefer dynamically typed languages for most tasks, and saw attempts at statically typing everything as some kind of [compulsion][1].
At work, we were writing a bunch of tests and tooling in python, and the team lead at the time insisted that we type things and lint with mypy strict as if it were a compiler.
I said to my teammate "this is so stupid, if you want to know the types of the parameters, you read the documentation comment right there in the definition. If you want to know more, you read the test. If you want to know even more, you read the source."
My teammate replied, "YOU will write a function with good documentation, thorough tests, and a comprehensible definition, but as an organization grows, a shrinking percentage of code will be written that way. These automated checks prevent the worst from coders who care less than you do."
I had no retort, so there is that.
[1]: https://github.com/dgoffredo/stag?tab=readme-ov-file#why
But now over the last years, I happen to prefer changing programs a lot without running them a lot. I often do code refactorings over multiple commits, being highly concentrated, without running the code once. And then only running the code only 1 hour or 2 later. Such a pleasant activity! Just writing, reading, writing, thinking code. No ugly and long stack traces, no need to input user data into input fields, just reading and changing the program code, with the editor in full screen.
And guess what I highly started to appreciate, after many years of Python! Type annotations! With type annotations a LSP would immediately underline any mistake I would accidentally make, and that made me feel much more comfortable and secure about my changes, over several commits, touching 100s of lines without ever running the program. I suddenly learned to understand, after many years of dynamic type less programming with Python, that I can get more easily and for much longer into a flow state when I add annotations and run a LSP live over my code while I work on it.
Python typing is about machine checkable properties of your program. Consider a function foo that takes a dictionary keyed by uuids, reads from it, and returns some kind of information. We can check all sorts of properties without ever running the code. Accidentally construct a dictionary keyed by strings instead of uuids? Rejected, wrong argument type. Accidentally modify the dictionary in the body of foo()? Rejected, if you wrote Mapping[UUID, Any] for the argument type. Mapping alone does not allow you to assume mutability. So many of the errors I make in Python, I can declare my intention not to make, and then check to see if I’ve committed them.
Who? People on your team or randoms complaining about your open source project? If it's the latter, you can tell them to get bent or write their own type stubs if it bothers them. Type hints are fully optional in Python.
Also its super hard to find non-crypto-currency rust jobs, but python jobs are pretty common.