terminal
Course Description
Bend your mind with programming TypeScript, Go, and Rust side-by-side. Get an overview of each language's basics and solve some example problems with each language. In the end, you will have built a fully unit-tested CLI application in TypeScript, Go, and Rust. Become a polyglot programmer and learn to get the most of multiple programming languages!
This course and others like it are available as part of our Frontend Masters video subscription.
Preview
CloseWhat They're Saying
Same CLI tool implemented in TypeScript, Go and Rust for comparison.

Andy
_andys8
Course Details
Published: August 13, 2022
Learning Paths
Learn Straight from the Experts Who Shape the Modern Web
Your Path to Senior Developer and Beyond
- 200+ In-depth courses
- 18 Learning Paths
- Industry Leading Experts
- Live Interactive Workshops
Table of Contents
Introduction
Section Duration: 14 minutes
- ThePrimeagen introduces the course by discussing the reasoning behind using three languages in this course and providing some personal background information. The course workflow, what languages students came to learn, and a general course overview are also covered in this segment.
Fundamentals
Section Duration: 1 hour, 14 minutes
- ThePrimeagen live codes the same function in TypeScript, C++, and Rust to demonstrate some base language similarities and differences. The Rust borrow checker is tasked with enforcing that all variables are initialized before they are used, the same value can't move twice, and a value can't move while it is borrowed.
- ThePrimeagen discusses the three types of Rust values, values, references, and mutable references. Values can have only one owner, many references can exist with the constraint that there are no mutable references alive, and one mutable reference and no reference can exist simultaneously.
- ThePrimeagen walks through creating enums in TypeScript, Go, and Rust to demonstrate the extent of enum support in each language. Rust allows enums with many types, including generic, which can be helpful for many typed lists, nullable, and error handling.
- ThePrimeagen answers student questions regarding whether you can have an enum that points to itself, why the map has a reference, and what the enum's owner is. A brief discussion regarding macros in Rust is also covered in this segment.
- ThePrimeagen live codes map and is_some in Rust on the "option" type to demonstrate Rust's ability to specify additional behaviors by writing functions inside enums. A student's question regarding if impl is a Java interface is also answered in this segment.
- ThePrimeagen briefly walks through the error handling in JavaScript and TypeScript and live codes error handling in Go and Rust. In Go, errors are pointers under the hood, so they return the empty type. Rust can handle errors using enums (sumtypes) with the Result type.
- ThePrimeagen briefly walks through the unit testing organization and example code for TypeScript, Go, and Rust. Unit testing with Rust happens in the file and can test private interfaces.
Submarine Navigation
Section Duration: 38 minutes
- ThePrimeagen provides an overview of the submarine navigation problem from Advent of Code. The rules of the problem are as follows: The submarine starts at position 0,0 (x position, depth), parse the input to direct the submarine, and multiply the depth * x progression to get an answer.
- ThePrimeagen walks through the TypeScript version of the solution to the submarine navigation problem.
- ThePrimeagen walks through translating the TypeScript solution into the Go version of the solution to the submarine navigation problem. A student's question regarding if underscore is a reserved variable name for the Go compiler to skip if it's not used.
- ThePrimeagen walks through translating the TypeScript solution into the Rust version of the solution to the submarine navigation problem.
Fissures
Section Duration: 47 minutes
- ThePrimeagen provides an overview of the fissures problem from Advent of Code. The rules of the problem are as follows: The given lines are ((x1, y1) -> (x2, y2)), only consider horizontal and vertical lines; the end goal is to parse the string.
- ThePrimeagen walks through the TypeScript solution to the Fissures problem.
- ThePrimeagen walks through the Go solution to the Fissures problem. This solution uses pointers, so there is no inlining, but there is a string function that can be implemented to include inlining.
- ThePrimeagen walks through installing Cargo, a Rust package manager, and the anyhow error type.
- ThePrimeagen live codes the Rust solution to the Fissures problem.
- ThePrimeagen answers student questions regarding name collisions with traits, if traits can be on enums, what happens if &self is passed to foo, and if you can override a preexisting trait such as a system library.
Count Trees
Section Duration: 26 minutes
- ThePrimeagen provides an overview of the count trees problem from Advent of Code and the problem's initial input. The goal of the problem is to count the total number of trees that would be hit while traveling, three right and one down, until the bottom is reached.
- ThePrimeagen walks through the TypeScript solution to the count trees problem.
- ThePrimeagen walks through the Go solution to the count trees problem.
- ThePrimeagen walks through the Rust solution to the count trees problem.
- ThePrimeagen discusses common language pitfalls, including value and pointer receivers in Go, differences between Go structs and Rust structs, and errors returning pointers when using Go. When using Rust, keep the following in mind: utilize traits for new behavior, the power of iterators, and the Option and Result on .map and iterator flat_map.
CLI
Section Duration: 44 minutes
- ThePrimeagen briefly walks through the base structure of a project in each language. Including a lib.rs file to contain modules in a Rust project creates a reference point for the bin folder; this allows for exporting various files into the project binaries.
- ThePrimeagen provides an overview of the course CLI project, Projector, and how the problem will be approached. Projector is a simple CLI application that stores, deletes, or presents variables based on the current working directory or provided path.
- ThePrimeagen walks through the setup for the TypeScript version of the CLI project. The goal of this segment is to get the command line arguments and turn them into an object that can be manipulated.
- ThePrimeagen walks through the setup for the Go version of the CLI project by implementing a simple CLI parser to parse out the args, config, and pwd.
- ThePrimeagen walks through the Rust version of the CLI project utilizing the clap CLI parser and Rust macros. A student's question regarding if every library used in the project needs to be imported at the top of the page is also answered in this segment.
Projector Object
Section Duration: 1 hour, 5 minutes
- ThePrimeagen demonstrates how to build the Projector object in TypeScript. This will require a struct that takes a defined config, a possible present working directory, operation, and arguments.
- ThePrimeagen walks through creating the Projector object in Go. The functions getConfig, getOperation, and getArgs retrieve the needed information or throw errors, and the NewProjectorConfig creates a new Projector object.
- ThePrimeagen live codes the operation part of the Projector object in Rust while utilizing traits to define the functionality of each term.
- ThePrimeagen walks through implementing the present working directory and config for the Rust version of the Projector object.
Testing
Section Duration: 44 minutes
- ThePrimeagen demonstrates how to create and run tests in TypeScript and what a thrown error looks like. Suggestions for the amount of testing that should be done on a project are also provided in this segment.
- ThePrimeagen walks through testing the projector project in Go with the built-in testing package and test command. A student's question regarding the phrase "black box testing" is also covered in this segment.
- ThePrimeagen demonstrates testing the projector project using Rust. Rust provides features specifically for writing tests, including the test attribute, a few macros, and the should_panic attribute.
- ThePrimeagen answers student questions regarding if Rust files can get large due to the tests being included and if naming the functions starting with test_ is just a convention. Questions regarding whether only the macro test is relevant for running tests and the trade-offs of having in-file tests are also covered in this segment.
Projector
Section Duration: 2 hours, 52 minutes
- ThePrimeagen live codes the base for the TypeScript version of the Projector CLI App. Importing the config, creating a data object, and making the base for the add, remove, set, and get operations are covered in this segment.
- The Primeagen walks through implementing the TypeScript Projector CLI application's add, remove, set, and get operations. A brief discussion regarding the basename and dirname utilities is also covered in this segment.
- ThePrimeagen demonstrates creating a series of tests for the TypeScript Projector CLI application. The tests check for the correct present working directory, restrictions on setting and deleting data, and the ability to retrieve data from various directory levels.
- ThePrimeagen live codes the base for the Go version of the Projector CLI App using the map syntax. This segment covers the serializing to JSON, creating the Config and Data structs, the GetValue function, and the GetValueAll function.
- ThePrimeagen walks through implementing the SetValue, RemoveValue, NewProjector, and defaultProjector for the Go version of the Projector CLI. The NewProjector function uses the package os to interface with operating system functionality.
- ThePrimeagen demonstrates creating a series of tests for the Go Projector CLI application. The tests check for the correct present working directory, restrictions on setting and deleting data, and the ability to retrieve data from various directory levels.
- ThePrimeagen walks through creating the base for the Rust version of the Projector CLI App utilizing the Serde framework. Creating a projector from a config, creating a data struct, and the base for get_value are covered in this segment.
- The Primeagen walks through implementing the Rust Projector CLI application's get_value, get_value_alll, delete_value, and set_value operations. The get_value_all will use a HashMap with Rust inferring the path types.
- ThePrimeagen demonstrates creating a HashMap testing suite using the collection_macros package for the Rust version of the Projector CLI application. A demonstration of correcting thrown errors is also covered in this segment.
- ThePrimeagen asks students some questions regarding what they think of Go and Rust.
- ThePrimeagen walks through setting up and using the TypeScript Projector CLI built throughout this course. Retrieving the options and projector, saving the config, and implementing the previously created operations are covered in this segment.
- ThePrimeagen walks through setting up and using the Go Projector CLI built throughout this course. Creating the projector, saving the config, and implementing and running the previously created operations are covered in this segment.
- ThePrimeagen walks through setting up and using the Rust Projector CLI built throughout this course. This portion will be written in two phases, saving the data and implementing the primary control file.
Wrapping Up
Section Duration: 2 minutes
- ThePrimeagen wraps up the course by providing some closing thoughts on polyglot programming and briefly discussing other Frontend Masters courses.
Learn Straight from the Experts Who Shape the Modern Web
- In-depth Courses
- Industry Leading Experts
- Learning Paths
- Live Interactive Workshops