[erlang-questions] node.js vs erlang

Joe Armstrong erlang@REDACTED
Thu Jun 19 17:20:57 CEST 2014

On Thu, Jun 19, 2014 at 1:33 PM, Loïc Hoguin <essen@REDACTED> wrote:

> On 06/19/2014 01:06 PM, Joe Armstrong wrote:
>> You can - Here is an example of a single file cowboy server that computes
>> fib(N) -
>>  [snip huge file]

>> Put this in a file. chmod it to u+x and run it
>> Then got to http://localhost:8124/fib?n=10
>> And fib(10) will be returned
> Joe, your one file example is longer than my many files getting started,
> not to mention completely cryptic.

I *explicitly* said at the end "With a small amount of refactoring this
could be
make just as simple as the node.js examples"

This was a quick cut-and-paste job to show that it could be done - it was
intended an a beginners example.

To make a beginners example - I'd move most of the code into the libraries
and rename
things fro clarity

> The shebang up there isn't something you can just drop on people, you have
> to explain it.


> You also have to say why you have an infinite receive

Can be refactored out of the code

> and how to stop the program.


> Plus, doing this you'd also have to explain them that they have to
> download 3 different projects manually and to put them in the appropriate
> folder.

this is what something like npm should do

> And of course, the worst is that by taking this one file example, people
> immediately get stuck. How do they add a second handler? I personally have
> no idea how to go from that one handler escript to something bigger.
read the rebar example at


Actually bigger apps should not be built the same way as smaller apps,
just because large apps need a particular structure, there is no reason why
small apps
need the same structure.

>        2) make a packed escript that packs all the compiled code into a
>> single file
>>           rebar is a good example of this
> That script takes an OTP application and bundles it into one escript. It
> makes little difference with taking an OTP application and generating a
> release, except the release is a lot more useful for servers.
>    Erlang was not designed to be complex - the primitives in Erlang
>> (spawn_link, trap_exits, etc.) were designed to be as simple as possible
>> and were intended to be called from library routines.
> I didn't say Erlang was designed to be complex. I'm saying running the
> Erlang VM is of higher complexity than dropping a PHP file into a folder or
> running nodejs myfile.js. And yes, that's true even if you use escripts.
To run the erlang VM I say

     $ erl -s ....

To run node.js I say

     $ node ...

 I don't see why one is more complex than the other.



> Loïc Hoguin
> http://ninenines.eu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20140619/9b60a89f/attachment.htm>

More information about the erlang-questions mailing list