Explaining the popularity of Python (a bit)
As a primarily Windows based developer I've really kind of struggled in the past to figure out why Python is so popular. But, I think I cracked at least a piece of the puzzle with one of my recent side projects. Especially when I put it through the lens of how Microsoft has been transforming .Net. In fact, I would say that most of the recent .Net changes appear to be things which they are borrowing from Python.
For instance, with .Net Core the NuGet package manner became part of the dotnet CLI tooling. This reminds me a lot of how pip is used in Python (and how npm is used within Node.js development). Basically, you have your biggest repository of 3rd party libraries treated as a first class citizen. And this makes it extremely easy to find, install and manage most projects. Very few projects have absolutely no 3rd party dependencies. And needing to install everything to manage that alongside the runtime/SDK just adds an extra step. This ease is a pretty compelling case.
Next, the minimum code required to write an app is insanely small. Again, with .Net 6 you can see Microsoft doing the same thing with the .Net suite of languages. For a lot of smaller projects it is nice to have less boilerplate code to deal with. And Python is much more minimalistic here than a lot of competing languages.
The dotnet CLI's restore command also does the same basic job as the commonly used requirements.txt file does in Python. Another huge benefit in getting an environment up and running across devices. This is maybe less new... but, it is hard to argue that it makes life better.
For the longest time I probably struggled the most with how to RUN a python app. Afterall, Python doesn't compile into an exe out of the box. On Linux this isn't an issue as Python has long been effectively a first class scripting language and it is frequently used for those sorts of tasks. But, when you needed a UI or a Windows app it became a bit harder to understand.
But, as the world shifts toward web based and containerization those problems start disappearing real fast. The first major change I made when I jumped back into this side project was to switch all code away from native UI and switch to a Flask app instead and get the containerization up and running. With that, I have a UI and I can even decide if I want it exposed externally or just available on my internal network.
Beyond that, I think it is just a matter of where the community has been focused. My side project used computer vision and Python had the best resources at the time. And perhaps still does. And that historical focus on scripted tasks has meant that the language has amazing support for the sorts of things I want to do in the future with this project like sending emails, connecting with MQTT and other tasks like that.
While it isn't to say that I can't do these things in .Net or another language, it would actually be quite a bit more code outside of Python. Where there isn't a critical dependency on Python and the project is a lot better I think that I would still prefer .Net for application or some sort of Node.js framework for a larger web based UI project. But, for any project with a small enough scope I think it is quite hard to beat Python.
Comments
Post a Comment