jarmo

jarmo

Using lightweight libraries/tools instead of Phoenix

Hello!

I’ve been an avid Phoenix user for years now (let’s say ~4-5 years?). Have multiple installations running in production etc. I also have Ruby on Rails experience a way back (from Rails 4 already if I remember correctly up to Rails 6). Total professional programming experience is ~15 years and has been mostly about web-apps.

Usually when I use these frameworks which do all the things, I start to wonder at one point, how difficult would it be to create a web application using lower level tools instead of these heavy-weight champions. I’m happy to say that I find Phoenix much more lightweight compared to Rails, however it still gets once in a while in my way with weird problems, which are harder to grasp due to the overhead and creates additional work with its backwards-incompatible version releases if there is any urge to upgrade. In Ruby ecosystem I would use Sinatra (or something similar) with some templating engine and lower-level database-connection library to build a web application if I would not want to use Rails.

I’ve never done something similar in Elixir world yet, but started to think what does Phoenix offer me in the first place. As I understand then one big thing about Phoenix is LiveView, but I’ve never found a use for it since I like more “boring technologies” meaning server-side template rendering and only a little bit of JavaScript here and there where more dynamic functionality is needed (surprise, surprise - most of the time it is not needed). And of course Phoenix-like framework offers conventions of where to put your code, which is really good if you’re just starting coding career.

I started to ponder that thought a little bit more and found out that most of the things I thought being part of Phoenix is just part of Elixir itself (thing Config and Releases for example).

After some initial research I found out that I could use Plug with Cowboy, Config, Releases and EEx together with Ecto and its migrations. I would also like not to use Ecto and use something where I can write plain old SQL, but have not found anything to my liking yet in Elixir ecosystem.

Any thoughts or experience about going this road or any strong opinions against doing it? What does Phoenix offer in your mind, which is not easy to do when not using Phoenix? Any good light-weight library suggestions (especially about database related)?

Don’t get me wrong - Phoenix is a fantastic framework, which has managed to create a fork of RoR in a good way. Usually these forks fail miserably in other ecosystems/programming languages because for some reason good parts of RoR is not copied and many bad parts are copied instead :slight_smile: Thank you for Phoenix!

Jarmo

First Post!

josevalim

josevalim

Creator of Elixir

You should be able to get something quickly up and running using Plug (Plug.Router in particular) and Phoenix.Template+Phoenix.HTML (if you are doing HTML stuff). If you are doing APIs, then you will need Jason and a handful of helpers such as json/2, which receives the connection, data, and renders it as JSON. For queries, you can use Postgrex directly.

Most Liked

al2o3cr

al2o3cr

IMO about 80% of the developer effort spent on “keeping things lightweight” is waste; there was a huge fad back in the day of people going to incredible lengths to prove “they didn’t NEED a framework” that led to a lot of hard-to-maintain messes. I’ve worked on at least one $BIGCO codebase where they started by embedding Sinatra “to make an efficient API” then welded every other Rails feature back on.

IMO it’s good for everybody, because people farther along in their coding career should probably be thinking about “how to solve the customer’s problems” and less about “how to shuffle around some files”.

11
Post #8
BartOtten

BartOtten

And then another developers has to work at the code base and:

  • learn your new (likely less) documented custom conventions
  • can’t find answers at ElixirForum and Stackoverflow
  • can’t ask “Phoenix questions” but has to resort to “we’re using a combination of Plug and X”

Have seen companies go ‘bare bone’ and instead they just rebuild a less documented, less dev friendly, less secure, less optimized ‘fat bone’ over time.

There might be very rare cases where it is beneficial but in general it’s just not worth it.

dimitarvp

dimitarvp

You’ll end up reinventing a smaller buggier Phoenix IMO.

I too think Phoenix can be too heavyweight on management – several different files in the right places, magic configurations with several levels of lists and tuples, code generators that historically have ended up producing outdated code you have to manually upgrade, and others I can’t remember right now – so I’ve been in projects where we’ve only used Plug for routing. However, these projects were serving JSON and had zero visual parts.

As much as I feel working with Phoenix is boring and annoying, it’s probably one of the best things we have on the planet in the web area.

Last Post!

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.

Where Next?

Popular in Discussions Top

CharlesO
Erlang :list.nth simple, but 1 - based nth(1, [H|_]) -> H; nth(N, [_|T]) when N > 1 -> nth(N - 1, T). Elixir Enum.at … coo...
New
jesse
Hi everyone, I hesitated to post this here because I don’t want you to think I’m spamming, but I’ve been working on a Platform-as-a-Serv...
New
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1144 55125 245
New
AstonJ
If a newbie asked you about Phoenix Contexts, how would you explain the basics to them? Feel free to be as concise or in-depth as you li...
New
New
AstonJ
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
New
AstonJ
Can you believe the first professionally published Elixir book was published just 8 years ago? Since then I think we’ve seen more books f...
New

Other popular topics Top

Qqwy
Update: How to use the Blogs & Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3271 131117 1222
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New

We're in Beta

About us Mission Statement