4 ms·
I have extensive experience working with Python 2, 3, asyncio and gevent so I'll comment on some of the points in this article. Python 2: def hello_world(
by lima 10y ago
I have extensive experience working with Python 2, 3, asyncio and gevent so I'll comment on some of the points in this article.
Python 2:
def hello_world(name):
print 'Hello', name
Python 3:
def hello_world(name):
print('Hello', name)
> The language, which was once simple and elegant, has become complicated and clumsy
Python 3 is just as simple to use as Python 2 (simpler, even due to all the cleanup that happened - just think about the encoding mess in Python 2).
What happened is that new, powerful features got added to Python 3 that solve specific issues that people were having. It's entirely optional to use these, but they make life much easier if you need them.
Async programming is only really applicable to highly concurrent network programming or other applications that spend a lot of time waiting for IO. For everything else it's just unnecessary overhead. It is inherently complicated. In particular, the async/await paradigm is extremely powerful. I first encountered it in C# and immediately fell in love with it, and I'm happy to see major languages like Python and JavaScript adopt it. It makes clear where you hand off control back to the event loop and prevents all sorts of bugs where you'd accidentally block the main thread by invoking blocking IO.
gevent, in comparison, is an ugly workaround that hides all of the complexity behind async programming. By monkey patching all IO libraries to be magically async, it makes it impossible to reason about the execution flow and it's extremely easy to get it wrong. That is an affront to the Zen of Python (Explicit is better than implicit).
Type annotations are just a standardized way to do what large projects were doing anyway - documenting types. By moving it out of the docstrings and formalizing it, it opens the door to strict type checking. The resulting ugliness reflects the difficulty of typing a dynamic language and you only need it if you want strict type. You can write untyped code just fine.
> I'm not even debating the value of type annotations [...] And why do this when there are hundreds of other languages out there that are statically typed?
Do I have to point of the irony?