Node.Js in Erlang style?

Not completely right Yes you could distribute JSON messages The part with hot code replacement is a bit more complicated let me explain OK, first you obviously need to have validation etc. In place, that shouldn't be a big problem. The first small problem arises from JSON, which does not allow for any JS code/functions in it, well you can work around that by sending the data as a string Next problem, when you want to replace function/method you need to make sure that it keeps it's scope, so that the newly compiled functions has access to the same things With some dark eval magic this is certainly possible but don't expect it to be anywhere near as natural as it's in Erlang: var Script = process. Binding('evals').

Script; var hello = ' function Swappable(initCode) { this. Execute = function() {} this. Swap = function(code) { this.

Execute = eval('func = ' + code); } this. Swap(initCode); } // Note: Swappable's scope is limited, it won't inherit the local scope in which it was created... var foo = new Swappable('function(){console. Log(hello);return function(){console.

Log(test)}}') var cb = foo.execute(); cb(); foo. Swap('function(){console. Log("Huh, old world?

");return function(){console. Log(test * test)}}'); var cb = foo.execute(); cb(); console. Log(bar.execute()); foo.execute() Output old world?

1764 This is not guaranteed to work in 100% of all cases and scopes. Also, the syntax is horrible, so I'd suggest if you want hot swapping, stay with Erlang Remember: Right tool for the right job Update There won't be anything better than that in the near future see: https://github.Com/ry/node/issues/issue/46#issue/46/comment/610779.

Not completely right. Yes you could distribute JSON messages The part with hot code replacement is a bit more complicated let me explain... OK, first you obviously need to have validation etc. In place, that shouldn't be a big problem. The first small problem arises from JSON, which does not allow for any JS code/functions in it, well you can work around that by sending the data as a string.

Next problem, when you want to replace function/method you need to make sure that it keeps it's scope, so that the newly compiled functions has access to the same things. With some dark eval magic this is certainly possible, but don't expect it to be anywhere near as natural as it's in Erlang: var Script = process. Binding('evals').

Script; var hello = ' function Swappable(initCode) { this. Execute = function() {} this. Swap = function(code) { this.

Execute = eval('func = ' + code); } this. Swap(initCode); } // Note: Swappable's scope is limited, it won't inherit the local scope in which it was created... var foo = new Swappable('function(){console. Log(hello);return function(){console.

Log(test)}}') var cb = foo.execute(); cb(); foo. Swap('function(){console. Log("Huh, old world?

");return function(){console. Log(test * test)}}'); var cb = foo.execute(); cb(); console. Log(bar.execute()); foo.execute(); Output old world?

1764 This is not guaranteed to work in 100% of all cases and scopes. Also, the syntax is horrible, so I'd suggest if you want hot swapping, stay with Erlang. Remember: Right tool for the right job.

Update There won't be anything better than that in the near future see: https://github. Com/ry/node/issues/issue/46#issue/46/comment/610779.

Here is a blog comparing experiences using Erlang and Node. Js: blog.mysyncpad.com/post/2073441622/node-... Here is another comparison which purposefully does not compare speed as such: jlouisramblings.blogspot.com/2010/12/dif....

1 To be honest that post is very misleading, first of all there's no mention about which version of Node. Js he used. It's widely known that 2.

X has massive problems when pushing strings to sockets (exactly what he did) and that there are some bugs in V8 with JSON encode/decode. The string problem is fixed in newer 3. X builds.

– Ivo Wetzel Dec 14 '10 at 14:02 My point wasn't really the difference in speed. – rvirding Dec 15 '10 at 16:21.

Don't have enough points to comment inline, but I wanted to respond to Ivo Wetzel's comment above at rvirding's post. There is an updated blog on mysyncpad where the author uses the version of nodejs specifically recommended by the nodejs and v8 developers. blog.mysyncpad.com/post/2143658273/syncp....

I assume With script module you could execute javascript without reloading the server. Supervisor A little supervisor script for nodejs. It runs your program, and watches for code changes, so you can have hot-code reloading-ish behavior, without worrying about memory leaks and making sure you clean up all the inter-module references, and without a whole new require system.

But then again it will reload(very short time offline) when it detects file changes.

1 With Erlang style messages you could hot swap w/o reloading anything. You could even transform local state before activating the new message loop – Roger Alsing Dec 14 '10 at 10:01 I also found this when googling => romeda. Org/blog/2010/01/hot-code-loading-in-nodejs.html.

But also believe ryan wants to put this in the codebase(but then again he is a busy man). But for now I don't believe it is as advanced as erlang? – Alfred Dec 14 '10 at 10:05 I checked it out, this does not preserver module state, so all you can use it for is patching of static, stateless utilities.

– Ivo Wetzel Dec 14 '10 at 10:29.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions