Series: How to Make a Programming Language

1. What Does it Mean to Make a Programming Language?

May 13th 201918:32

In this drive by code session WaiKit and I start a series on the topic of making programming languages. I will give an overview on what it means to make a programming language and explain what is it that you’d be making if you want to make a programming language.

Watch “What Does it Mean to Make a Programming Language?”

2. Parsers and ASTs

Jun 13th 201908:50

I give an explanation of parsers and AST to prep you for the next episode of where we show you how to build a parser for a programming language.

Watch “Parsers and ASTs”

3. Building MyPL Part 1 - Parser

Jun 13th 201916:33

In this drive by code session I replay WaiKit’s code session where he builds a parser for a programming language called MyPL. This is part 3 in a series about building programming languages. I recommend watching the first 2 in the series before this one.

Watch “Building MyPL Part 1 - Parser”

4. Building MyPL Part 2 - Still Parser

Jun 24th 201921:35

In this drive by code session we finish build the parser for MyPL - the programming language we are making.

Watch “Building MyPL Part 2 - Still Parser”

5. Building MyPL Part 3 - Generator

Jun 24th 201918:48

In this drive by code session we finish building a programming language called MyPL by writing a generator that takes MyPL AST format and translates it to JavaScript. WaiKit writes the code and I replay it and explain what he did.

Watch “Building MyPL Part 3 - Generator”

6. How to Make a Parser using Nearley.js - Part 1

Jul 29th 201935:55

In this drive by code session we’ll show you what a context-free grammar is and how to use it and Nearley to build parsers. JSON is used as the example language we’ll build the parser for.

Watch “How to Make a Parser using Nearley.js - Part 1”

7. How to Make a Parser using Nearley.js - Part 2

Aug 2nd 201927:10

In this drive by code session we continue making a JSON parser. After having make a working parser for a subset of the functionality in JSON, we’ll introduce the ability to embed JavaScript code in the grammar to customize the result of a parse. Again, Waikit wrote the code, and I’ll replay them and explain what he did. Enjoy!

Watch “How to Make a Parser using Nearley.js - Part 2”

8. Make a Parser With Nearley.js - Part 3 - Handling Whitespace

Aug 15th 201911:00

In this drive by code session we’ll demonstrate how to handle whitespaces in a grammar using Nearley.js. The convention used in the video is based on the recommendations by Kartik Chandra - the creator of Nearley.js. As usual, Waikit drove the code before hand, and I’ll replay his code session and explain what he did.

Watch “Make a Parser With Nearley.js - Part 3 - Handling Whitespace”

9. How to Make a Parser with Nearley.js - Part 4 - Parsing String Literals

Aug 20th 201921:04

In this episode we’ll demonstrate how to parse a string literal in JSON properly, continuing our series on building parsers using Nearley.js.

Watch “How to Make a Parser with Nearley.js - Part 4 - Parsing String Literals”

10. How to Build a Parser with Nearley.js - Part 5 - Operator Precedence

Aug 20th 201920:51

Continuing in the series on making parsers, this time, we build a calculator that can add, subtract, multiply and divide. In particular, we tackle the issue of operator precedence.

Watch “How to Build a Parser with Nearley.js - Part 5 - Operator Precedence”

11. Build a Parser using Nearley.js - Part 6

Sep 10th 201909:06

In this episode we’ll implement parenthesis for overriding operator precedence in our arithmetic syntax. This is a continuation of the Nearley.js series for build parsers using JavaScript. Waikit wrote the code, and I replay his session and explain what he did.

Watch “Build a Parser using Nearley.js - Part 6”

12. Make a Parser with Nearley.js - Part 7

Sep 10th 201912:16

In this episode we’ll add function expressions to our arithmetic syntax and Toby was force to go off script as Waikit forgot to implement the power functions. We’ll see if Toby holds it together. Again we’ll use Nearley.js as the parser generator.

Watch “Make a Parser with Nearley.js - Part 7”

13. Make a Parser with Nearley.js - Part 8 - Making ASTs

Nov 6th 201929:45

In this episode, Waikit and I show you how to have your parser produce an AST - short for Abstract Syntax Tree. Also, I will answer a YouTube comment! Enjoy.

Watch “Make a Parser with Nearley.js - Part 8 - Making ASTs”

