First was the ignorance
At university, I’ve learned a bit of C, C++, Java, PLSQL, Smalltalk and more. There were no mean to learn yet another programming language. I was much more interested in understanding higher level concepts (UML, Merise, design patterns, etc.).
During my studies and at the very start of my career; I’ve mainly worked in PHP and I’ve learnt Symfony 1 about six years ago. I’ve never liked the PHP language itself but Symfony 1 is a great web framework and PHP has been getting better and better.
I did learn a lot while working with Symfony 1. About 3 years ago, we’ve started to use Symfony 2 as early adopters and despite its great architecture; I didn’t enjoy the transition at all.
Getting started with Django/Python
After considering Ruby On Rails and Play2; I’ve decided to try out Django on a small project. I wasn’t that impressed at first:
A Django application starts as an almost blank project:
- There is no environment settings (just a big ugly settings.py file)
- There is no lambda example of a view and template (respectively called controller and view in the rest of the World)
Python can be “tricky”
importmight lead to hard to fix bugs
- Python dictionaries aren’t ordered
- Last but not least: “Default parameter values”
Once I’ve figured out how to set-up my projects the way I wanted and had a better understanding of the Python concepts, I was rolling out tests and code faster than ever before. Almost four years later, I’m enjoying it more and more and wouldn’t go back to PHP, Java etc. unless forced to (for financial reasons…). The tricky points I have mentioned before are the main ones I have found so far… I’m not saying that Python is perfect but let put it this way:
I’ve built my very first website about fifteen years ago and Python is the only piece of technology I’ve ever trolled about.
What makes Python awesome?
- At first glance: the syntax is the best out there
- Both Unit and Functional tests are easy to write
- Built-in and external libraries are awesome. Reading a JSon, reading an Excel file, finding a file on the File System are all super easy tasks in Python. One of the reason is that all its built-in libraries are consistent
It’s really easy to install packages and manage dependencies via PIP. When you start a second project, you might want a separate configuration, well, the virtual environments are easy to set-up as well !
- Tiny (but problematic) entry barrier - especially for frontenders (compared to PHP and JS)
- Not a lot of jobs - (an expertise in a niche can however be an advantage)
- A touch of elitism. In other words, a few unreasonable fan boys with super strong opinions
What about PHP?
PHP has unfortunately many flaws, this article is an excellent sum-up: PHP, a fractal of bad design. And to keep this article balanced, here is a response from Symfony creator, Fabien Potencier: PHP is much better than you think.
In my opinion, the syntax is the main reason to love Python. The syntax is indeed extremely important when coding is your work. Developers are spending hours every day reading and writing code. Reducing the size of the code they have to produce and maintain has therefore a huge impact on their happiness and productivity.
Why is Python not more popular then?
In my opinion, Python has a relatively small user-base because:
1.Not taught at university => not used in companies => not taught at university => …
It’s our role as IT professionals to advise the best technologies to use. Customers would not usually require you to use a specific programming language, web framework, etc.
2.It’s expensive and risky to train the developers
Sure but it’ll be shortly profitable. More importantly, it took me less time to be productive with Django/Python than with Symfony2/PHP even though I had no previous experience whatsoever in Python. If you’re OK with your developers learning a new framework, you should be OK to let them learn a new programming language as well.
3.There are less hosting solutions available
There is plenty of hosting solutions available for Python. Of course, there are more options for PHP but it does not matter. You only need one hosting platform !
4.Python is too slow
Python clearly is not the fastest programming language out there but its speed should not be a problem. If a part of your application needs to be as fast as possible, you can link up Python with C++ and keep the simplicity of Python for 99% of your application.
PHP is not a language for beginners. PHP is a really permissive language, it’s therefore a language for experts. It’s also extremely easy to deploy some PHP code to production. This is the reason why it attracts total beginners as well. This large community of developers going from people learning coding via Wordpress to the engineers working at Facebook remains its main strength.