编程语言动物园
The Programming Languages Zoo

原始链接: https://plzoo.andrej.com/

## 编程语言动物园:概要 编程语言动物园是一个教育性的编程语言集合,包含许多小型但完整的编程语言,旨在说明语言设计和实现的核心概念。对于希望学习编程语言的工作原理或构建自己语言的人来说,这是一个宝贵的资源。 该动物园展示了多种范式——函数式、声明式、面向对象和过程式——并演示了解析、类型检查(静态和动态)、求值策略(急切和惰性)以及异常处理等技术。包含的语言范围从简单的λ演算到Haskell、Prolog和面向对象系统的迷你版本。 该项目强调研究注释良好的源代码。每种语言都有一个README和示例,可以通过命令行运行,交互式(REPL)或使用文件。 该项目采用MIT许可开源,欢迎贡献——错误修复、新语言(遵循简洁性指南)或帮助解决现有问题——通过GitHub。

## 编程语言动物园:摘要 一篇最近的Hacker News帖子强调了[编程语言动物园](https://andrej.com/),这是一个简洁的编程语言实现集合,可能使用OCaml和词法/解析器生成器构建。 这次讨论引发了关于编程语言本质的争论——它们本质上是数学问题,还是用户界面(UI)挑战? 一些人认为语言不仅仅是语法,并引用了Rust的借用检查器等特性,它提供了LLM生成的代码中没有的宝贵保证。 另一些人则强调UI方面,特别是随着编码代理变得越来越普遍,认为语言越来越是问题解决和解决方案实现之间的桥梁。 这场对话涉及语言设计中固有的权衡,质疑单一语言是否可以包含*所有*可能的功能。 想法包括具有可配置功能的语言,以及人工智能驱动的代码直接生成到优化可执行文件的可能性。 最终,这场讨论凸显了语言语义、工具以及程序员在日益受人工智能影响的世界中的作用之间的复杂相互作用。
相关文章

原文

About the zoo

The Programming Languages Zoo is a collection of miniature programming languages which demonstrates various concepts and techniques used in programming language design and implementation. It is a good starting point for those who would like to implement their own programming language, or just learn how it is done.

The following features are demonstrated:

  • functional, declarative, object-oriented, and procedural languages
  • source code parsing with a parser generator
  • keep track of source code positions
  • pretty-printing of values
  • interactive shell (REPL) and non-interactive file processing
  • untyped, statically and dynamically typed languages
  • type checking and type inference
  • subtyping, parametric polymorphism, and other kinds of type systems
  • eager and lazy evaluation strategies
  • recursive definitions
  • exceptions
  • interpreters and compilers
  • abstract machine

Installation

See the installation & compilation instructions.

The languages

The following languages are on display:

miniml_error
like miniml that can also abort execution
minihaskell
lazy, functional, integers, booleans, lists, recursion, statically typed
miniprolog
logic programming, Horn clauses, unification
levy
call-by-push value, statically typed
comm
A procedural language with integer arithmetic, local variables, conditional statements, while loops and print, compiled to simple machine code.
calc
integer arithmetic +, -, *, /
sub
eager, mutable records, statically typed, subtyping
boa
object-oriented, eager, first-class functions, dynamic types, extensible objects
lambda
untyped λ-calculus, several evaluation strategies
calc_var
integer arithmetic +, -, *, /, variables
miniml
eager, functional, recursive functions, statically typed, compiler, abstract machine
poly
lazy, functional, statically typed, parametric polymorphism, type inference

Usage

The languages are not really meant to be used. Rather, you should read and study the source code, which is decorated with ample comments. Also, each language lang has its own README.md and example.lang in the subdirectory src/lang.

Nevertheless, all the language are fully functioning miniature versions of real languages and can be executed. For each language lang you can:

  1. see what command-line options are available with

  2. run the toplevel with

  3. run files non-interactively with

     ./lang.native <file> <file> ...`
    
  4. load files and enter the toplevel

     ./lang.native -l <file> -l <file> ...`
    

Authors

License

The project is open source and released under the permissive MIT license.

Contributing

New contributions are welcome. If you would like to contribute to the project, please contact us through the GitHub project page:

  • If you discover a problem, open an issue.
  • Even better, fix the problem and submit a pull request!
  • If you would like to help but do not know how, have a look at open issues and volunteer to resolve one.
  • If you have an idea for a new language, we will be happy to take it in. Please note that all the languages are purposely kept simple for educational purposes.

Before you contibute a new langauge, please read these guidelines for contributing.

联系我们 contact @ memedata.com