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,

Where Next?

Popular in Discussions Top

PragTob
Hello everyone, I know we had quite some threads (read through lots of them) about background job processing but it remains a hotly deba...
New
mikl
I wanted to capitalize a string, and tried using String.capitalize(). That generally works well, until you try to capitalize a word like...
New
pillaiindu
In django there is a cache framework backed by memcached. Rails also puts a lot of emphasis on caching, and even the idea of russian-doll...
New
cvkmohan
The upcoming Phoenix 1.6 release looks very interesting. Became a habit to watch the commits - and - what they are bringing in. phx.gen...
New
chuck
Let me start by stating an assumption: Phoenix is a great approach to building REST APIs. There are many reasons for this, but I will ass...
New
New
gausby
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
1207 39247 209
New
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
RudManusachi
What configs will make sense to put to runtime.exs? – A bit of how I configure apps: I have generic configs in config/config.exs, dev...
New
chulkilee
Here are the list of HTTP client libraries/wrappers, and some thoughts on HTTP client in general. I’d like to hear from others how they w...
New

Other popular topics Top

danschultzer
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch. This project took far...
548 29305 241
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 52238 488
New
Lily
In templates/appointment/index.html.eex: <%= for appointment <- @appointments do %> <tr> <td><%= appoi...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
AngeloChecked
What learn first? Rust or Elixir Hi Elixir community! I’m here because i want learn a new language. I’m a junior developer and mainly i ...
New
klo
Got a question about when to concat vs. prepending items to list then reversing to achieve appending. So i know lists boil down to [1 | ...
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 record...
New

We're in Beta

About us Mission Statement