Live data from Hacker News

Neon: Node plus Rust

calculist.org

61–70 of 71 posts

Re: Neon: Node plus Rust

#61

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

The reason that I'm using Rust and Node together is Lambda. It supports Java, Python and Node and my (admittedly perfunctory) tests showed that Node had the smallest overhead of the three in getting to Rust. However, this library seems to offer a richer interaction between the two platforms, which would imply using Node as something beyond a bridge to Rust, so there's likely an answer beyond mine that the author has in mind.

Re: Neon: Node plus Rust

#62
post #26

Earlier quoted context omitted.

If the goal is having a fast "business-rules engine" coupled to a pretty HTML5-based app-wrapper, one of my own projects is to combine Electron with the Erlang VM. Rather than trying to go whole-hog on linking the two worlds together at a process level, I've just embedded an Erlang release into the Electron package, which decompresses itself to the user's Library/APPDATA dir on Electron startup, transparently registe…

Give me this but with Elixir and Im sold.

why elixir over rust? I'd assume rust makes more sense because you don't need gc

Re: Neon: Node plus Rust

#64
post #63

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

Because rust isn't web yet: http://arewewebyet.com .

That site is very out of date. We've been trying to get it fixed (as none of us control it), but we haven't been able to so far. :(

Re: Neon: Node plus Rust

#65
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?

Rust is a compiled language, so the JS files don't directly load a .rs file but instead they load a native Node extension, i.e. a .node file, which is generated by compiling and linking the Rust sources. (The node-cli tooling automates the whole build process.)

The line you cited is automatically locating the .node file, loading it, and returning the module object associated with it.

On IRC a couple people have been questioning this part of the API, suggesting that just using the standard npm module `bindings` might be better. It's a reasonable idea and I'll probably open a discussion in a GitHub issue.

Re: Neon: Node plus Rust

#66
post #65
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?

Rust is a compiled language, so the JS files don't directly load a .rs file but instead they load a native Node extension, i.e. a .node file, which is generated by compiling and linking the Rust sources. (The node-cli tooling automates the whole build process.) The line you cited is automatically locating the .node file, loading it, and returning the module object associated with it. On IRC a couple people have been…

I realize that Rust is a compiled language, that's not the issue. The syntax somehow suggested to me the modules could be compiled on demand, but that is not the issue either.

My question is/was, given two or more modules written in Rust, how do I address and require them by name? Due to its naming I assumed "neon-bridge" would be the glue that handles this. Given the fact that you can require .node files directly, it was not clear to me that "neon-bridge" is just the name of an example module (or is it?).

Re: Neon: Node plus Rust

#67
post #66
post #65

Earlier quoted context omitted.

Rust is a compiled language, so the JS files don't directly load a .rs file but instead they load a native Node extension, i.e. a .node file, which is generated by compiling and linking the Rust sources. (The node-cli tooling automates the whole build process.) The line you cited is automatically locating the .node file, loading it, and returning the module object associated with it. On IRC a couple people have been…

I realize that Rust is a compiled language, that's not the issue. The syntax somehow suggested to me the modules could be compiled on demand, but that is not the issue either. My question is/was, given two or more modules written in Rust, how do I address and require them by name? Due to its naming I assumed "neon-bridge" would be the glue that handles this. Given the fact that you can require .node files directly, i…

Ah, I see!

So neon-bridge is a utility npm package I published that automates loading your Neon project (so it's not the name of an example module). And the expectation is that you only have one Rust package ("crate" in Rust parlance) per Node package, which is why you don't need to pass it the name of anything -- it's looking for _the_ native module in the package, as opposed to _a_ native module.

However, that single Rust crate may have multiple modules in its implementation. They live in the src/ directory of your Neon project and are picked up by the Rust compiler and build tool.

And yes, deeeeefinitely need to get some docs going... :P

Re: Neon: Node plus Rust

#68
post #67
post #66

Earlier quoted context omitted.

I realize that Rust is a compiled language, that's not the issue. The syntax somehow suggested to me the modules could be compiled on demand, but that is not the issue either. My question is/was, given two or more modules written in Rust, how do I address and require them by name? Due to its naming I assumed "neon-bridge" would be the glue that handles this. Given the fact that you can require .node files directly, i…

Ah, I see! So neon-bridge is a utility npm package I published that automates loading your Neon project (so it's not the name of an example module). And the expectation is that you only have one Rust package ("crate" in Rust parlance) per Node package, which is why you don't need to pass it the name of anything -- it's looking for _the_ native module in the package, as opposed to _a_ native module. However, that sing…

Cool, thanks for clearing that up. And thanks for working on this, I know with the questions it can sometimes seem like it's not appreciated... :)

Re: Neon: Node plus Rust

#69
post #63

Earlier quoted context omitted.

Because rust isn't web yet: http://arewewebyet.com .

That site is very out of date. We've been trying to get it fixed (as none of us control it), but we haven't been able to so far. :(

To clarify, are you saying that Rust is web (i.e. that the tools necessary for modern web server development and deployment are available to the Rust ecosystem)?

Re: Neon: Node plus Rust

#70
post #68
post #67

Earlier quoted context omitted.

Ah, I see! So neon-bridge is a utility npm package I published that automates loading your Neon project (so it's not the name of an example module). And the expectation is that you only have one Rust package ("crate" in Rust parlance) per Node package, which is why you don't need to pass it the name of anything -- it's looking for _the_ native module in the package, as opposed to _a_ native module. However, that sing…

Cool, thanks for clearing that up. And thanks for working on this, I know with the questions it can sometimes seem like it's not appreciated... :)

Not at all -- my goal is simplicity and clarity so a confused (potential) user is a bug report!
Post reply on HN