Django vs Phoenix

I’ve been working with Django since version 0.9x. So for quite some time now.

There are several things I really like about Django:

  • Excellent documentation. All in one place, nice tutorials, nice examples.
  • Many useful features included, like Sitemap generation, CORS, authentication & authorization, etc
  • A very powerful admin interface which is most often good enough for basic administration tasks

The downside is that concurrency related tasks are very hard to do and requires workarounds like job-queues etc.

Especially the concurrency issues are what brought me to Elixir. And so far I am pretty happy with Elixir/Phoenix. For me the most noteable differences where:

  • The documentation in the Elixir world feels cluttered. Like, lots of packages and you have to jump between packages all the time. Even worse I often wondered why the documentation doesn’t mention feature X until I figured out that I had to look at package X by myself. Take ecto and ecto.migrations for example.
  • Phoenix does a really bad job in terms of self marketing imho. Compare the Django site and then Phoenix. I feel Django does a much better job at explaining why Django is great, getting started tutorials, highlighting its features, etc. In that regard Phoenix indeed feels more like Flask.
  • I feel that Ecto is a bit more low-level compared to Django’s ORM. But I actually like this because it allows me to better facilitate PostgreSQL’s features.
  • The directory layout in Phoenix still feels weird to me, like the difference between :app and :app_web. I rather prefer Django’s app approach, which are fully contained including views, templates, url mappings, etc.
  • One thing I really miss from Django is the admin feature. In countless projects it was a huge time saver.
7 Likes

I’ve been feeling this as well. Each library’s doc taken individually is great, but when trying to add a metric for available DB connections, I had to search in Ecto, Ecto SQL, Postgrex, DBConnection, Telemetry, Telemetry Metrics, Telemetry Poller, and Telemetry Statsd. I wonder if it would make sense to generate a “global” searchable help based on the current app’s dependencies or something…

(In the end, I didn’t find a supported way to get the number of available DB connections)

4 Likes

My impression in the majority of the responses is that Phoenix is great but not better than Django. Please help me decide where to focus on, vote if you will Phoenix or Django?

Why would you base your decision on some votes by random people? And I wonder what result you think you’ll get, considering this is an Elixir forum?

Spend some time to evaluate both frameworks and pick the one you are most comfortable with.

4 Likes

@egze I think most people can’t be wrong.

I haven’t read the posts in any great detail but I can tell you that Elixir/Phoenix users are confident enough in their choice to use it that we are not afraid to highlight the positives of other languages/frameworks :smiley:

Personally I think Phoenix is the best web framework out there and I think the opening chapters in the Phoenix book really do an amazing job of explaining why. Check out this post:

Also see this thread:

Hope that helps, and at the end of the day, just use what makes you happy or what you think is best for your project - pretty much what I think most people in this thread are likely saying :023:

5 Likes

@AstonJ thanks a lot you are always helpful, and yes Elixir/Phoenix community is the best! I think I will concentrate on Elixir, Phoenix, and Ecto. Django will be second.

1 Like

Like I said before, the django admin can be huge time saver. On the other hand if you need to deal with concurrency or background tasks then Phoenix will be so much nicer to work with.

Also after working with Elixir and its functional nature it’s kinda tricky to go back to mutable classes. It’s really so easy to reason about your code in Elixir which helps tracking down bugs.

If you need dynamic or live-upating HTML views then Phoenix live view is also a very nice feature. Sure, it can be done with javascript + websockets, but there’s way more complexity involved!

And finally working with GraphQL is amazing in Elixir - especially in combination with subscriptions. In Django we had very bad experiences, like huge perfomance drops once the datasets reached a certain size. Absinthe (the GraphQL library for Elixir) on the other hand was very fast and stable, even with complex workloads. It also outperformed Apollo (a node.js implementation) in our tests on complex workloads (deep trees).

6 Likes

Based on what definition of “fast”? What benchmarks are you basing this on?

2 Likes

I’m curious too. I consistently see flask benching as one of the slowest python web frameworks, even slower than ror.

1 Like

Don’t listen to me. I saw flask, thought python, and in my head was thinking about japronto.

1 Like

japronto is actually very fast for python yeah. ^.^

Web browsers aren’t implemented with JavaScript - but only “scripted” with it.

japronto

The server is written in hand tweaked C trying to take advantage of modern CPUs. It relies on picohttpparser for header & chunked-encoding parsing while uvloop provides asynchronous I/O. It also tries to save up on system calls by combining writes together when possible.

Sounds like this thing is implemented in C and scripted with Python.

So any Python code it has to execute (or wait for) is only going to slow it down. :003:


A million requests per second with Python

3 Likes

Yep, that is the point of japronto, it is trying to minimize the overall python code. Still pretty easy to use though (not that I’ve created any new python web server in about 5 years now). :slight_smile:

Hi, I’m an django dev whose just crossing into the elixir world. One the things I’m missing is an admin interface, which in django comes out of the box. I see there have been projects such as ExAdmin/Talon, but what are the currently top admin tools for elixir that are still maintained and ready for production use?

1 Like

Maybe torch: https://github.com/danielberkompas/torch

2 Likes

Torch looks awesome, nice interface and self generating admin what more do you need!

Is it Christmas!

Thanks very much for sharing @mythicalprogrammer

1 Like

I’ve used Django a lot, largely because of the tight coupling between the ORM, validation, and frontend rendering.

How would you all recommend someone new to Phoenix and Elixir get a similar feel and productivity level? I’m willing to write code, but I’d rather not write all the code. In reading it and going through a small workshop of Phoenix and LiveView, there are really cool pieces. However, I also feel like I’ll need to write a lot of features/pieces that the tight build the ORM and Django give me out of the box. Any libs and recommendations on how to accomplish the same sort of flow?

Welcome :023:

I’m not too familiar with the current state of Django (when I looked at it when I was deciding between it and Ruby/Rails its main advantage in my view was its built in admin panel) however with regards to the ORM we have Ecto, which is pretty fantastic :003:

I wrote some of my thoughts about Ecto in my review of the Programming Ecto (Pragprog) book (it might also give you a glimpse into some of the other benefits of Elixir).

With regards to ACP tools we have some too - though of course not as highly coupled as what you may find in Django: https://hex.pm/packages?search=admin&sort=recent_downloads*

2 Likes

I think this solution is just fine. ^^

1 Like