Django vs Phoenix

phoenix
learning-elixir
#1

Anybody knows a comprehensive comparison of Django and Phoenix, thanks for the help.

  • Where are they similar?
  • Where do they differ the most?
  • When would you use/recommend either?
  • Anything else you’d like to share?
#2

Phoenix should be faster, at least by default, and a better choice for apps that require concurrency; streaming, real-time collaboration, long-running services… However Django is more established, there are a lot of jobs, books and tutorials.

I think Django is more complete by default, and thus it may be overwhelming at first, it may be worth considering alternatives like Flask, but overall both are easy to understand. I’d suggest you to spend a week with both frameworks building the same project (a simple one), and chose the one that makes you more productive.

1 Like
#3

I’ve edited your post to try and follow the format for these kinds of threads - hope you don’t mind :smiley:

2 Likes
#4

Based on my current experiences here is my take. I don’t have a comprehensive guide, but beyond handling web request and mostly following mvc they are not all that similar. Django has models and an ORM phoenix uses schemas with Ecto. Django’s use of “apps” fall in line with using contexts but each django app has it own mvc file structure. Which I have to admit I like. Django is also bloated with features and can serve a very wide range of web projects out of the box. It comes with a ready to go admin. Phoenix is explicit while django is implicit. I applaud both Phoenix/Elixir and Django for the excellent documentation.

Both communities are generally pleasant. Phoenix doesn’t take on user land solutions. For example authentication/authorization. Phoenix leaves the decision up to you, while django comes with it (including password upgrading). The elixir phoenix community hasn’t quite caught up with some of the other popular django apps such as Wagtail and saelor. But it will.

That being said django does not even come close to providing the ease of use when working with realtime. The phoenix team has done an amazing job adding realtime capabilities (my biggest pull to phoenix). With phoenix you also get the benefits with running on the beam. Phoenix has liveview which is very nice. I’ve already seen community members of django, crystal, and laravel implement their own versions. But those will not be as scalable.

Overall my default is elixir/phoenix. It’s fast and enjoyable. There are more than enough community packages to rival django. While “user land” decisions are not made for you by the framework itself, the community has fantastic libraries. The elixir community is full of some really smart experienced people. Pow is a good example of this. The elixir community is very happy to guide you in the right direction. You will not only learn and become a better developer, but you will start to realize those framework abstractions aren’t as hard as they might seem.

All that said, phoenix is probably closer to Flask than Django.

If a client needs cms capabilities, e-commerce or they really can’t be sold on elixir I go with django. Otherwise, elixir and phoenix all the way! Hope that helps.

19 Likes
#5

You already were given excellent answers. My really short version is this:

Do you want to have most of what you need ready-made and able to be put in your project with small initial friction? Go for Django.

Do you want to build part of the required functionality (like authorization and CMS) yourself, while retaining full control on what is going on below the hood? Go for Phoenix.


Have in mind though: apps made with implicit/magic frameworks always come with a high maintenance burden. They allow you to start quicker but you pay off those savings in the future, many times over. A lot of Rails and Django apps are an example of this phenomena.

5 Likes
#6

Thanks @AstonJ, good job!

1 Like
#7

What about libs like Pow? Don’t they remove some of this DIY burden?

#8

There are already pretty good answers here.

Django(advantages in my opinion):

Comes with admin panel which is very good and have an excellent support.
Include it’s own ORM.
Session support is very good.
Each feature will be broken down into smaller apps by default.
third party library support is good.
More jobs.
Django rest framework is very good for building api’s.

Disadvantages:(In my opinion)

Bloated with lot of extra features.
deployment is little difficult.
No dedicated forum as good as this one.
No built in modules like Gen servers to handle jobs processing.

Phoenix:

Excellent:grinning:
Fast
Not bloated
Excellent built in tools for RTC
Genservers are great to have.
Ecto is very good.

But at the end It all comes down to your needs.

You are building e commerece website . Instead of building admin panel from scratch go with Django saves you a lot of time.

You are building app with lot of background job processing and real time communication go with phoenix.

Hope this helps…

3 Likes
#9

FYI: There is a Python by O’Reilly Humble Book Bundle for the next 5 days.

3 Likes
#10

Lots of great points in this thread!

If you’re set on Python as a language, I would highly recommend Flask. You’ll start very bare bones, but in the end you will have a great app with only the pieces you really need. I’ve built many apps in Flask and always been pleased with the results. It is very well documented and easy to get going.

Django is great, but gets a bit bloated and hard to maintain when so much is automagically done IMO.

2 Likes
#11

Django appears to have the upper hand in both official and unofficial documentation.

#12

Yes, it does. It has been around much longer and the Python ecosystem is very large.

That being said, the Elixir community has been my favorite community of developer. I haven’t been stumped yet thanks to the help of many people on this forum much more intelligent than me.

2 Likes
#13

I also prefer frameworks like Flask, CodeIgniter and Sinatra over Django, Laravel and Rails. You know more about how your app works when you use these frameworks.

#14

Flask is fast. I mean fast. Runs circles around lots of other frameworks even Phoenix.

#15

I did Flask.

It’s very very bare bone, there was no real convention for where you put certain files. It reminds me of express.js framework.

I’ve found myself spending too much time figuring out how I want my code to be organize and it was frustrating when I just want to code the logic. There is always this frustrating and fun feeling of I can improve this by breaking these code up and doing this and that.

Phoenix is much more opinionated and organized. There are only few complaints, one was organizing custom plugs and such. I ended up creating a plug folder in app_web and all plug have a namespace appweb.plug.myplug. But this is also due to me being new to the language and framework.

1 Like
#16

Where your files exist on disk (at rest) is much less important than how your code interacts at runtime (in motion).

3 Likes
#17

I mean all things being relative, me having to inherit a flask code base with 5000+ or so lines of code in app.py, but I guess your right code interacts at run time is much more important.

What does (at rest) mean?

1 Like
#18

+1. The “at rest” code is much more important on a maintenance perspective. I much prefer opinionated frameworks for that alone, even when I would have preferred to handle it differently, as it is much easier to get started, to understand others’ code bases to get ideas and solutions, and to transfer the ownership of the code (including to my future self two years down the line).

2 Likes
#19

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.
4 Likes
#20

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)

2 Likes