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

How NodeJS Works

How NodeJS Works

A short overview of how NodeJS actually works for CNTU students.

Avatar for Volodymyr Rudyi

Volodymyr Rudyi

January 30, 2020
Tweet

More Decks by Volodymyr Rudyi

Other Decks in Programming

Transcript

  1. A bit of JavaScript history • Created in 1993 •

    First standard in 1996 • Latest standard in 2017 • Used on clients and servers
  2. Execution environments 101 • Allows executing JavaScript code • Works

    on a particular platform/set of platforms • Provides an additional API to interact with the platform
  3. NodeJS Provides tools for • Interaction with file systems (fs)

    • Console (console.log) • Timer (setTimeout) • Debugging and profiling (Inspector/Chrome Dev Tools) • Thousands of other stuff • These features are called NodeJS API
  4. V8 • Not a Mustang GT • A JavaScript Engine

    developed by Google • Written in C++ • Knows how to parse and execute JavaScript code • Knows nothing about browsers, files, operating systems
  5. Summary • Programmer writes JavaScript code and passes it to

    the NodeJS(Execution Environment) • Execution environment passes the code to the V8 engine • V8 engine parses code and executes it • Each time API is used, V8 calls the corresponding code from the execution environment (using so-called “bindings”)
  6. Idea • It’s possible to create your own custom execution

    environment • It’s should be easy
  7. Embedding V8 - Pros • Wide set of features •

    Performance • Inspection/analysis using Chrome Dev Tools protocol • It’s native
  8. Embedding Rhino - Pros • Java-based API • Can be

    almost instantly embedded to some platforms, like Android • Non-native code running in JVM