Live data from Hacker News

Neon: Node plus Rust

calculist.org

51–60 of 71 posts

Re: Neon: Node plus Rust

#51
post #49

Since both node and Rust use libuv for parallelism. Is it possible to provide the node libuv pool to rust so that they share a single bound on parallel operations? Also, can I use Neon for async callbacks?

Rusts std lib does not utilize any longer. It only used in in some pre 1.0 versions when green threads were still a thing.

Re: Neon: Node plus Rust

#52

Honest question: Why would someone use Node instead of a Rust web framework when writing part of the code in Rust anyway?

- Node has full garbage collection. Rust has some very clever memory-handling, but it's not quite the same. - Node is javascript. You may want to run the same code on client and server, and it's simpler than compiling Rust to JS. - There may be JS libraries you want to use. I could go on.

> Node is javascript. You may want to run the same code on client and server, and it's simpler than compiling Rust to JS.

What would be the reason to do that?

Re: Neon: Node plus Rust

#53

Earlier quoted context omitted.

- Node has full garbage collection. Rust has some very clever memory-handling, but it's not quite the same. - Node is javascript. You may want to run the same code on client and server, and it's simpler than compiling Rust to JS. - There may be JS libraries you want to use. I could go on.

> Node is javascript. You may want to run the same code on client and server, and it's simpler than compiling Rust to JS. What would be the reason to do that?

You need to do the same thing on the client and the server.

- DOM manipulation for AJAX states so they can be reached directly from the server without needing client side JS to do anything

- Calculate discounts for products (obviously clients just POST the product they want, but the discounts should be applied on the server consistently to how they were shown to the user)

- Your code is something generic, like recursively checking for a keypath on an object, and totally useful for JS anywhere it runs.

All kinds of other reasons.

Re: Neon: Node plus Rust

#54
There's an API thing from the JS side I don't understand, and I didn't find anything documentation-wise (maybe it's just because I haven't had my coffee yet):

  require('neon-bridge').load()
So this loads... which rs file, exactly? Where do I specify the Rust file to be loaded? Or is there just a single entry point and you're supposed to have one singular Rust module that is named by convention?

Re: Neon: Node plus Rust

#56
post #54

There's an API thing from the JS side I don't understand, and I didn't find anything documentation-wise (maybe it's just because I haven't had my coffee yet): require('neon-bridge').load() So this loads... which rs file, exactly? Where do I specify the Rust file to be loaded? Or is there just a single entry point and you're supposed to have one singular Rust module that is named by convention?

Looks like `neon-bridge`, in this case, is an NPM module.

Re: Neon: Node plus Rust

#57
post #54

There's an API thing from the JS side I don't understand, and I didn't find anything documentation-wise (maybe it's just because I haven't had my coffee yet): require('neon-bridge').load() So this loads... which rs file, exactly? Where do I specify the Rust file to be loaded? Or is there just a single entry point and you're supposed to have one singular Rust module that is named by convention?

Looks like `neon-bridge`, in this case, is an NPM module.

Yes, it is, but the point is its load() function apparently takes no parameters.

Re: Neon: Node plus Rust

#58

Earlier quoted context omitted.

- Node has full garbage collection. Rust has some very clever memory-handling, but it's not quite the same. - Node is javascript. You may want to run the same code on client and server, and it's simpler than compiling Rust to JS. - There may be JS libraries you want to use. I could go on.

> Node is javascript. You may want to run the same code on client and server, and it's simpler than compiling Rust to JS. What would be the reason to do that?

I found it rather pleasant to have the same libs on client and server. Learn one lib API and use it everywhere :)

It also enabled me to move functionality freely around.

Calculating report data on the front-end, so it gets ready tomorrow and later moving it into the back-end, for performance reasons.

Re: Neon: Node plus Rust

#59
post #57

Earlier quoted context omitted.

Looks like `neon-bridge`, in this case, is an NPM module.

Yes, it is, but the point is its load() function apparently takes no parameters.

1. https://github.com/dherman/neon-bridge/blob/master/lib/index...

2. https://nodejs.org/api/globals.html#globals_filename

3. https://github.com/dherman/neon-bridge/blob/master/lib/proje...

Post reply on HN