Hacker News new | ask | show | jobs
by coldtea 1918 days ago
>I can't help but feel like if you want static typing, you're better off recognizing that python is not the right tool for the job.

Static typing is not a job though. It's a language feature. The job is solving technical/business problems.

And Python is a tool, but it's not a tool to do dynamic typing or static typing with, it's a tool to solve problems with.

So, the comment "if you want static typing, you're better off recognizing that python is not the right tool for the job" doesn't quite sit right.

You could instead better say that it's not a good fit for Python.

But why would that be?

Especially since one could easily have said the same for Javacript, but Typescript exists as basically Javascript + types, and people seem to love it.

So there's that.

2 comments

Typescript a) is just plain a lot better than mypy b) is still a poor experience compared to using a first-class typed language.

The extent to which a) is due to implementation decisions made by typescript/mypy vs being due to inherent differences between Javascript and Python is arguable. Certainly there are things that look like unforced design errors in mypy, and the fact that Dart existed (and largely failed) before Typescript shows that it's not just about what language you're based on. But there are also idioms and aspects of the Python object model that seem inherently hard to type nicely, and are sadly too entrenched in the ecosystem to change.

> Typescript (...) is still a poor experience compared to using a first-class typed language.

I personally don't agree. I have coded in C# and TS extensively, and while first-class types available in runtime (especially with generics <cough>though not in java</cough>) is super nice, I think the benefits of looseness of TS overweight the costs. Also, you can always go crazy and use zod or io-ts, but in that road there's always the danger of just writing types and not doing any work because "typing is fun"(c).

I spent a couple of days trying to make an app work in typescript before thinking "I'll just give Scala.js a quick try, not going to spend a lot of time on it", and to my surprise everything just worked perfectly.
I'm happy to hear that, even though I'd personally refrain from getting myself into a Scala codebase again :) (IMHO, it goes further in the "typing for typing's sake" direction). Because of my existing skills I'd probably use Blazor, if I'm going that way.
Javascript has no real competition. People have accepted its existence as a given so every improvement over it is celebrated. On the other hand, many languages want to be the new python and their fans will try to bring it down at every opportunity.

Note: I'm a python dev, yet even I can agree that the python ecosystem is broken and if not maintained, the language will decline over time.