For the first time ever, I attended the Python Software Foundation’s PyCon Conference in Cleveland, USA. I was nothing short of impressed, a great variety of talks and keynotes and very friendly people. I consider myself an intermediate python developer, but the talks were suitable for all knowledge levels. The goal of this post is to share what I learned speaking with other programmers and their experience with the language and its most popular frameworks.
Everybody loves Python
That’s a bit obvious at a Python conference, however, I’ve never seen so many people agreeing on the direction the language is taking. Maybe it’s a sample bias. Even people who do other languages professionally would be happy to move to Python. At the end of the conference there was a chat with Python’s creator, Guido van Rossum. Who when asked, why did you build the language in 1991. Replied something along the lines – “I didn’t like any of the programming languages at the time, so I built my own”. Well, the simplicity he introduced in coding was a revolution, it’s almost writing english. Obviously, the language’s success is a result of multiple factors. To the main point, I didn’t meet a single person complaining about the language, but mostly that they need more time to learn the new cool frameworks.
The world runs on Django
I haven’t used Django beyond the Hello World initial start up. However, it was possibly the second most used word throughout the week, followed by asyncIO. Novice users were quite happy with it, but advanced users had plenty of complaints. I couldn’t participate in much of the discussions, but one thing was clear. That technology is here to stay, so I better look more into it.
GraphQL is the next cool thing
What GraphQL is in a nutshell is a unifying layer of different data stores and their types. You don’t have to know SQL to query the database or learn another REST API and how to query that endpoint. You write the same syntax and it abstracts the front end from the back-end data storage. This sounds great, especially if you have a lot of legacy systems and fragmented data stores. It has data efficiency in mind, which is great for mobile applications. The main library to build on top of Flask API is called Graphene. Everyone is looking forward to trying it out. The people I spoke with, who were using it in their work, said it’s still quite new and not really real-life production ready. You would still face problems that were solved in other systems 10-15 years ago, but are yet to be solved for this one. Ironically, not a single one of them recommended me to use it in its current state.
The N+1 Problem
This was raised in a Q&A as GraphQL apparently isn’t handling the N+1 problem. It pertains to the querying of objects when you have a one to many relationship. For example, imagine you have a table of authors and a table of books. The author to books is the one to many relationship. If you want to get the lastest 10 books across all authors, you have two options: Query the authors table to get their names (1 query) and then for each resulting author fetch their books (N queries), which would have worse performance than just querying the books table directly (1). Most databases handle this issue, but not all systems. When we then look into issue when it comes to REST API calls, the performance deterioration can be significant. To illustrate how fast it exacerbates, if you have very nested objects – imagine the just explained example, but if you had to query all pages with author to book to pages relationship.
AsyncIO makes asynchronous development tolerable
Writing and troubleshooting asynchronous code is far from straightforward in most languages. The ones that have somewhat improved the development envorinment for it are Node.JS and Python. I attended maybe 2 or 3 talks on it, trurth be told, it looks quite straightfroward, but to be able to play with it, your Python version needs to be greater than 3.3. The official documentation is available here. It offers the inbuilt async/await keywords to simplify making async code synchronous via futures and promises. Its latest version even abstracts you away from its event loop. Other lessons included, if you want safe concurrency – decouple your code, don’t share data across threads and use message queues.
Python2.7 is still around
That’s also obvious, but as support is to end on 1 Jan 2020. A lot of people are trying to find time to move their legacy codebase to Python 3. On the question “How many of the attendees worked with Python 2.7 in the past month”, the result was around a third.
Everyone wants type safety
Python 3 intruduced Type Hinting. The two main competing tools are “MyPy” and “Pyre”. The syntax is very similar to current Swift and TypeScript. Together with docstrings, it makes Python even more self-documenting. I recently started working with MyPy. It is straight-forward, but going back and annotating all your old functions is quite boring, but no doubt it’s the way forward. It somehow provides the feeling of being a more mature language.
Instagram deploys their application every 7 minutes
That is impressive. I attended a talk where they were discussing race conditions in their deployments, as they said they deploy something like 100 commits a day. Part of me still thinks, that’s a bit too much and unnecessary. They reiterated they have one large monolith with over a 1000 django endpoints rather than plenty of microservices. This somewhat justifies it, but why not just start breaking that monolith apart. I had quite a few more questions, but didn’t have time to ask them. What resonated with me was a quote they shared that guided their development process – “Do the simplest possible thing that will make it work. When it breaks, do the next simplest possible thing that will get it working again.”
I don’t know of another language that overuses decorators. Everyone I spoke with prefers decorators over inheritance. There was a talk that explained the situtation around the lack of transparency when you overdecorate and you don’t know how deep the code goes and how much performance hit you are getting. The talk is available here on YouTube.
Visual Studio Code Remote Development Preview
On the 1st day of the conference, Microsoft announced the new extenstions for Visual Studio where you can work inside a Docker Container or directly on a remote machine. They offered workshops to try the new feature out. It looked promising, despite still in preview. Quite looking forward to the workflow improvements it will bring.
All the talks are available on the conference’s YouTube page.
They are definitely of high quality and show the state of Python in 2019.
The ones that stood out to me are:
- Paul Ganssle – Dealing with Datetimes
- Amanda Sopkin – The Refactoring Balance
- Hannah Stepanek – Thinking like a Panda