Название: From Source Code To Machine Code: Build Your Own Compiler From Scratch Автор: James Smith Издательство: Leanpub Год: 2023-05-18 Страниц: 102 Язык: английский Формат: pdf (true), epub, mobi + Extras Размер: 10.2 MB
Ever wondered how computers turn source code into working software? You can learn the art by building your own mini-compiler. A succinct book walks through a minimal yet complete compiler implementation. Compiles a static-typed language into x64 ELF executables.
Compilers are a fascinating topic. You use them every day. They turn your textual source code into some binary magic executed by computers. Ever wondered how they work? You can learn all of this by coding a mini-compiler by yourself, thus removing a mystery from your mind. Compiler construction is a subject included in Computer Science and software engineering education. However, many of today’s (2023+) coders do not have a formal CS education. Basic things such as compilers, databases, operating systems, etc. are often seen as magical black boxes. That’s why I started the “Build Your Own X” book series. To learn and teach basic things by the “from scratch” approach, through succinct & condensed books. It’s also considered a fun side project that just cost you some free time.
Like my other books, this book follows a step-by-step approach. You start with simple things, like a calculator, then a simple interpreter. Then you tackle the compiler bit-by-bit, compiling to bytecode, learning assembly, and finally generating native executables. The final product is a small, statically typed language that resembles a subset of C, which compiles into x64 Linux ELF executables. And it has a machine-agnostic IR, so it’s not hard to target other platforms such as ARM, which is a challenge you can take up later. The project is written from scratch in pure Python without any dependencies, although everything is language agnostic.
Contents:
01. Introduction 02. A Simple Calculator 03. Interpreter: Variables and Scopes 04. Interpreter: Control Flows and Functions 05. How Computers Work 06. The Virtual Machine and Bytecode 07. Compiler: Variables and Expressions 08. Compiler: Control Flows 09. Compiler: Functions and Non-Locals 10. A Crash Course on x64 Assembly 11. The x64 Instruction Encoding 12. From Virtual Machine To Real Machine 13. Binary Executables 14. Pointers and Memory
Скачать From Source Code To Machine Code: Build Your Own Compiler From Scratch
|