Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Pumping up Node.js modules with Rust

Pumping up Node.js modules with Rust

These slides were presented at JSConfAU 2018

Talk Description:

If you’ve spent much time writing and debugging node module code for performance in a Js app, you’ve probably had a hard time managing memory and native code integration.

In this talk, we venture deep into the belly of the Rust Language to uncover the secret incantations for building high performance and memory safe node modules using Neon, which helps you to write native node js modules and it is definitely gonna mesmerize you with its easy language bridge capabilities for building high performant and crash-free Js apps.

Rust is out there creating a new generation of system programmers, it has a lot to offer in terms of safety and performance for high-level programming languages such Python, Ruby, Js and more with its easy Foreign Function Interface capabilities which enables developers to easily develop bindings for foreign code.

vigneshwer dhinakaran

March 24, 2018
Tweet

More Decks by vigneshwer dhinakaran

Other Decks in Technology

Transcript

  1. JSConf AU 2018 Pumping up Node.js modules with Rust Vigneshwer

    Dhinakaran | Mozilla TechSpeaker | @dvigneshwer
  2. Why Rust? Freedom from Data Race conditions Strong type system

    High level iterators More control over memory Welcoming Community
  3. Tokio MiniHTTP The library is a proof-of-concept implementation of a

    simple HTTP/1.1 server using Tokio. http://aturon.github.io/blog/2016/08/11/futures/
  4. 2016 -18 For the third year in a row, Rust

    is stackoverflow's most loved language https://insights.stackoverflow.com/survey/2018/
  5. Ownership • Rust moves ownership by default • The owner

    has the right to destroy the thing it owns • The memory is freed as soon as the owned variable goes out of it's scope • Hence vehicle may already be destroyed at the point when it's passed to repair_service • Rust catches these errors at compile time
  6. Borrowing • A reference is passed without transferring ownership •

    One can borrow immutable (&) or mutable (&mut) but not both at the same time • Shared ownership can be achieved through special pointers with runtime checks
  7. Mutability Rules • All variables are immutable by default •

    Only one mutable reference at a time ( But as many immutable &’s as you want ) • Mutable references block all other access (The &mut must go out of scope before using other &’s )
  8. When should you use Rust? • Rewrite modules of your

    code that are computationally heavy (Complex math optimizations etc) • For accessing the hardware(ex :- IOT applications, device drivers, GPU’s etc) • Implementing advance concurrency paradigms • JS to Rust calls are non-trivial, so be wise!
  9. What does Rust have to offer? • Modern C/C++ replacement

    • Memory Safety without Garbage Collection • No runtime needed • Rich Typesystem • Strong Functional Programming influence