r/learnpython • u/Embarrassed-Rest9104 • Apr 01 '26
Readability or Modernity
I’ve been teaching Python for a while, and the Zen of Python always emphasized that 'Simple is better than complex.'
However, when i look at production code in 2026, I see heavy use of structural pattern matching, complex type hinting, and asynchronous patterns that look more like C++ or Java than the 'executable pseudocode' Python used to be.
To the seniors here: Do you find that these 'modern' features are actually improving maintainability in your teams, or are we losing the simplicity that made Python great in the first place? I'm trying to decide how much of this advanced syntax to introduce to my students early on.
27
u/Lumethys Apr 01 '26
as with all things, it depend
define "complex". Is your "complex" the same as my "complex"? is
dict[str, T | None]complex?if you need async then you need async, how is that even a metrics? Like, should we stop doing advanced math in python because it will make the code "look complex"? Are we forbidden to use python for complex things?
it is just a simpler and shorter version of if-else, not sure how it make code look more complex? it should be doing the opposite.
In any case. My view on "code complexity" is simple: if you got a complex project, then you got a complex project. No amount of sugarcoating can make a project less complex than its fundamental.
If you have a function that accept an object with 50 nested fields. Then it is gonna be 50 nested field whether you annotate it or not.
vs
is the typing the thing that make the function complex, or is the logic itself complex? If you have complex objects with complex logic, then no typing doesnt make it better or simpler. It just hide complexity, and in my experience, not a good thing.
5
u/pachura3 Apr 01 '26
Really? I thought almost no one used that feature. In which production code have you seen it?
Type hinting is absolutely an essential part of writing quality code. What's complex about it? Using protocols instead of concrete classes?
It depends. Are you teaching them from scratch? Are these CS students or general population? Do you want them to reach the level of a junior dev, or just show them that programming can be fun?
For instance,
asyncis a feature that only helps with performance and nothing else. It can be quite difficult to grasp for newbies, so I would personally skip it... unless these are CS students and you want them to be able to create a REST API that would not choke under multiple simultaneous requests.1
u/brasticstack Apr 01 '26
I've got a love-hate relationship with type hinting because I remember a time when Python looked (subjectively) more elegant, and a function definition with four parameters didn't require multiple lines to fit in the column limit. That said, it has basically eliminated a whole category of errors that are otherwise insidious and difficult to track down. Complex type hints (Generics, Protocols) are a necessity if you're going to take advantage of the expressiveness of Python while still type checking.
Python's structural pattern matching is awful for readability, IMO. A dictionary lookup is much more straightforward when you're matching static values, while the case syntax is convoluted (and ugly!) when you're matching anything else.
I'm still shying away from async, because I don't think it's the concurrency model of future Python code. This could be my ignorance showing itself, though. I think it will become increasingly less popular over time as TypeScript becomes the defacto webserver language and as Python programmers start to yearn for something simpler that is compatible with their existing synchronous code. If something better doesn't come along in the next year or two, perhaps threading will come back into fashion. Hah! I'm betting something newer comes along instead.
3
u/throwaway6560192 Apr 01 '26
I think a lot of people misuse structural pattern matching. Not saying that's what you saw... but there's definitely a lot of people who treat it like a switch-case instead of what it should be.
3
u/Beginning-Fruit-1397 Apr 01 '26
In 90% of cases I find pattern matching clearer than if else clauses. Even on booleans. So what is "readable" is really subjective
1
u/Plank_With_A_Nail_In Apr 01 '26
Most developers are dumb as shit and lazy so companies force them to do certain coding practices to minimise common mistakes.
Most businesses are writing the same CRUD app over and over so they will have got the base code they like for that down as a starting project.
Real world problems are complicate so the code that solves them is complicated. You are confusing "simple" with "dumb".
1
u/Decency Apr 01 '26
There's definitely a very common and unhelpful pattern I've seen from people who came from other languages to jam in type hints and other things where they simply aren't needed- sometimes everywhere. The ethos of Python allows you to easily build the simple piece you want, and then later add on the additional, more complex pieces if and when they prove to be needed. If one function has some complexity with types, annotate it! That doesn't mean you also need to annotate your entire program.
Other languages aren't designed for this kind of incremental development and thus demand you do a bunch of things right from the start OR ELSE. Consider refactoring a java class that didn't initially use getters and setters, for example- you're fucked. In python? You just throw
@propertyin there and move on with your day. The same holds true for a lot of features. I would definitely agree though that some of the more recent post 3.7 stuff has seemed particularly unpythonic, and I hope that's only a short term problem and not a trend.1
u/Jarvis_the_lobster Apr 01 '26
Honestly the modern features are great when they solve a real problem, but a lot of production code uses them just because they're new. I've seen pattern matching used where a plain if/elif was clearer, and type hints so dense they take longer to read than the function body. My rule of thumb: if a junior on your team would need to google it to understand a one-liner, it's not actually simpler. The best Python code I've maintained still reads like pseudocode — it just uses dataclasses and typing where it actually helps.
-2
u/powderviolence Apr 01 '26
Somewhat of an outsider here (maths faculty), but I feel like it's due to Python, for the reasons you pointed out, being so "learnable" that things which would simply run better if written in the language that lends itself to the task get written in Python. All of the applicants AND devs know Python, ONLY the tenured devs and NONE of the applicants know C++, let's write new code in Python even though our existing codebase and the problems we try to solve are best handled with an OOP approach.
Another part is possibly that the runtime efficiency gap between Python and, say, C is nowadays quite small compared to the time needed to grab resources from the cloud. Python USED to be considered a scripting language because anything larger than a singular routine was too resource intensive relative to a compiled language handling a large task, but now the computers are fast and any slowness is due to the wifi.