Brendan Eich, Bjarne Stroustrup, Graydon Hoare

Things people tell me that they know: “full-stack JavaScript is the Future”, “everyone should know C”, “Rust is the best language for Systems Programming”… Most people hear stuff like this, and say to themselves, is that true? ~ Haseeb Qureshi, Converge: Why Engineers Disagree About Everything (Talk)

Migrating between C++, JavaScript and Rust today has never been easier, language features/syntax seem to be converging, recent updates to each language added features exclusive to other languages.


// JS         // C++         // Rust
let x = 4; auto x = 4; let x = 4;


  • ECMAScript 2017 (JS) now features shared memory and atomics, and even things like threads are possible through service workers.
  • C++ 17 now features array destructuring, and upcoming features like modules will make the language even closer to higher order languages.
  • Rust now has a TypeScript-like Language Server, which is similar to Visual Studio’s C++ Intelisense.

Performance across each language is also getting closer:

  1. JavaScript’s WebAssembly proposal is bringing with it a huge boost in performance, and regular JavaScript is among the fastest dynamically typed languages out there. (Ruby, Python, etc.)
  2. C++ through it’s long history of focusing on performance, has always been extremely fast.
  3. Rust is fast, at times even better than C/C++ in performance, according to The Computer Language Benchmarks Game K-Nucleotide benchmark.

Table of Contents

  1. Installation — Get off the ground and programming immediately.
  2. Modules — Creating and installing modules, and how to structure your modules/applications.
  3. Syntax — An overview of the syntax differences of each language.


Brendon Eich is known as a bit of an apologist because of some bad decisions early on with the language, nevertheless, thanks to no small effort on the part of the many people contributing to the evolution of the language, modern JavaScript is a pleasure to develop in.


Download and install the Node Version Manager for your machine:

Then open up a terminal such as Hyper and type:

nvm install node
nvm use node

Or you can visit The Node Foundation and download the current version of Node.

Alternatively you can visit a code editing website like Codepen, but bear in mind there are missing features between browser and server versions of JS.

There’s also TypeScript and Flow, tools that add static type checking to the JavaScript language.

Recommended — Use a Type checker like TypeScript or Flow for your code.

File Structure

├─ src/
│ ├─ api/
│ │ └─ index.js
│ └─ main.js
└─ package.json


# Installing Packages
npm i <package-name>
# Running Programs
node <javascript-file-name>


C++ is a mature language that has a lot of heritage. Developed by Bjarne Stroustrup in Bell Labs as an extension to C, it became its own language once people coming from C began to see how much more maintainable their codebases were with class hierarchies and template metaprogramming.


No matter what platform you’re developing on, you’ll want to have the following tools:

  • CMake — The most popular package toolchain for C++, abstracts your project away from your IDE and makes compiling libraries easier.
  • Conan — The most popular C++ package manager, makes dependency management in C++ much easier.


Download Visual Studio 2017 Community Edition.


apt-get install gcc
# or
apt-get install clang


Download XCode.


Rust has become pretty popular, with exciting research projects ranging from using it to build web browsers like Servo to even entire operating systems and game engines.

This is thanks to the strong emphasis on ergonomics, performance, and security that the Rust standard body pushes for.

Jack Moffitt, developer for the Rust powered browser Servo, said on The Changelog that:

“All of [ our security critical bugs with Firefox WebAudio ] were array out of bounds/use after free errors and all of them would have been prevented by the Rust compiler [ instead of C ].”



Visit to get an installer .exe.

Linux / OSX

curl -sSf | sh
# You should see:
# Rust is installed now. Great!

From there you can easily find integrations with code editors like VS Code or Atom.

File Structure

