-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Type annotations? #50
Comments
Hi, and thanks for the kind proposal! We’re not fond of type annotations for many reasons that would be too long to discuss here 😄, that’s why we don’t have them in Pyphen (and in other projects maintained by CourtBouillon). But, well, maybe one day, at least for "small" libraries like Pyphen. That’s a topic for discussion, because they’re becoming popular as you notice, that’s why we often take a lot of time to answer this kind of issues! But it’s not the moment (yet?) for us. I’m closing this issue, because there’s nothing to yet! |
Thanks for the well-considered reply 👍 . Interesting to hear that this is a conscious choice. I can imagine reasons for this, but I'd of course be interested in your considerations 👀 . Publishing this rationale may prevent this type of question from occurring in the future. Feel free to close the issue as the question has been answered. |
Why not! First of all, I’m not trying to convince anyone that type annotations are "bad", and I don’t want to be convinced that they are "good". I find them somehow useful, but I also find them quite annoying. That’s only my personal point of view. I’ve been working for some time on a quite big project with 100% type annotations, and I’ve found them really interesting and intellectually challenging. That’s a great exercice to really think about the type of your parameters, it forces to take care of corner cases and to be sure about what you can and can’t do with your functions. I’ve spent a lot of time carefully defining types and see mypy give me 100% coverage, and each time it was great reward! But, even if it’s rewarding, let’s face it: I don’t find them really useful in Python. When I write code with statically typed languages, checks at compilation time can give me some confidence with my code. The best language I’ve tested for this is Rust: it can take a lot of time before my code compiles, but when it does I can be almost sure that it does what I want. I then have the impression that the large amount of time I’ve spent defining types and ownership is very useful for the quality of the code I write. I have the impression that adding type annotations in Python takes time, but that it’ll never give me the confidence that types give me in other statically typed languages. If I want to carefully think about types, then I prefer to write Rust! The compiler is amazingly powerful, and it is by design. To be honest, I often don’t want to carefully think about the types I use. I’m soooo lazy. For sure, it’s really easy to write code that doesn’t work with Python. But it’s also really easy write code that works. 💜 That’s what I love 💜. It will never be as clean, as solid, as "right" as Rust, but it’s damn easier, faster and shorter, at least for me! And I can always write tests to check that I didn’t break anything. Moreover, adding type annotations adds code. And I love when code is short, because I find it easier to read and to maintain. I think that finding "good" variable names is important because it increases readability, for example when reading the signature of a function. When there are type annotations, I really lose the ability to understand what the code does, because I have the feeling that types tell me how the code works. In the future, I may be interested to add type annotations in projects that I know very well, if they’re small enough to fit entirely in my head. But my head is really, really limited! TL;DR: Let’s say that I prefer when code is short and simple than extensive and exact. |
Hi there, it seems like the use of type annotations is becoming ever more popular in the community. Is there any reason Pyphen doesn't have them? I'd be happy to submit a PR 🙂
The text was updated successfully, but these errors were encountered: