rust-dev-
From reading the article, I thought the point was that a universal
server could be deployed and initiated before the actual service it
would offer had actually been *written*.
I agree with Kevin that the exercise would be pretty much pointless for
Rust, unless you enjoy writing interpreters and/or JIT compilers and
want to implement one for Rust. (I know we had rusti at one point, keep
reading...)
In particular, I assume this works in Erlang because Erlang programs are
compiled to an interpreted bytecode representation (for an abstract BEAM
machine) that can then be JIT compiled for the target architecture when
it is run.
But Rust does not not have an architecture independent target code
representation; I do not think LLVM bitcode counts, at least not the
kind we generate, since I believe that has assumptions about the target
architecture baked into the generated code.
Cheers,
-Felix
On 18/12/2013 19:17, Kevin Ballard wrote:
That's cute, but I don't really understand the point. The sample
program he gave:
test() ->
Pid = spawn(fun universal_server/0),
Pid ! {become, fun factorial_server/0},
Pid ! {self(), 50},
receive
X -> X
end.
will behave identically if you remove universal_server from the equation:
test() ->
Pid = spawn(fun factorial_server/0),
Pid ! {self(), 50},
receive
X -> X
end.
The whole point of universal_server, AFAICT, is to just demonstrate
something clever about Erlang's task communication primitives. The
equivalent in Rust would require passing channels back and forth,
because factorial_server needs to receive different data than
universal_server. The only alternative that I can think of would be to
have a channel of ~Any+Send objects, which isn't very nice.
To that end, I don't see the benefit of trying to reproduce the same
functionality in Rust, because it's just not a good fit for Rust's
task communication primitives.
-Kevin
On Dec 18, 2013, at 6:26 AM, Benjamin Striegel <ben.strie...@gmail.com
<mailto:ben.strie...@gmail.com>> wrote:
Hello rusties, I was reading a blog post by Joe Armstrong recently in
which he shows off his favorite tiny Erlang program, called the
Universal Server:
http://joearms.github.io/2013/11/21/My-favorite-erlang-program.html
I know that Rust doesn't have quite the same task communication
primitives as Erlang, but I'd be interested to see what the Rust
equivalent of this program would look like if anyone's up to the task
of translating it.
_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org <mailto:Rust-dev@mozilla.org>
https://mail.mozilla.org/listinfo/rust-dev
_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev
--
irc: pnkfelix on irc.mozilla.org
email: {fklock, pnkfelix}@mozilla.com
_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev