• Tuesday , 25 February 2020

High Performance Apps with JavaScript and Rust

Code Canyon



NodeJS is amazing at lots of things, but computationally intensive or low level tasks aren’t among those things. How can you still leverage the ease of use of NodeJS and do things that are computationally expensive like machine learning, or low level things like computations on a GPU? By using Rust and Node together. Rust is a strongly typed cross platform language that is an excellent choice for handing these exact problems. It’s easy to learn and works very well with Node. This talk will teach you Rust syntax and usage from a JS developers perspective, how to write a Rust library to make it callable from NodeJS and finally actually calling the library from NodeJS. After attending this talk you will:
– Have a basic grasp of writing a Rust library
– Know when and how to use Rust
– Understand how to use the foreign function interface to call out from NodeJS
– Execute callbacks to your Node code from your Rust lib.

EVENT:

NodeJS Interactive 2017

SPEAKER:

Amir Yasin

PERMISSIONS:

The Linux Foundation provided Coding Tech with the permission to republish this video.

CREDITS:

Original video source: https://www.youtube.com/watch?v=Pfbw4YPrwf4

Additional material for JavaScript learners:
https://amzn.to/2JrUINQ Eloquent JavaScript, 3rd Edition: A Modern Introduction to Programming
https://amzn.to/2HwAMYd Simplifying JavaScript: Writing Modern JavaScript with ES5, ES6, and Beyond
https://amzn.to/2Cq5bmL JavaScript: JavaScript Programming.A Step-by-Step Guide for Absolute Beginners
https://amzn.to/2uhIvAP How JavaScript Works
https://amzn.to/2CwS2bU The Modern JavaScript Collection

Original source

3d Ocean

Related Posts

13 Comments

  1. oxyfodu
    April 27, 2019 at 17:18

    IMO this FFI-Glue code looks more complex than Neon bindings. Maybe Neon improved since this talk was given. At least neon gives you a nice project layout to develop nodejs/rust side-by-side.

    Another option is to compile rust to wasm and use the WASM blob in NodeJS (which is possible with recent NodeJS versions, 11.x ATM).

    So, counting FFI, Neon and WASM, there are three options to integrate Rust into NodeJS – there's no excuse not to try it 😉

  2. Gurudutt Raut
    April 27, 2019 at 17:18

    Wtf BS

  3. 4mb127
    April 27, 2019 at 17:18

    Very good and clear talk. Nice job.

  4. Chris Rudd
    April 27, 2019 at 17:18

    a couple clarifications:
    Ownership in rust
    a borrow is like a window into the original variable
    mutable just means changable
    immutable borrows can be passed around freely (so long as the windows die before the original does)
    mutable borrows can only be held by one window, until that window goes out of scope (they block immutable borrows to avoid data races)

    Tuples are basically an easy way to return multiple results in a single package. You access it like you would an array

    Vectors are basically what you would normally think of as an array. The difference happens because one of Rust's focuses is on speed. Vectors live on the heap (big, slow memory) and their length can be changed. Arrays live on the stack (small memory that's close to the cpu) and have be a fixed size known at compile time.

    A closure is basically a mini function that fits inside a variable so it can be handed around. (https://doc.rust-lang.org/book/2018-edition/ch13-01-closures.html#refactoring-with-closures-to-store-code)

    —————
    Rust has some of the best documentation I've seen in a systems language
    Tutorial/reference (clear, effective, very useful): https://doc.rust-lang.org/book/2018-edition/
    An example page from language wiki (clearly explains every part of the language): https://doc.rust-lang.org/std/collections/index.html

  5. a4400815
    April 27, 2019 at 17:18

    At 21:03 indentation looks like "for" loops are nested. They are not!

  6. Andrew Vijay
    April 27, 2019 at 17:18

    uh.. uh.. uh.. uh.. uh.. uh.. uh.. uh..

  7. Dayvie
    April 27, 2019 at 17:18

    Never optimize prematurely.

  8. Roland Brake
    April 27, 2019 at 17:18

    i hate this language!

  9. Maratimus Lion
    April 27, 2019 at 17:18

    Cool 😎

  10. BinaryReader
    April 27, 2019 at 17:18

    tip: when creating a lib project in rust, you can run `cargo run –example foo` where foo lives in the directory `[root]/examples/foo.rs`. This lets you run your application as a program (an example program) but still easy author a lib. This is a better alternative to creating a app if your intent is to create a lib.

  11. DjNerDee
    April 27, 2019 at 17:18

    Rust is a great language if you haven't tried it already. I'm using it to make a 3d game engine that works natively on the browser by compiling down to wasm

  12. Mark Walker
    April 27, 2019 at 17:18

    If something is "immutable" how can it be a variable?

  13. Hristo Traykov
    April 27, 2019 at 17:18

    Great presentation, but if there is a way please tell this guy he's saying "AAA" WAY TOO MUCH! Thank you.

Leave A Comment

You must be logged in to post a comment.