4 ms·
If you want to develop web pages, don't do Erlang. If you want to do web services, do Erlang. I've used both Ruby (Rails) and Python (trying to do concurrency w
by e_proxus 13y ago
If you want to develop web pages, don't do Erlang. If you want to do web services, do Erlang. I've used both Ruby (Rails) and Python (trying to do concurrency with tornado, greenlets, gevent) and they just fell flat. You can do it, but it is incredibly messy and unstable (because there's so much work involved).
In Erlang, you would typically answer a web request in a new actor every time. Just as in Rails, running for example N number of threads serving one request each. Of course, in Erlang that number of actors can vary, which means your system will be more responsive and you'll have lower average latency. However, what differs mostly, is that in Erlang all those actors live inside one VM and you can have central actors managing things, collecting statistics, keeping global state, talking to databases / other services. This, I think, is the core strength of Erlang compared conventional single threaded / GIL systems.
A more concrete example would be to dynamically show the current request rate on a web page. You can just create an actor that gets a message from any other actor once they handle a request, and keeps track of how many such messages per second arrive. Then when rendering that web page, you just ask that actor for it's current value. Simple, beautiful, dynamic. No need for a database or any other central storage.
- klibertp 13y ago> If you want to develop web pages, don't do Erlang. I'm not sure I agree. There's https://github.com/ChicagoBoss/ChicagoBoss https://github.com/ChicagoBoss/ChicagoBoss and quite a few other frameworks (https://github.com/ChicagoBoss/ChicagoBoss/wiki/Comparison-of-Erlang-Web-Frameworks https://github.com/ChicagoBoss/ChicagoBoss/wiki/Comparison-o...) and there's also Elixir and some frameworks for it (https://github.com/dynamo/dynamo https://github.com/dynamo/dynamo). It's of course nowhere near the ease of development of simple web pages in Django or Rails, but it's not like you need to reinvent everything from scratch either. And you gain ability to scale almost without any effort. It's a tradeoff, of course, and using Erlang for every web page you build from now on would be probably an overkill. But there are web sites which are not services yet, which could still benefit from Erlang greatly. And I think (and hope) that the initial overhead of Erlang will get smaller and smaller over time as new frameworks emerge and that someday deploying your blog on top of Erlang will become viable choice :)
- davidw 13y ago> it's not like you need to reinvent everything from scratch either No, not everything, but lots of stuff. Recent example: I had to fix the Postgres database driver to better handle queries like "select * from foobar where id = any($1)", [uuid1, uuid2, uuid3] Also, ChicagoBoss is a bit rudderless at this point in time - Evan Miller has moved on to other things, and the guy who briefly took his place has as well. My own branch of it on github seems to be the only one getting any attention lately, and that's just small fixes here and there: https://github.com/davidw/ChicagoBoss https://github.com/davidw/ChicagoBoss