Slide 1

Slide 1 text

Rust for Node.js Developers Giovanny Gongora / @gioyik

Slide 2

Slide 2 text

OUTLINE • What is Rust? • Why using Rust with Node.js • Rust inside Node.js • FFI on Node.js • Let’s do it • More ways?

Slide 3

Slide 3 text

WHAT IS RUST? 1. A systems programming language 2. It focuses on speed, safety and concurrency 3. Great fit to write programs with specific time requirements 4. Ability to write low level code, like device drivers 5. No garbage collector

Slide 4

Slide 4 text

What does it look like? You can run this on https://play.rust-lang.org if you don’t have Rust installed

Slide 5

Slide 5 text

WHY SHOULD I CARE?

Slide 6

Slide 6 text

WHY USING RUST WITH NODE.JS 1. Performance 2. Parallelism 3. Bindings

Slide 7

Slide 7 text

ANY REAL ADVANTAGE WE COULD SEE? Yes, but not today

Slide 8

Slide 8 text

RUST INSIDE NODE.JS (really?)

Slide 9

Slide 9 text

THE PROBLEM “Start ten threads. Inside each thread, count from one to five million. After all then threads are finished, print out ‘done!’”

Slide 10

Slide 10 text

Let’s create a new cargo project configure Cargo.toml

Slide 11

Slide 11 text

Edit the lib Build it

Slide 12

Slide 12 text

Create your node file Check the output

Slide 13

Slide 13 text

LET’S TRY A LESS COMPLEX EXAMPLE!

Slide 14

Slide 14 text

Let’s create a new cargo project configure Cargo.toml

Slide 15

Slide 15 text

Edit the lib Build it

Slide 16

Slide 16 text

Create your node file profit!

Slide 17

Slide 17 text

MORE WAYS?

Slide 18

Slide 18 text

LET’S TRY A COMPLEX EXAMPLE!

Slide 19

Slide 19 text

NEON Neon is a Rust bridge to the Node.js platform: an API (and a set of tools) for implementing binary Node modules in Rust

Slide 20

Slide 20 text

RUNO [PROTOTYPE] RuNo bridge is a command line tool which generates C++ boilerplate add-on code to call Rust library from.

Slide 21

Slide 21 text

CONCLUSIONS

Slide 22

Slide 22 text

SHOULD I TRY RUST?

Slide 23

Slide 23 text

SO, USE RUST INSTEAD OF JAVASCRIPT ON WEB APPLICATIONS?

Slide 24

Slide 24 text

THANKS! More info at Rust Inside Other Languages Giovanny Gongora / @gioyik