Building an Interpreter from scratch

所在平台: Udemy

课程主页: https://www.udemy.com/course/essentials-of-interpretation/

课程评论:没有评论

第一个写评论        关注课程

课程简介

课程总结:从零开始构建解释器 课程名称:从零开始构建解释器 课程概述:该课程探讨了编程语言的底层工作原理,解释了编译器与解释器的区别,虚拟机与即时编译器(JIT)的概念,以及功能性编程与命令式编程的差异。传统的编译器课程通常呈现得过于复杂,使得许多学生在学习初期便失去兴趣。本课程的创新之处在于通过4-6小时的高效教学,使学生能够直观理解编程语言的语义,并通过现场编码进行实践。整体课程内容紧凑、有序,重点放在运行时语义上,目标是为学生构建一个与JavaScript或Python类似的编程语言解释器。 适合人群: 本课程适合任何对构建复杂系统感兴趣的工程师,尤其是对编译器、解释器及源代码转换工具有兴趣的人。只需具备基本的数据结构和算法知识,如树、列表和遍历。 实现工具: 我们将使用JavaScript作为实现语言,因为其优雅的多范式结构最适合本课程中涉及的内容。课程提供的代码还易于移植到TypeScript、Python、Java、C++、Rust等其他语言。 课程特点: - 课程内容简明扼要、直击要点,每节课自成体系,避免无关的材料干扰。 - 动态演示和现场编辑笔记相结合,帮助学生更好地理解复杂主题,掌握对象结构的连接。 - 每节课包括现场编码和作业,提供从零开始构建完整AST解释器的源码。 课程内容分为四个部分,共18节课,具体如下: **第一部分:编译器快速入门** 介绍不同的编译和解释管道,JIT与AOT编译器的区别,虚拟机、字节码解释器及AST解释器的概念,以及本地代码和LLVM IR等示例。 **第二部分:解释器:基本表达式与变量** 开始构建编程语言,讨论基本表达式(如数字、字符串)、变量、作用域和词法环境、控制结构,以及解析器生成器的基础知识。 **第三部分:函数与功能性编程** 实现函数抽象和函数调用,讨论闭包、匿名函数和立即调用的匿名表达式(IILEs),以及调用栈、递归和语法糖的概念。 **第四部分:面向对象编程** 专注于语言中的面向对象支持,讨论基于类和基于原型的方法,实施类、实例和模块的概念。 希望您能享受这门课程,并欢迎在评论中讨论任何问题或建议。- Dmitry Soshnikov

课程评论(0条)

课程详情

How 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 they usually are 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 right away deep down to the theoretical aspects of formal grammars. And by the time of implementing a 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 session as pair-programming, and described in a comprehensible way.In the Essentials of Interpretations class we focus specifically on runtime semantics, and build a interpreter for a programming language very similar to JavaScript or Python.Implementing a programing language would also make your practical usage level of other programming languages more professional.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 really a pretty advanced engineering task!), and obtain a transferable knowledge for building such systems.If you are interested specifically in compilers, interpreters, and source code transformation tools, then this class is also for you.The only pre-requisite for this class is basic data structures and algorithms: trees, lists, traversal.What is used for implementation?Since we build a language very similar in semantics to JavaScript or Python (the two most popular programming languages today) we use specifically JavaScript - its elegant multi-paradigm structure which combines functional programming, class-based, and prototype-based OOP fits ideal for that.Many engineers are familiar with JavaScript so it should be easier to start coding right away. However in implementation we don't rely on too specific to JS constructs, and the code from the course is easily portable to TypeScript, Python, Java, C++, Rust, and any other language of your taste.Note: we want our students to actually follow, understand and implement every detail of the interpreter themselves, instead of just copy-pasting from final solution. The full source code for the language is available in video lectures, showing and guiding how to structure specific modules.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 (and when at time) 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 lectures class. In the course we implement a full AST interpreter for our programming language.Reading materialsAs further reading and additional literature for this course the following books are recommended:Structure and Interpretation of Computer Programs (SICP) by Harold Abelson and Gerald Jay SussmanProgramming Languages: Application and Interpretation (PLAI) by Shriram KrishnamurthiWhat is in the course?The course is divided into four parts, in total of 18 lectures, and many sub-topics in each lecture. Please address curriculum for detailed lectures descriptions.PART 1: COMPILERS CRASH COURSEIn this part we describe different compilation and interpretation pipelines, see the difference between JIT-compilers and AOT-compilers, talk about what is a Virtual machine and Bytecode-interpreter, and how it difference from an AST-interpreter, show examples of native code, and LLVM IR, and other topics.PART 2: INTERPRETERS: BASIC EXPRESSIONS AND VARIABLESIn this part we start building our programming language, and consider basic expressions, such as numbers, strings, talk about variables, scopes, and lexical environments, control structures, and touching parser generator.PART 3: FUNCTIONS AND FUNCTIONAL PROGRAMMINGIn this part we start talking and implementing function abstraction, and function calls. We describe concept of closures, lambda function, and IILEs (Immediately-invoked lambda expressions). In addition, we touch topics of Call-stack, recursion, and syntactic sugar.PART 4: OBJECT-ORIENTED PROGRAMMINGThe final part of the course is devoted to the object-oriented support in our language. We describe the class-based, and prototype-based approaches, implement concept of classes, instance and modules.I hope you'll enjoy the class, and will be glad to discuss any questions and suggestion in comments.- Dmitry Soshnikov

课程标签

0人关注该课程

主题相关的课程