Live data from Hacker News

Pyrefly vs. Ty: Comparing Python's two new Rust-based type checkers

blog.edward-li.com

111–120 of 166 posts

Re: Pyrefly vs. Ty: Comparing Python's two new Rust-based type checkers

#111
post #57

[ty developer here] We are happy with the attention that ty is starting to receive, but it's important to call out that both ty and pyrefly are still incomplete! (OP mentions this, but it's worth emphasizing again here.) There are definitely examples cropping up that hit features that are not yet implemented. So when you encounter something where you think what we're doing is daft, please recognize that we might have…

Really loving those markdown style tests. I think it's a really fantastic idea that allows the tests to easily act as documentation too. Can you explain how you came up with this solution? Rust docs code-examples inspired?

[deleted]

Re: Pyrefly vs. Ty: Comparing Python's two new Rust-based type checkers

#112

Earlier quoted context omitted.

Responding to your gradual typing anti-pattern bit: Agree that dynamic language behaviors can be extreme but it’s also easy to get into crazy type land. Putting aside a discussion of type systems, teams can always add runtime checks like pydantic to ensure your types match reality. Sorbet (Ruby typechecker) does this where it introduces a runtime checks on signatures. Similarly in ts, we have zod.

> teams can always add runtime checks like pydantic to ensure your types match reality. That's the problem with bugs though, there's always something that could have been done to avoid it =) Pydantic works great in specific places, like validating user supplied data, but runtime checks as a replacement for static type checkers are not really feasible. Every caller would need to check that the function is being called…

To be clear, I myself prefer sound type systems.

But the reality is that teams have started with untyped Python, Ruby, and Javascript, have been productive, and now need to gradually add static types to remain productive.

> Every caller would need to check that the function...

The nice part here is where the gradual part comes in. As you are able to type more of your code, you're able to move where you add your runtime validation, and eventually you'll be able to move all validation to the edges of your system.

Re: Pyrefly vs. Ty: Comparing Python's two new Rust-based type checkers

#113
post #62

Astral tooling is great and brings new energy into python land but what is the long game of all astral projects? Integrate them into python natively? Be gone in 5 years and leave unmaintained tooling behind? Rug pull all of us with a subscription?

As a Redditor said:

> The standard VC business model is to invest in stuff that FAANG will buy from them one day. The standard approach is to invest in stuff that's enough of a threat to FAANG that they'll buy it to kill it, but this seems more like they're gambling on an acqui-hire in the future.

Re: Pyrefly vs. Ty: Comparing Python's two new Rust-based type checkers

#114
post #57

[ty developer here] We are happy with the attention that ty is starting to receive, but it's important to call out that both ty and pyrefly are still incomplete! (OP mentions this, but it's worth emphasizing again here.) There are definitely examples cropping up that hit features that are not yet implemented. So when you encounter something where you think what we're doing is daft, please recognize that we might have…

Really loving those markdown style tests. I think it's a really fantastic idea that allows the tests to easily act as documentation too. Can you explain how you came up with this solution? Rust docs code-examples inspired?

I use this in my books to show the output but also to "test" that the code found in my books actually works.

Re: Pyrefly vs. Ty: Comparing Python's two new Rust-based type checkers

#115
post #62

Astral tooling is great and brings new energy into python land but what is the long game of all astral projects? Integrate them into python natively? Be gone in 5 years and leave unmaintained tooling behind? Rug pull all of us with a subscription?

As a Redditor said: > The standard VC business model is to invest in stuff that FAANG will buy from them one day. The standard approach is to invest in stuff that's enough of a threat to FAANG that they'll buy it to kill it, but this seems more like they're gambling on an acqui-hire in the future.

I have never seen a FAANG company buy a pure programming-language based tooling startup.

Re: Pyrefly vs. Ty: Comparing Python's two new Rust-based type checkers

#116
post #60

I am not well versed in python programming, this is just my opinion as an outsider. For anyone interested in using these tools, I suggest reading the following: https://www.reddit.com/r/Python/comments/10zdidm/why_type_hi... That post should probably be taken lightly, but I think that the goal there is to understand that even with the best typing tools, you will have troubles, unless you start by establishing good pr…

> Python, AFAIK, has many features, a very permissive runtime, and perhaps (not unlike C++) only some limited subset should be used at any time to ensure that the code is manageable. Unfortunately, that subset is probably different depending on who you ask, and what you aim to do. I'll get started on the subset of Python that I personally do not wish to use in my own codebase: meta classes, descriptors, callable obje…

You should try Go!

Re: Pyrefly vs. Ty: Comparing Python's two new Rust-based type checkers

#117
post #57

[ty developer here] We are happy with the attention that ty is starting to receive, but it's important to call out that both ty and pyrefly are still incomplete! (OP mentions this, but it's worth emphasizing again here.) There are definitely examples cropping up that hit features that are not yet implemented. So when you encounter something where you think what we're doing is daft, please recognize that we might have…

Really loving those markdown style tests. I think it's a really fantastic idea that allows the tests to easily act as documentation too. Can you explain how you came up with this solution? Rust docs code-examples inspired?

I love doctest as it works so well with a REPL but unfortunately it hasn't really gained traction anywhere I've seen.

Re: Pyrefly vs. Ty: Comparing Python's two new Rust-based type checkers

#119
post #68
post #67

Earlier quoted context omitted.

Unfortunately with us being in the middle of the AI hype cycle, everyone and their dog is currently busy migrating to python.

I don't see why AI hype means more Python code. State of the art AI models are all closed source and accessible through an API anyways. APIs that any language can easily access. AAa for AI model development in itself, yes it's mostly Pyython, but niche.

Because everyone and their dog thinks they need to be ready to develop their own models, in python.

This is honestly a thing, at least in the startup world.

Re: Pyrefly vs. Ty: Comparing Python's two new Rust-based type checkers

#120

> my_list = [1, 2, 3] > pyrefly, mypy, and pyright all assume that my_list.append("foo") is a typing error, even though it is technically allowed (Python collections can have multiple types of objects!) > If this is the intended behavior, ty is the only checker that implicitly allows this without requiring additional explicit typing on my_list. EDIT: I didn't intend my comment to be this sharp, I am actually rooting…

> I am strongly against ty behaviour here. [ty developer here] Please note that ty is not complete! In this particular example, we are tripped up because ty does not do anything clever to infer the type of a list literal. We just infer `list[Unknown]` as a placeholder, regardless of what elements are present. `Unknown` is a gradual type (just like `Any`), and so the `append` call succeeds because every type is assign…

So, how does that relate to this quote from the article?

  >ty, on the other hand, follows a different mantra: the gradual guarantee. The principal idea is that in a well-typed program, removing a type annotation should not cause a type error. In other words: you shouldn’t need to add new types to working code to resolve type errors.
It seems like `ty`'s current behaviour is compatible with this, but changing it won't (unless it will just be impossible to type a list of different types).
Post reply on HN