4 ms·
I (mostly) like when programming languages allow you to express ideas with dedicated syntax. It (usually) is more clear and concise. Even if I don't use all the
by blindseer 6y ago
I (mostly) like when programming languages allow you to express ideas with dedicated syntax. It (usually) is more clear and concise. Even if I don't use all the syntactic sugar in a language, I often find myself wanting to use a significant number of these features.
However, this brings me to my biggest gripe with the Python ecosystem. For better or for worse, Python is used EVERYWHERE. And, to make matters worse, standard tooling that manages dependencies and versions of Python is a complete mess.
Just in the last couple of months I've written Python packages for applications embed a Python 3.3 interpreter. And I still work with code that runs only in Python 2.6 (working with hardware). In these projects, I can't use these new "features" even if I wanted to.
The tenet of my comment is this:
I really wish there was a standard source to source transpiler that helped in converting Python 3.x code to Python (2|3).(y).
Almost all the features I'm envious of either have a way to be represented in older languages more verbosely (f-strings, :=) or don't need to be in the source on the user end (type hinting, dataclasses, keyword only arguments). I know there's not a one to one mapping here, but even a best effort would go a long way to helping adoption of these new features. I don't see the Python folks slowing down when adding new features to the language.
I really wish I could use these features today but I know I can't. I also hesitate sometimes when I'm making a package open source because I'm worried someone else might want to use my code in an older version of Python and won't be able to because I wanted some syntactic sugar (I've even received PRs on project to revert some changes), and I now actively choose not to use these features against my desires. Larry Hastings may have said farewell to Python 3.5 but lord knows when I will be able to do the same.
Is this just me? How many people use `:=` or `@dataclass` or `|` for dict merges in their code today?
- lpellis 6y agoI didn't even know about | for dict merges, that's pretty cool. But I feel the same, even in my private code I'm a bit hesitant to use :=, and any pip installable packages I almost feel obligated to write in more compatible ways. Not sure what the solution is really.
- iddan 6y agoJavaScript figured it out: always compile as low as you possibly can and expose more modern modules if needed
- srtjstjsj 6y agoIsn't that what .pyc bytecode is for? So you don't need to interpret the source of a library?
- PhineasRex 6y agoI used @dataclass in almost every python project I work on. It's one of the most valuable additions to the language I can think of.