Programming Language with LLVM

所在平台: Udemy

课程主页: https://www.udemy.com/course/programming-language-with-llvm/

课程评论:没有评论

第一个写评论        关注课程

课程简介

课程名称:使用LLVM的编程语言 课程概述: 本课程旨在解答诸如编程语言的底层工作原理、编译器与解释器的区别、虚拟机以及JIT编译器的概念等问题。许多学校的“编译器课程”往往被视为仅适合高级工程师的“硬核火箭科学”。传统的编译器书籍通常从最低级的主题开始,如词法分析,直至形式语法的理论层面,这使得学生在实现第一个分词器模块时失去兴趣,因为他们无法直接参与编程语言的实现过程。本课程的目标是让学生在4到6小时之内理解并构建完整的编程语言语义,内容直接切中要点,通过实时编码会话进行配对编程,以通俗易懂的方式加以描述。 在“使用LLVM的编程语言”课程中,我们将专注于将语言编译为LLVM IR,构建一个更低级的编程语言。通过紧密接触LLVM编译器基础设施,学员将理解现代生产级语言(如C++、Rust等)的底层编译原理。此外,实现编程语言将提升学员在其他编程语言上的实际能力。 先决条件: 该课程有三个先决条件。首先,“使用LLVM的编程语言”课程是对之前课程“从零开始构建解释器”(即解释的基础)和“构建虚拟机”的自然扩展。这些课程让学员在AST层面上构建完整的编程语言。学员需要理解eval、闭包、作用域链、环境及其他构造。其次,由于需要了解生产语言所在的更低级别(位码/IR),学员需具备基础的C++经验。课程中将主要使用C++的基本特性,不会过多涉及C++的具体细节。课程内容也可轻松转化和移植到其他语言,如Rust或Python。 课程目标群体: 本课程适合任何有好奇心的工程师,希望获得构建复杂系统的技能,构建编程语言是一个高级工程任务!如果你对LLVM及其编译器基础设施感兴趣,并希望自己构建语言,本课程同样适合你。 实现所用工具: 低级编译器通常涉及到性能问题,通常用C或C++这样的低级语言实现。本课程将采用C++的基本特性,确保代码易于转化和移植到其他语言。我们鼓励学生在实现LLVM编译器的每个细节时,亲自尝试,而不是单纯地复制最终解决方案。 课程特色: - 每节课内容简明扼要,自成体系,聚焦于相关主题。 - 动画演示结合实时编辑笔记,便于理解复杂内容。 - 从头到尾的实时编码会话,提供完整的代码来源。 课程大纲: 课程共分为四个部分,包括20节讲座及每节讲座的多个子主题。 第一部分:LLVM基础构造 讨论编译和解释的流程,开始构建语言,涉及LLVM IR、对象及位码的编译等主题。 第二部分:函数和栈 实现控制流结构,如if表达式和while循环,讨论栈变量、嵌套块、局部变量及函数编译。 第三部分:面向对象编程 实现面向对象的概念,如类、实例,讨论堆分配和垃圾收集器。 第四部分:高阶函数 关注闭包、函数式编程、lambda函数,最终实现可执行代码。 该课程将为学员提供一个全面、实用的编程语言构建知识体系。

课程评论(0条)

课程详情

Course overviewHow programming languages work under the hood? What's the difference between compiler and interpreter? What is a virtual machine, and JIT-compiler? And what about the difference between functional and imperative programming?There are so many questions when it comes to implementing a programming language!The problem with "compiler classes" in school is such classes are usually presented as some "hardcore rocket science" which is only for advanced engineers.Moreover, classic compiler books start from the least significant topic, such as Lexical analysis, going straight down to the theoretical aspects of formal grammars. And by the time of implementing the first Tokenizer module, students simply lose an interest to the topic, not having a chance to actually start implementing a programing language itself. And all this is spread to a whole semester of messing with tokenizers and BNF grammars, without understanding an actual semantics of programming languages.I believe we should be able to build and understand a full programming language semantics, end-to-end, in 4-6 hours - with a content going straight to the point, showed in live coding sessions as pair-programming and described in a comprehensible way.In the Programming Language with LLVM class we focus on compiling our language to LLVM IR, and build a lower-level programming language. Working closely with the LLVM compiler infrastructure level you will understand how lower-level compilation and production-level languages, such as C++, Rust, etc work today.Implementing a programing language would also make your practical level in other programming languages more professional.PrerequisitesThere are three prerequisites for this class.The Programming Language with LLVM course is a natural extension for the previous classes - Building an Interpreter from scratch (aka Essentials of Interpretation), where we build also a full programming language, but at a higher, AST-level, and also Building a Virtual Machine. Unless you already have understanding of how programming languages work at this level, i.e. what eval, a closure, a scope chain, environments, and other constructs are - you have to take the interpreters class as a prerequisite.Also, going to lower (bitcode/IR) level where production languages live, we need to have basic C++ experience. This class however is not about C++, so we use just very basic (and transferrable) to other languages constructs.Who this class is for?This class is for any curious engineer, who would like to gain skills of building complex systems (and building a programming language is an advanced engineering task!), and obtain a transferable knowledge for building such systems.If you are interested specifically in LLVM, its compiler infrastructure, and how to build your own langauge, then this class is also for you.What is used for implementation?Since lower-level compilers are about performance, they are usually implemented in a low-level language such as C or C++. This is exactly what we use as well, however mainly basic features from C++, not distracting to C++ specifics. The code should be easily convertible and portable to any other language, e.g. to Rust or even higher-level languages such as Python. Using C++ also makes it easier implementing further JIT-compiler.Note: we want our students to actually follow, understand and implement every detail of the LLVM compiler themselves, instead of just copy-pasting from final solution. Even though the full source code for the language is presented in the video lectures, the code repository for the project contains /* Implement here */ assignments, which students have to solve.What's specific in this class?The main features of these lectures are:Concise and straight to the point. Each lecture is self-sufficient, concise, and describes information directly related to the topic, not distracting on unrelated materials or talks.Animated presentation combined with live-editing notes. This makes understanding of the topics easier, and shows how the object structures are connected. Static slides simply don't work for a complex content.Live coding session end-to-end with assignments. The full source code, starting from scratch, and up to the very end is presented in the video lecturesWhat is in the course?The course is divided into four parts, in total of 20 lectures, and many sub-topics in each lecture. Below is the table of contents and curriculum.Part 1: LLVM Basic constructsIn this part we describe compilation and interpretation pipeline, starting building our language. Topics of LLVM IR, object, compilation of the bitcode are discussed.Part 2: Functions and StackIn this part we implement control flow structures such as if expressions and while loops, talk about stack variables, nested blocks and local variables, and also compile functions.Part 3: Object-oriented programmingIn this part we implement OOP concepts, such as classes, instances, talk about heap allocation, and garbage collectors.Part 4: Higher-order functionsIn this part we focus on closures, functional programming, lambda functions, and implement the final executable.

课程标签

0人关注该课程

主题相关的课程