Crowdhailer

Crowdhailer

Creator of Raxx

Why I built an alternative to plug (Raxx), and why I based it on Rack

tl:dr. This is not an anti plug article, my conclusion is there is reason for both to exist.

Several years ago Jose wrote this article, Why your web framework should not adopt Rack API. It was not the only one, The dark side of the Rack and Websockets dreams.

I am aware of these and was still was curious what a Rack style webserver interface would look like for Elixir, the result was Raxx. Recently, I started building a web-framework on top of Raxx. Here are my thoughts as to “Why Raxx”.

Interested in hearing anyone’s thoughts and opinions.

Edit: See the Library thread on the forum here.

Most Liked

josevalim

josevalim

Creator of Elixir

The problem with this approach is that you need to sit with the response in memory while you undo the stack. If you have a pipeline with 10 plugs, it is most likely that only one or two need to modify the response. In Plug you would register callbacks when you need it. In the Rack model, you need to hold all 10 middleware in the stack.

I would also argue that the use of Plug is simpler for the majority of cases. You can’t get simpler than a single function that receives the connection and returns the connection. As an example, in Phoenix you can use plugs both as “callbacks” in your controller and in your pipelines. However, in Ruby, almost all frameworks and libraries, such as Rails and Sinatra, end-up introducing a new lightweight abstraction that resembles Plug, such as callbacks or filters at the controller and application level.

However, I definitely agree the Plug model is more complex than the Rack model in the scenarios you mentioned. Part of the problem here, especially in regards to exception handling, was that the issue was discovered as we moved forward due to the interplay between Plug and immutability. I believe it would be less confusing if those issues could have been articulated up front.

That’s not saying Plug is the ideal interface for everything but for HTTP the list of pros fairly outweigh the cons (IMO :slight_smile:), especially with HTTP 2 being available and playing even more on the strengths of streaming, data push, multiple responses, etc.

13
Post #6
AstonJ

AstonJ

Found this talk, not sure if it’s up to date but here it is anyway:

Personally I think exploring new ideas is always a good thing, choices generally drive innovation.

Crowdhailer

Crowdhailer

Creator of Raxx

Can’t believe it took me this long to find this paper “Your Server as a function”

Operations are phrased as value transformations,encouraging the use of immutable data structures and, we believe,enhancing correctness through simplicity of reasoning.

While most of our engineers find the programming model un-usual, they tend to internalize it quickly.

The whole paper is discussed in a Scala/Java context so some parts don’t translate well, e.g. there is no need to talk about Futures. However it is interesting to see some of these ideas explained more rigorously than I ever managed when talking about Raxx.

There is also a discussion about interrupting ongoing processing, for example in the case of a timeout.
This is an equivalent here, in Elixir/Erlang. e.g. a Gen call can timeout, but the processing will continue and the reply potentially be returned to the mailbox later.

Is anyone sending interrupt message to processes in the case of a call timeout.

Finally the paper is in a typed language. The idea of statically verifying that only authenticated requests are passed to a service(http handler) that requires authentication is very appealing.
Although less easy to see how this can be useful in Raxx, it might be useful to Midas,
https://github.com/midas-framework/midas

Last Post!

AstonJ

AstonJ

I think Raxx fell into the same trap that Sinatra did - it focused on simplicity but people wanted all the bells and whistles of frameworks like Rails and Phoenix :lol: however the Elixir community has grown a lot since then, and I wonder whether you might find that enough people now may be interested in such a framework?

I’m curious what you mean by the latter part of your sentence - in what way did the Elixir ecosystem get in the way of functional programming principles?

Where Next?

Popular in Discussions Top

PragTob
Hey everyone, this has been on my mind for some time and I’d love your input on it! TLDR: I feel like maps are superioer for storing and...
New
AstonJ
Are there any Elixir or Erlang libraries that help with this? I’ve been thinking how streaming services like twitch have exploded recentl...
New
restack_oslo
Hello, Please pardon me for any faux paux. I am 46 and this is my first time on a forum of any kind. I wanted to to get answers from tho...
New
sergio
There’s a new TIOBE index report that came out that shows Elixir is still not in the top 50 used languages. It also goes on to call Elix...
New
rms.mrcs
A couple of days ago I was discussing with a friend about different approaches to write microservices. He said that if he was going to w...
New
lorenzo
Hey everone! I created a prototype for my app using Nodejs for the api. But the framework I chose wasnt great (in general theresnt any g...
New
crispinb
On reading dhh’s latest The One Person Framework it strikes me that Phoenix with LiveView is already pretty much this. However, never hav...
New

Other popular topics Top

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
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New

We're in Beta

About us Mission Statement