[erlang-questions] Re: Web server structure: Rack

Dmitrii Dimandt <>
Mon Jan 11 08:53:15 CET 2010


> On Sun, Jan 10, 2010 at 4:46 PM, Steve Davis
> <> wrote:
>> 
>> What's wrong with building on inets? Why do we reinvent the web layer
>> for OTP so often?
>> 
>> BTW I am genuinely extremely interested in answers to these questions.
> 
>    Maybe there's nothing wrong with inets.
> 
>    But why do we reinvent the web layer? :)
>    * it's a nice and easy task (well known, simple and useful
> protocol) to write as one of your first OTP applications; (I wrote an
> Gopher server as my first application; and I've also written my own
> (almost throw-away) web server;)
>    * it's fun to write a web stack that works **exactly** the way
> **you** want; (or at least you think you want and then you change your
> mind ;) )
>    * it's damn easier than in other languages; (no threading /
> multi-process / scalability issues);
> 
>    Hope others agree and add other motives.
>    Ciprian.


Actually, it's not entirely true for the web.

- There's ton of information being passed around in HTTP requests
- Parsing this information out is a tedious task and needs to be redone for every new web layer you wish to build
- Parsing multipart forms is PITA, see http://code.google.com/p/mochiweb/source/browse/trunk/src/mochiweb_multipart.erl and http://bitbucket.org/justin/webmachine/src/tip/src/webmachine_multipart.erl (see esp. the comment about how browsers are fun :) )
- Setting cookies correctly is PITA, see http://code.google.com/p/mochiweb/source/browse/trunk/src/mochiweb_cookies.erl
- You can't reliably write generic code that will run across all Erlang web servers, since every web server differs in how it presents information to your code and what it expects from your code
- Because of that you can't reliably abstract parts of your functionality (caching, setting etags etc., see e.g. http://rack.rubyforge.org/doc/Rack.html) into truly reusable pieces of code


Because of that a common web server interface is actually a blessing and, in my opinion, should be accepted more aggressively.


More information about the erlang-questions mailing list