14. Making a ProgLang - Evaluating ASTs

Nov 8th 201930:24

In this drive by session Waikit and I continue our journey of building a baby programming language. Previous we created a parser that generates a AST representation of the code. Now we’ll write an evaluator that takes that AST as input and evaluates the result of the program.

Watch “Making a ProgLang - Evaluating ASTs”

15. How to Build a Code Generator

Nov 18th 201918:45

In this drive by code session WaiKai and I show you how to write a code generator: a program that spits out JavaScript code based on the AST (abstract syntax tree) of our small math arithmetic language.

Watch “How to Build a Code Generator”

16. The Fun Programming Language

Nov 18th 201913:15

I introduce a project that I’ve been working on: the Fun Programming Language. This project has 2 purposes: 1) to teach developers functional programming by allowing to choose between the functional style and the imperative style explicitly and enforcing it; 2) to give programming language learners a reference language to play with.

Watch “The Fun Programming Language”

17. Moo.js Tokenizer with Nearley.js

Feb 10th 202028:23

In this video I’ll introduce how to use the Moo.js lexer/tokenizer with Nearley.js. A lexer is a processing step commonly used to process the input string before the parser. It helps increase the performance of the parser, and as in the case of Moo.js, it also allows the parser to report errors with line number information.

Watch “Moo.js Tokenizer with Nearley.js”

18. Earley Parsing Algorithm

Jan 17th 202030:53

In this video I introduce the Earley Parser Algorithm and explain how it works with a small parsing example. The Earley Algorithm was invented by Jay Earley and is used by the nearley parser generator tool which I have covered in previous videos.

Watch “Earley Parsing Algorithm”

19. Generating Friendly Parser Errors with Earley Algorithm

Jan 22nd 202021:05

In this video, a follow up to the introductory video on the Earley Parsing Algorithm, I explain how Nearley.js produces user-friendly error messages whenever a parser error is encountered.

Watch “Generating Friendly Parser Errors with Earley Algorithm”

20. Make Your Own Language 1: The Lexer

Jul 18th 202016:01

This is the first episode of a series where you build your first programming language, using these videos as a guide. We’ve setup the syntax for a small programming language. You can clone this project and start getting to work. The project repository is https://github.com/airportyh/smallang.

Watch “Make Your Own Language 1: The Lexer”

21. Make Your Own Language 2: The Parser

Jul 18th 202021:06

This is the second episode of a series where you build your first programming language, using these videos as a guide. We’ve setup the syntax for a small programming language. You can clone this project and start getting to work. The project repository is https://github.com/airportyh/smallang. In this episode, we begin building the parser for the programming language, starting with variable assignment syntax.

Watch “Make Your Own Language 2: The Parser”

22. Make Your Own Language 3: Parsing Function Calls

Jul 19th 202016:25

This is the third episode of a series where you build your first programming language, using these videos as a guide. We’ve setup the syntax for a small programming language. You can clone this project and start getting to work. The project repository is https://github.com/airportyh/smallang. In this episode, we write implement the ability parser function calls in the parser and modify the parser to be able to handle multiple lines of code.

Watch “Make Your Own Language 3: Parsing Function Calls”

23. Make Your Own Language 4: The Generator

Jul 20th 202017:35

This is the fourth episode of a series where you build your first programming language, using these videos as a guide. We’ve setup the syntax for a small programming language. You can clone this project and start getting to work. The project repository is https://github.com/airportyh/smallang. In this episode, we write a code generator that produces JavaScript, in JavaScript.

Watch “Make Your Own Language 4: The Generator”

24. Make Your Own Language 5: Runtime Functions

Jul 20th 202011:40

This is the fifth episode of a series where you build your first programming language, using these videos as a guide. We’ve setup the syntax for a small programming language. You can clone this project and start getting to work. The project repository is https://github.com/airportyh/smallang. In this episode, we write some runtime functions to allow users of the language to have a baseline of capability.

Watch “Make Your Own Language 5: Runtime Functions”

25. Make Your Own Language 6: Parsing Lambda Functions

Jul 20th 202018:38

This is the sixth episode of a series where you build your first programming language, using these videos as a guide. We’ve setup the syntax for a small programming language. You can clone this project and start getting to work. The project repository is https://github.com/airportyh/smallang. In this episode, we write code to parse lambda functions: the most powerful feature of this language.

