Giter Site home page Giter Site logo

yuttasakcom / rust-for-node-developers Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mercateo/rust-for-node-developers

0.0 1.0 0.0 2.69 MB

An introduction to the Rust programming language for Node developers.

License: Apache License 2.0

JavaScript 0.70% Rust 58.70% TypeScript 40.60%

rust-for-node-developers's Introduction

Rust for Node developers

An introduction to the Rust programming language for Node developers.

๐Ÿ’ก 2nd edition. I initially wrote this tutorial in the summer of 2016. Rust 1.0 was roughly a year old back than. This tutorial stayed quite popular over time even though I haven't added new chapters. As years passed by the Rust (and Node) ecosystem evolved further and this tutorial wasn't up-to-date with all changes. With the recent release of "Rust 2018" (which I'll explain later in more depth) I took the opportunity to update this tutorial as well. Enjoy the read! ๐ŸŽ‰

Hi there, I'm Donald. I'm a JavaScript developer who wants to learn Rust and as a part of this process I'll write here about my learnings. But what is Rust and why do I want learn it? Rust is a systems programming language like C or C++, but with influences from functional programming languages and even scripting languages like JavaScript. It feels very modern - which is no surprise, because it is a relatively young language. It went 1.0 in 2015! That doesn't only mean it is fun to write, because it has less clutter to carry around, it is also fun to use, because it has a modern toolchain with a great package manager. Rust's most unique feature is probably the compile-time safety check: it catches errors like segfaults without introducing a garbage collector. Or to phrase it differently: maximum safety with maximum performance.

Probably even more important than its features is the ecosystem and the community behind the language. Rust really shines here - especially for people who love the web. The language was (and still is) heavily influenced by developers from Mozilla. They have written servo, a modern browser engine, in Rust and parts of Firefox are now running Rust code. Rust is also great for authoring WebAssembly code (short: Wasm), a binary format for the web, which is supported in Firefox, Edge, Chrome and Safari.

To summarize: Rust is a young modern language with a great tooling and ecosystem, good safety and performance promises and which can be used for a lot of different projects - from low level tasks to command line tools and even web projects.

Before we dive into our tutorial we want to look at least once into a real Rust file:

fn main() {
    println!("Hello World!");
}

The JavaScript equivalent could roughly look like this:

function main() {
  console.log('Hello World!');
}

Nothing too scary, right? The ! behind println could be a bit confusing, but don't mind it for now. Just think of it as a special function.

How do we move on from here? First I'll guide you how my current setup looks like to use Node and Rust. Many people seemed to like that I introduce some convenient tooling and IDE configurations before actually speaking about Rust itself. But you can skip this chapter, if you want. After the setup step I'll create several kitchen sink like examples - first with Node and then with Rust. I'll try to explain them as best as I can, but don't expect in-depth explanations in every case. Don't forget that I'm trying to learn Rust - just like you. Probably you need to explain me some things, too! And before I forget it: my Node examples will be written in TypeScript! Writing them in TypeScript will make it a little bit easier to compare some examples to Rust.

One word about the structure of this tutorial before we start. Every chapter has its own directory. If a chapter has sub-chapters they also have sub-directories. And if a (subd-)chapter contains code examples, you'll find a node and a rust directory which contain all the code of this (sub-)chapter. (One example: The chapter "Package Manager" can be found inside package-manager/. It has the sub-chapter "Publishing" and the corresponding code examples can be found in package-manager/publishing/node/ and package-manager/publishing/rust/.)

Table of contents

  1. Setup
  2. Hello World
  3. Package Manager
  4. Read files
  5. Write files
  6. HTTP requests
  7. Parse JSON

Thank you for reading this tutorial. โ™ฅ

I highly appreciate pull requests for grammar and spelling fixes as I'm not a native speaker. Thank you!

rust-for-node-developers's People

Contributors

allyjweir avatar belfz avatar da-vaibhav avatar donaldpipowitch avatar donocode avatar echochamber avatar frankkair avatar joaosa avatar killercup avatar tracker1 avatar wwilfinger avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.