Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support NodeJS as a platform #270

Open
foretspaisibles opened this issue Sep 13, 2016 · 8 comments
Open

Support NodeJS as a platform #270

foretspaisibles opened this issue Sep 13, 2016 · 8 comments
Milestone

Comments

@foretspaisibles
Copy link

I am maintaining a codebase running lwt on top of NodeJS, thanks to the excellent js_of_ocaml. Of course the Unix parts of lwt are unavailable but I have written replacements for some of the missing functionalities. I am also happy to say that the resulting programs have been put in production for several month now and display a very satisfying stability and ability to handle large amount of data.

I would be very interesting to make NodeJS being supported next to Unix as a platform, as to ease writing platform-independant code. Is there anybody doing the same, or even just vaguely interest by this?

@aantron
Copy link
Collaborator

aantron commented Sep 13, 2016

Interested to see what you have made.

Also, it would be nice to run CI tests even of only the existing platform-independent parts of Lwt on Node (see #249). Would be interested to hear about your setup or environment.

@aantron
Copy link
Collaborator

aantron commented Dec 26, 2016

I want this. Any word? Ideally, we would make room for several bindings besides Unix, though practically we would implement the ones that people are most interested in first. Ideally, we could make sure Lwt interacts really well with JS, has a nice mapping to promises. We would compile Lwt with Bucklescript and publish Lwt in npm for people using that to depend on. cc @fxfactorial @sgrove @jordwalke ?

@jordwalke
Copy link

It's very valuable because many people have existing deployments of node and they can't just drop everything and create an entirely new server environment from scratch. For example, corporate IT departments might have spent a long time vetting infrastructure like node, and therefore that's the easiest way to wedge OCaml into the system.

@mfp
Copy link
Collaborator

mfp commented Mar 6, 2017

I've taken a quick look at NodeJS' API and many things in Lwt_unix would be implementable straightforwardly atop it (minus the type equalities, etc., with Unix, which would have to go in the NodeJS-safe version), the easiest ones being the FS functions. Lwt_bytes could be implemented atop Buffer, but it would probably be easier to reimplement higher-level functionality (re: Lwt_io's reorganization). With a good enough coverage of Lwt_unix (needs not be complete and would certainly not include any of the async method stuff or just NOP it) and Lwt_io, things like Ocsigen could be nearly runable on NodeJS.

@michipili are your NodeJS reimplementations of Lwt_unix (and others) functionality available somewhere for reference?

@foretspaisibles
Copy link
Author

@mfp @aantron It is not yet. I will prepare a repository for this soon, so that we can start a discussion on concrete basis.

@avsm
Copy link
Collaborator

avsm commented Apr 13, 2017

On a similar note, we have a bunch of code in https://github.com/docker/vpnkit/blob/master/src/hostnet/sig.ml that abstracts over Lwt_unix vs libuv. It might be useful to build a 'core' set of Unix signatures that could be implemented by multiple libraries for js_of_ocaml, libuv, etc. (cc @djs55)

@aantron aantron mentioned this issue Jun 11, 2017
@aantron aantron added this to the libuv milestone Aug 3, 2019
@aantron aantron removed the difficult label Mar 4, 2020
@Lupus
Copy link

Lupus commented Sep 4, 2020

@michipili how's your Lwt-on-nodejs project going after couple years? We do something similar with some abstraction over httpaf for native http stack and node http stack, so that services could be run on top of native OCaml or node platforms.

@foretspaisibles
Copy link
Author

That's pretty interesting! On my side, I've not been doing much in the topic these days and do not plan to. I guess I still could have my code somewhere but it would probably not be running without upgrading to modern LWT interface at least!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants