3 ms·
After many projects with Rails and one with Phoenix, these are my remarks on the list in the post: * The directory structure. Rails has a simpler one. Phoenix
by pmontra 9y ago
After many projects with Rails and one with Phoenix, these are my remarks on the list in the post:
* The directory structure. Rails has a simpler one. Phoenix has some weirdness (why the migrations are in priv/db? They are private and all the other modules are not?)
* The naming conventions. About the same.
* The database migrations. About the same, but with Phoenix we have to duplicate the schema definition in the model, which is not DRY at all and encourage bugs. Either the ActiveRecord way (the truth in the db) or the Django way (the truth in the model).
* The use of dependencies. About the same.
* The ActiveRecord features. AR is much easier to use than Ecto, which is more general but often unnecessarily so. Proof: there are modules on top of Ecto to make it look like AR [1] [2]. Personally I won't use plain Ecto in an Elixir project of my own.
* The ERb templates. About the same.
* The form helpers. I really don't know: my Phoenix project was a backend to a SPA, we generated JSON plus some email templates.
* The built-in support for testing. About the same.
Advantages of Phoenix:
* no need for Sideqik, just spawn processes and send emails and the like
* create some GenServers to run long running processes side by side with the main web application
* the websocket server is an example of the previous point and it performs better than the one in Rails.
* Elixir's pattern matching is so good to use compared to any language without it (Ruby, Python, etc.)
Advantages of Rails:
* ActiveRecord is so easier to use that it translates in visible productivity gains (of course it's also 10 years of Rails vs 4 months of Phoenix). What it means for the long term maintainability of the application is up to you to decide. In my experience the impact is zero because none of my projects was meant to scale to the millions of users or to a complex architecture and none did. Your project might be different.
* The object oriented notation is more compact than the functional one: object.method.method.method vs value |> function |> function |> function, maybe with some Module.function thrown in to make it even more verbose.
[1] https://github.com/sheharyarn/ecto_rut https://github.com/sheharyarn/ecto_rut
[2] https://github.com/MishaConway/ecto_shortcuts https://github.com/MishaConway/ecto_shortcuts
- kungfooguru 9y ago'priv' is an Erlang/OTP application's directory for files that are part of an application but not source or compiled beams.
- praveenperera 9y agoWhen I go back to Rails, ecto is something I miss a lot. Once I got used to “thinking in ecto” and its explicitness and composeability I fell in love with it. Ecto also makes it much harder to shoot yourself in the foot. For anyone that wants to learn more about Ecto I recommend this talk: https://youtu.be/YQxopjai0CU https://youtu.be/YQxopjai0CU