3 ms·
This is sort of speculation on my part: The fact that static typing PEPs can't easily introduce syntactic changes to the language (I don't think there has been
by davidatbu 4y ago
This is sort of speculation on my part: The fact that static typing PEPs can't easily introduce syntactic changes to the language (I don't think there has been a syntactic change introduced because of static typing ever since Python 3.5) will really hold back Python's static typing from being ergonomic at least, and "fully capable" at the worst.
I think that limitation of statically typed Python alone is enough to give this new language a chance.
It's also looks like the type inference of erg will be better than the current Python checkers.
- frou_dh 4y agoI was just playing around with Python 3.10 for the first time today. I made an algebraic/sum-type (dataclasses + typing.Union), then did some structural pattern matching on a value of that type (match statement), and Mypy could tell me statically when the pattern matching wasn't exhaustive! I think it's pretty damn amazing how well Python has been able to evolve into the realm of static typing. And no unofficial superset syntax required!
- davidatbu 4y agoThat's wonderful to hear! It's been > 1 year since I used daily-drove Python, so my comments do lag behind the progress by at least a year. Maybe an unofficial superset syntax is indeed not required!!
- svetb 4y agoMypy can work really well in many cases, but we seem to get bitten by bugs on a daily/weekly basis. There are >1,000 currently open on Github [0], so it doesn't take much effort to hit one. And having the type-checker tell you that something's not valid when it actually is is a real turn-off...means that we end up with code that's riddled with "# type: ignore", which kind of defeats the point. Pylance (the VSCode built-in linter, based on Pyright I believe) tends to do a better job than Mypy, but not as easy to integrate into CI. It's a real shame that the Python ecosystem doesn't have anything nearly as robust as TypeScript. [0] https://github.com/python/mypy/issues?q=is%3Aopen+is%3Aissue+label%3Abug https://github.com/python/mypy/issues?q=is%3Aopen+is%3Aissue...
- gilch 4y agoMypy still couldn't handle recursive types, last I checked. Pyright can do it, but seems to have trouble with even basic type inference. The annotation syntax is working OK, although it tends a bit verbose, but the type checkers are still crippled IMHO.
- LtWorf 4y agoThe fact that it's written in js, probably not by python developers makes me distrust it. Anyway I tried it on a mypy clean codebase and it gave a gazillion false positives so I never bothered to integrate it more properly.
- davidatbu 4y agoI absolutely feel comfortable vouching for Pyright! Last I used it, it was miles ahead of mypy in terms of speed, easy-of-use (it's an LSP!), correctness (simply has less bugs), and feature completeness (has implemented every new static typing feature that I've wanted to use months ahead of mypy). The maintainer was also super-responsive on Github: replied to my issues in hours/minutes, and often released minor versions with bugfixes one or two days after issues are reported.
- aslilac 4y agoI’ll also vouch for it. Plus, at least half a dozen highly funded people have tried to recreate TypeScript and have failed. Microsoft is flawed, but they can make a mean type checker.
- int_19h 4y agoMost recently, Python 3.11 changed syntax to allow for variadic generics: https://peps.python.org/pep-0646/#grammar-changes https://peps.python.org/pep-0646/#grammar-changes The other case that I remember off the top of my head is Python 3.6 adding annotations for variables that aren't created via function definitions: https://peps.python.org/pep-0526/ https://peps.python.org/pep-0526/
- davidatbu 4y agoI actually meant to refer to PEP 526 when I said "python 3.5", thanks for that correction! Also thanks about pointing out the syntax change for variadic generics! I still think my overall point about pace of "syntactic innovation" in static typing remaining slow stands, though. Just comparing equivalent typescript and python constructs: This in TS: { member?: string, other_member: string } is currently in python: from typing import TypedDict class SmallerObj(TypedDict, total=False): member: str class Obj(SmallerObj): other_member: str Python 3.11 will shorten the above to: from typing import TypedDict, NotRequired class Obj(TypedDict): member: NotRequired[str] other_member: str But still ...