Archive for the tag: Compiler

Writing a compiler in F#. Bytecode and let-bindings

Money No Comments »

In this video we’ll extend the Fang compiler by adding support for let-bound variables to the codegen and the VM.

00:00 – Intro
00:44 – Plan
00:49 – Environment
01:59 – ConstPool: motivation
02:54 – ConstPool: implementation
05:12 – Var bytecode
05:57 – Bind bytecode
11:23 – Environment support in the VM
18:19 – Running and debugging the VM
20:37 – Summary
Video Rating: / 5

F# Compiler Service – F# Compiler Community Session

Money No Comments »

In this community session, Don Syme talks about how does FCS work, main components and principles.

To learn more about F# and its compiler, check out the following links.

F# compiler guide: https://github.com/dotnet/fsharp/blob/main/docs/compiler-guide.md
F# codebase: https://github.com/dotnet/fsharp
F# language and core library design suggestions: https://github.com/fsharp/fslang-suggestions/
F# language and core library designs: https://github.com/fsharp/fslang-design
F# core library documentation: https://aka.ms/fsharp-core-reference
F# language documentation: https://docs.microsoft.com/en-us/dotnet/fsharp/
Video Rating: / 5

This is the first video in a series focused on implementing a compiler backend for a small functional language which is a variation of the untyped λ-calculus. In this video we define the language’s AST and implement a tree-walking interpreter that does term reduction by substitution. We also explore ways to encode recursion via a fixpoint combinator as well as lazy and eager evaluation strategies.

00:00:00 Intro
00:01:53 High-level compiler structure
00:03:55 Plan
00:05:44 Project setup
00:10:02 Defining AST
00:15:51 Defining example lambda terms by hand
00:19:06 Evaluation by term reduction
00:21:20 Evaluating literals
00:22:47 Evaluating builtins: arithmetic
00:27:24 Evaluating builtins: comparison
00:29:37 Evaluating conditionals
00:30:59 Evaluating abstraction
00:32:31 Evaluating application
00:40:53 Evaluating variables
00:42:25 Debugging eval function
00:44:57 Bug found, continuing with more examples
00:48:27 Fixpoint combinator and recursion
00:56:43 Speed of evaluation
01:00:48 Eager vs lazy evaluation
01:05:55 Next up
Video Rating: / 5