Watch “Make Your Own Language 6: Parsing Lambda Functions”

26. Make Your Own Language 7: White Space and Ambiguous Grammar

Jul 25th 202017:40

This is the seventh episode of a series where you build your first programming language, using these videos as a guide. We’ve setup the syntax for a small programming language. You can clone this project and start getting to work. The project repository is https://github.com/airportyh/smallang. In this episode, we add more proper whitespace handling to the language and run into some trouble, but nothing we can't debug our way out of.

Watch “Make Your Own Language 7: White Space and Ambiguous Grammar”

27. Make Your Own Language 8: Code Generator for Lambda

Jul 25th 202010:57

This is the eighth episode of a series where you build your first programming language, using these videos as a guide. We’ve setup the syntax for a small programming language. You can clone this project and start getting to work. The project repository is https://github.com/airportyh/smallang. In this episode, we make the code generator for lambda functions and actually get the fibonacci series program to work!

Watch “Make Your Own Language 8: Code Generator for Lambda”

28. Make Your Own Language 9: Comments and More Ambiguous grammar

Jul 27th 202010:10

This is the ninth episode of a series where you build your first programming language, using these videos as a guide. We’ve setup the syntax for a small programming language. You can clone this project and start getting to work. The project repository is https://github.com/airportyh/smallang. In this episode, add comments and start on working a code challenge by get side-tracked on debugging some more ambiguous grammar.

Watch “Make Your Own Language 9: Comments and More Ambiguous grammar”

29. Make Your Own Language 10: Coding Challenge

Aug 10th 202029:10

This is the tenth episode of a series where you build your first programming language, using these videos as a guide. We’ve setup the syntax for a small programming language. You can clone this project and start getting to work. The project repository is https://github.com/airportyh/smallang. In this episode, we struggle through the roman numerals coding challenge, and see if this programming language is worth anything.

Watch “Make Your Own Language 10: Coding Challenge”

30. Parser Performance Story

Aug 24th 202024:20

I tell my story and show the results of improving the performance of the jsonr parser (github.com/airportyh/jsonr) written using Nearley.js. This video demonstrates parser code in a real world scenario and also gives performance tips regarding Nearley.js and beyond.

Watch “Parser Performance Story”

31. dabeaz's Compilers Course And X86 Registers

Mar 10th 202115:22

In this video I tell Huiqi about David Beazley's "Write a Compiler" course and X86 registers.

Watch “dabeaz's Compilers Course And X86 Registers”

32. Fun with ASTs

Aug 4th 202158:01

This is a 1-hour lecture and demo I did for Insiten's Algorithm Friyay. I introduce ASTs (Abstraction Syntax Trees), how to get them in JavaScript, and we write code to traverse an AST. Unfortunately I failed to record the audio for the attendees, so you can only hear one side of our conversations.

Watch “Fun with ASTs”

33. Fun with AST Part 2

Aug 6th 202159:56

This is the second hour-long lecture on ASTs which I did for Insiten's Algorithm Friyay. We finish building a script that can tell which variables in a JavaScript program are unused by traversing an AST of the program.

Watch “Fun with AST Part 2”

34. Compilers Challenge #1: Reverse Polish

Oct 25th 202114:40

I am starting a new series about compilers called Compilers Challenge and this is episode 1. For each "compilers challenge", first I will present a video with a problem for you to solve. You are to solve this code challenge at home. Then, in a separate video coming out about a week later, I will present my solution to the challenge. To get the most of this experience, I recommend that you give the challenge a faithful attempt before view my solution. The first episode is on Reverse Polish Notation: https://en.wikipedia.org/wiki/Reverse_Polish_notation. Here is the text of the challenge as it is written on leetcode.com: https://leetcode.com/problems/evaluate-reverse-polish-notation/. Good luck!

Watch “Compilers Challenge #1: Reverse Polish”

35. Compilers Challenge #1 Solution: Reverse Polish

Nov 2nd 202118:21

This is the solution to the first compilers challenge: Reverse Polish, which can be found here: https://tobyho.com/video/Compilers-Challenge-1-Reverse-Polish-Notation.html You can find all compilers challenges here: https://github.com/airportyh/compilers_challenge

Watch “Compilers Challenge #1 Solution: Reverse Polish”