In Rust, any folder can be a module if it has a Cargo.toml file (which is basically an .ini file similar to NPM's package.json), and often you'll see a script to handle building the package as well.

├─ src/
│ ├─ api/
│ │ └─ # Same as index.js in commonjs
│ └─
├─ Cargo.toml
└─ # (Optional) Same as build script in node

Here’s a sample Cargo.toml file:

name = "multitouch-fabric-visualizer"
version = "0.1.0"
authors = ["Alain Galvan <>"]
build = ""
serial = "0.3.4"
cpal = "0.4.4"
winit = "0.5.2"
vulkano = "0.3.2"
vulkano-win = "0.3.2"
vk-sys = "^0.2.2"
vulkano-shaders = "0.3.2"


#Installing packages requires you to edit your Cargo.toml file.# Check for errors
# Recomended: Use Rust Language Server
cargo check
# Run program
cargo run
# Compile Executable
cargo build # Use the --release flag for a production build


Imports, Namespaces, Exports

With node, every JavaScript file is treated as an isolated module, and the index.js file of a given folder indicates the folder's root JavaScript file.

// 💛 TypeScript// Import (Package `fs` is included with node)
import fs from 'fs';
// Namespace
const { readFileSync } = fs;
// Export
export function myexport(code: string): number {
return 0;
// Export all from module
export * from './localmodule';

Until C++ Modules come along, the following is the standard way of modularizing code. There’s no strict path rules in C++.

// 💙 C++// Import
#include "istream"
//Need the following imports for types
#include "stdio.h"
#include <string>
// Namespace
using namespace std;
// any declaration is exported by default
uint32_t myexport(string code)
return 0;

Modules in Rust follow the convention of having indicate the root module of a given folder, and every submodule must be declared with the keyword mod.

// 💖 Rust
// Import
// External package from cargo
extern crate winit;
// Local module (must be declared)
mod localmodule;
// Namespace
use std::*;
// Export
pub fn myexport(code: &str) -> u32 {
return 0;
// Export from local module
pub use self::localmodule::*;


Enums don’t exist in JavaScript, but are available in TypeScript:

// 💛 TypeScript
enum Enums {
// 💙 C++
enum class Enums {
// 💖 Rust
enum Enums {


JavaScript doesn’t have types, so no need to define structs. Types aren’t limited to being just structs in TypeScript though.

// 💛 TypeScript / Flow
type Structs = {
property: number
// 💙 C++
struct Structs
uint32_t property;
// 💖 Rust
struct Structs {
property: u32


// 💛 JavaScript
class MyClass {
constructor(member = 0) {
this.member = member;
mutateMember() {
this.member += 1;
let o = new MyClass();

Normally in C++ you would declare your class in a header .h or .hpp file, and write the implementation in a .cpp file.

Alternatively you can use just a header and write the implementation as inline statements, or write the implementation in the class, but you’ll need to juggle when you declare variables/functions due to there not being declaration hoisting.

// 💙 C++
class MyClass
uint32_t member = 0; MyClass(uint32_t pMember) : member(pMember)
} void mutateMember() {
member += 1;

In Rust, there is no keyword class, instead you can create class-like constructs through a struct to represent your state, and implementation blocks (impl), which are sort of like cpp files.

// 💖 Rust
struct MyClass {
member: u32;
impl MyClass { fn new() -> MyClass {
MyClass {
member: 0
fn mutate_member(&mut self) {
self.member += 1;


JavaScript features 2 function types, the first being a function bound to the global scope unless specified otherwise, and the second being bound to the scope of where the function was declared, Fat Arrow Functions.

// 💛 JS
function myFunction() {
return 0;
let lambda = () => null;

In C++ lambdas are denoted with a scope capture [...scopevars], followed by the standard parenthesis for arguments and curly brace for the body of the function () { }.

// 💙 C++
uint32_t myFunction() {
return 0;
// If there's no args in the function, you can omit the ()
auto lambda = []()
return nullptr;

In Rust lambdas follows the signature |...params| { body }, with the curly braces around the body being optional.

// 💖 Rust
fn my_function() -> u32 {
fn ten_times<F>(f: F) where F: Fn(i32) {
for index in 0..10 {
ten_times(|j| println!("hello, {}", j));


// 💛 JS// Array Destructuring
let arr = [1, 2, 3, 4, 5];
// Grab 1, and [2, 3, 4, 5]
let [first,] = arr;
// Object Destructuring
let obj = {
x: 1,
y: 2,
z: 3
// Grab variables from obj
let {x, y, z} = obj;

C++ 17 recently added destructuring as a native language feature:

// 💙 C++std::array<uint32_t, 5> arr = { 1, 2, 3, 4, 5 };// Rest operator isn't available
auto [first, second, third] = arr;

Rust has intuitive destructuring for Structs and arrays:

// 💖 Rust// Array Destructuring
let arr = [0, 1, 2, 3, 4, 5];
let [first,] = arr;// Object Destructuring
struct Obj {
x: u32,
y: u32,
z: u32
let obj = Obj { x: 0, y: 0, y: 0 };let Obj { x, y, z } = obj;


// 💛 TypeScript / Flow
type Renderable = {
render: () => void

C++ interfaces are possible through classical inheritance.

// 💙 C++
class Renderable {
virtual void render();
// 💖 Rust
trait Renderable {
pub fn render(&self);


There’s no such thing as templates/generics in JS, but you do have Generics in TypeScript and Flow.

// 💛 JS
function lol<T>(what: T) {
}// 💙 C++
template<typename T>
void lol(T what)
}// 💖 Rust
fn lol<T>(what: T) {

Common Modules

// 💛 JS
import fs from 'fs';
import path from 'path';
// 💙 C++
#include "ifstream"
#include "path"
// 💖 Rust
use std::io;
use std::path;

Conclusion & Further Reading

Getting a full grasp of a programming language to the point where you’re able to write anything takes time, however reading each language’s manual will help tremendously.


The TypeScript Handbook gives a clear introduction to the newest JavaScript features as well as teaching best practices with the TypeScript toolset.

For more resources, check out my post on developing javascript applications.


The C++ Programming Language book by the author of the language, Bjorne Strustrup, is a great summary of the entire language.

For more resources, check out my post on designing C++ libraries..


Rust features advanced variable binding patterns that come from functional programming, so be sure to review the chapter on patterns.







-- | Graphics Software Engineer @ AMD, Previously @ Guest lecturer talking about 🛆 Computer Graphics, ✍ tech author.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium


Getting started with Assembly

So, lets talk about utility….💰

Introduction to the interval tree

Flashing ROM using SP Flash Tool

How to create beautiful Matplotlib trends in Python

The MetaInfluencers NFT (Part 1)

10 Features in Sheets Excel Needs

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Alain Galvan

Alain Galvan | Graphics Software Engineer @ AMD, Previously @ Guest lecturer talking about 🛆 Computer Graphics, ✍ tech author.

More from Medium

C++11 raw string literal delimiter

Solving a few functional programming exercises using Elixir

Haskell basics: Expressions and Equations

Coding in MS-DOS Batch