[erlang-questions] node.js vs erlang
Loïc Hoguin
essen@REDACTED
Thu Jun 19 13:33:23 CEST 2014
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. 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 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.
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.
> 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.
--
Loïc Hoguin
http://ninenines.eu
More information about the erlang-questions
mailing list