TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: Will we see a TypeScript for Python?

11 pointsby rrishiabout 2 years ago
Is there a need for such a thing like JS needed it? Is it viable?

10 comments

PaulHouleabout 2 years ago
Python has an optional typing system which helps your IDE complete things and can be checked with tools like<p><a href="https:&#x2F;&#x2F;mypy.readthedocs.io&#x2F;en&#x2F;stable&#x2F;index.html" rel="nofollow">https:&#x2F;&#x2F;mypy.readthedocs.io&#x2F;en&#x2F;stable&#x2F;index.html</a><p>Plus there are compilers which can make faster code if you add static types<p><a href="https:&#x2F;&#x2F;cython.readthedocs.io&#x2F;en&#x2F;latest&#x2F;src&#x2F;quickstart&#x2F;cythonize.html" rel="nofollow">https:&#x2F;&#x2F;cython.readthedocs.io&#x2F;en&#x2F;latest&#x2F;src&#x2F;quickstart&#x2F;cytho...</a>
abeppuabout 2 years ago
It&#x27;s true that python has support for typing, and I do find that mypy helps produce better python code.<p>But I think a meaningful issue is that python&#x27;s rich ecosystem of datascience and ML tooling often is at odds with meaningful type annotations. Roughly, you can end up with signatures that indicate that a value is a DataFrame or an ndarray or whatever, but there are a bunch of implicit assumptions on what columns are defined, or what how the shapes of two ndarrays line up, etc. It&#x27;s easy for a codebase to end up paying the upfront cost of providing annotations, but without actually getting an improved ability to reason about or refactor code.
peruvianabout 2 years ago
Python 3 has types and you can use Pydantic for validation.<p><a href="https:&#x2F;&#x2F;docs.pydantic.dev" rel="nofollow">https:&#x2F;&#x2F;docs.pydantic.dev</a>
评论 #34946851 未加载
评论 #34947228 未加载
user3939382about 2 years ago
In the abstract we have Psalm for PHP which I think is likely to eventually get rolled into PHP’s native type system. It’s so robust the major IDEs haven’t fully implemented it yet.<p>It doesn’t turn PHP into Haskell or anything but huge swaths of bugs are eliminated.
nilsbungerabout 2 years ago
Python typing is optional and only checked statically, just like typescript typing. What else would a “Typescript for Python” add?
jasfiabout 2 years ago
If you consider a language besides Python itself (which has optional typing), Nim could be an option, as the syntax is similar.
评论 #34946879 未加载
speedgooseabout 2 years ago
As other mentioned, Python has already some tools around strong typing.<p>However they aren’t as extensive as TypeScript is to JavaScript. The community is also not much into types so you don’t have collections like Definitely Typed.<p>But the need exists and I guess it’s a matter of time until a tool becomes as popular and complete as typescript.
评论 #34947698 未加载
hot_grilabout 2 years ago
JS doesn&#x27;t <i>need</i> TypeScript. When&#x27;s the last time TS saved your JS project from disaster?
评论 #34947579 未加载
findjashuaabout 2 years ago
pyright
otabdeveloper4about 2 years ago
Probably never. Modern Python is a joke, and so are attempts at to typify it like mypy.
评论 #34946993 未加载