David.dev 🎪

about ~ apps

Jan. 11, 2020, 1:32 a.m. django, python

Migrated to Django!

After flirting for a long time with different web-framework solutions for my humble website (and other hobby projects) I decided to move this blog from NodeJS to Python, more precisely to Django.

Why ? Well it is said that among the rules of programming there is "never rewrite something that works fine" and truth to be told all worked fine in my home-made minimalistic CMS using Polka and just the bare essential NPM packages (like MySQL).

So why move to a "battery included" opinionated framework like Django ? May be I am a bit nostalgic or may be the Django project I finished during the Christmas holidays revealed that, sometimes, opinionated is fine. Or even better.

A mature framework like Django present several advantages, for instance:

  1. Security: which is essential today. Not all is set out of the box with Django either but a lot of security features are available out of the box e.g. password encryptions, CSRF, SQL Injection and more ;
  2. Admin: out of the box you get an admin panel for users management and edit any of your data from your models
  3. ORM: this is a downside for many and you certainly learn more by writing your own queries BUT ..sometimes things just need to work well and the Django ORM works very well.
  4. Templating: Django has a good template engine out of the box.
  5. Python Syntax: I really ended up liking it a lot. No more nested {} and not as verbose and beginner friendly
  6. Structure and best practices out of the box
  7. Synch is good: this might sound crazy now that Django 3 has Asynchronous support but my brain works very well with synchronous systems. I am not building something with millions or thousands of concurrent users, so is not that relevant to me.

I also can't deny that not having to deal with so many NPM packages is a great relief. Sure, Django has packages too, but not with the same level of obfuscation in NodeJS projects (which is not necessarily a bad thing but makes it a bit confusing to me).

Another truth is that using an high level framework like Django -- where a lot of stuff is abstracted for you -- made me more efficient. I could finally finish a project from A to Z without having to ask around on stack overflow -- or worse get someone else to fix my code (which is never a good idea unless you understand what is going on. In my experience even genius programmers are terrible at explaining to others what they just did).

So in a "new year resolution" style I plan to spend more time focusing on Python and Django. Whilst it is very interesting to sample different technologies, time is limited and is lieu of knowing a little bit of many languages/systems I will try to focus on one. This is of course the perspective of sometime coding on a non-professional capacity (but, being an entrepreneur, in constant touch with professional). For a professional it probably makes sense to learn and focus on a) what the market wants and b) the right tool for the job.

This said, I believe that a lot of web development today has been over-complicated just for the sake of it. A CSS/JS framework in a Django template does very well so I don't see the need to transform everything in an API (a huge trend nowadays).