runtimejs / runtime

[not maintained] Lightweight JavaScript library operating system for the cloud
http://runtimejs.org
Apache License 2.0
1.93k stars 128 forks source link

Node.js compatibility #44

Open piranna opened 9 years ago

piranna commented 9 years ago

There's some of the internal modules published on npm and seems it's the way to go, so the core will be minimal and probably it's mostly a matter of having a require() function and delegate everything to modules as @groundwater proposed. Later one of those modules could provide an environment and API layer that a Node.js app would expect. I know runtime.js will try first to allow to exec single Javascript apps, but that single app could be a Node.js emulator similar to what diferent libOS libraries do on the exokernels, isn't it? :-)

(And yes, I'm asking for this to exec NodeOS on runtime.js ;-) )

iefserge commented 9 years ago

Yeah, check out this https://github.com/kesla/runtime-node-net (by @kesla). It's still work in progress, but the idea is to provide Node.js compatible net module on top of runtime. Later we can teach runtimeify to use it automatically, so existing Node.js apps would just work without any modifications.

piranna commented 9 years ago

Great! :-D

kesla commented 9 years ago

@piranna we now have net, dns & http for runtimejs!

kesla commented 9 years ago

Very early days, but compatibility is getting there

piranna commented 9 years ago

Very early days, but compatibility is getting there

Wohoo! :-D

piranna commented 9 years ago

In its current status, NodeOS has too much dependency on processes. Maybe in the future we remove them if we make it a Javascript-only OS (at this moment the only binary is Node.js, I hope LLVM.js cames soon so I don't need to have a gcc binary for compiled modules...), but until that I'll wait for them. Keep working, good job :-)

kesla commented 9 years ago

LLVM.js?

kesla commented 9 years ago

how will that work?

piranna commented 9 years ago

LLVM.js?

https://github.com/kripken/llvm.js, it's LLVM (and Clang) compiled itself to Javascript using Emscripten, although seems to be abandoned... :-( But this could allow to have a C/C++ compiler written (transpiled) in Javascript so it can be used in NodeOS for the compiled modules and also for runtime.js :-)

kesla commented 9 years ago

@piranna sounds to crazy to be a good idea to me. I'd much rather see that we skip support for c++ modules all together and go strong on full js-modules.

piranna commented 9 years ago

Yeah, for runtime.js I would definitely go for pure Javascript modules, and only have C++ to expose to that Javascript modules the most internal and low-level parts (interruptions, ports address, memory...) as Javascript objects.

NodeOS make use of some compiled modules to have access to the Linux syscalls as if they were functions, but it's possible to change them to call methods on runtime.js core objects :-)

kesla commented 9 years ago

Oh right, so I'm not a pro around this - but wouldn't it be possible to use https://www.npmjs.com/package/ffi for this?

piranna commented 9 years ago

but wouldn't it be possible to use https://www.npmjs.com/package/ffi for this?

In fact, it's being integrated natively in the core of upcoming versions of Node.js... :-D