Giter Club home page Giter Club logo

b1fipl's Introduction

A Bestiary of Single-File Implementations of Programming Languages

From a French Prayer-book of the Thirteenth Century, in the British Museum.

Programming languages are amazing

Programming languages are amazing pieces of work. They turn our words, numbers, and symbols into the bits that make a machine do things.

It's easy to get overwhelmed when implementing a programming language. The GNU Compiler Collection is millions of lines long.

That's too complicated to learn how to implement a programming language. Luckily, some smart people have distilled the most interesting parts of programming languages into an approachable essence. I'm referring to implementations of programming languages that fit in a single source code file.

These single-file implementations are rarely complete, hardly sophisticated or efficient. But they are self-contained, concise, and clear. They make it fun to discover why programming languages are amazing.

Concatenative

bbf, v3 implemented by Mark Carter. A Forth in C.

dc implemented by Lorinda Cherry.

Forth1 implemented by Tycho Luyben.

jonesForth implemented by Richard W.M. Jones.

Mouse implemented by Peter Grogono.

Functional

7 lines of code, 3 minutes implemented by Matt Might.

arpilisp implemented by Marc Paquette.

How to implement a programming language in JavaScript implemented by Mihai Bazon.

(How to Write a (Lisp) Interpreter (in Python)) implemented by Peter Norvig.

komplott implemented by Kristoffer Grönlund.

Lisp500 implemented by Teemu Kalvas.

Lisp9 implemented by Nils M. Holm. A byte-compiling Lisp interpreter.

Lisp90 implemented by Anthony C. Hay.

Lisp In Less Than 200 Lines Of C implemented by Carl Douglas.

MiniLisp implemented by Rui Ueyama.

Mini-Scheme updated by Chris Pressey, originally implemented by Atsushi Moriwaki.

mLite implemented by Nils M. Holm. A lightweight variant of ML.

Most functional implemented by John Tromp. An implementation of binary lambda calculus in 25 lines of obfuscated C.

sectorlisp implemented by Justine Alexandra Roberts Tunney et al. An x86 Lisp interpreter that fits in a boot sector.

sedlisp implemented by Shinichiro Hamaji.

single_cream, scheme interpreter implemented by Raymond Nicholson.

ulc implemented by Asad Saeeduddin. A minimalistic implementation of the untyped lambda calculus in JS

Imperative

asm6502.py implemented by David Beazley.

wak is the single-file version of a "fairly compact implementation of the AWK programming language", implemented by Ray Gardner.

bc implemented by depsterr. Compiles brainfuck into an x86_64 linux binary.

Brainfuck implemented by Brian Raiter.

c4 C in 4 functions, implemented by Robert Swierczek.

Jasic implemented by Robert Nystrom. Old-school BASIC in Java.

mescc-tools-seed, implemented by Jeremiah Orians. A complete chain of one-file languages, from compiler to assemblers and even a shell, for Intel x86: C compiler in assembly, macro assembler to build the C compiler, hex2 assembler to build the macro assembler, hex1 assembler to build the hex2 assembler, hex0 assembler to bootstrap the whole thing, and finally, a shell to script the previous stages.

Mini-C implemented by Sam Nipps. A small subset of C, of course. But not as small as you would guess.

Pascal-S implemented by Niklaus Wirth & Scott A. Moore.

picol is a Tcl interpreter implemented in C. Implemented by Salvatore Sanfilippo, aka antirez.

Selfie includes a 1-file C compiler in C. Implemented by the Computational Systems Group at the Department of Computer Sciences of the University of Salzburg.

swizzle implemented by Robert Swierczek.

The Super Tiny Compiler! implemented by James Kyle.

Tiny Basic implemented by Tom Pittman.

Trac implemented by Jack Trainor.

Tutorial - Write a Shell in C implemented by Stephen Brennan.

VTL02 for 6502 ported and improved by Mike Barry. VTL-02 was originally designed and implemented by Gary Shannon & Frank McCoy.

Logical

microKanren is a Kanren interpreter, implemented by Jason Hemann.

prolog.c is a simple Prolog interpreter written in C++, implemented by Alan Mycroft.

Prolog originally implemented by Ken Kahn, adapted by Nils M. Holm.

Tiny Prolog in OCaml is an interpreter for a subset of Prolog, in OCaml, implemented by Lilian Besson (@Naereen)

Honourable Mentions

256LOL implemented by Jeff Overbey. An x86 assembler in 256 lines or less. Technically not a single file but Jeff gives good descriptions of the problems with elegant, simple solutions.

An Implementation of J implemented by Arthur Whitney. See the appendix "Incunabulum". It's only a fragment of the J interpreter, but its conciseness is impressive.

A Regular Expression Matcher implemented by Rob Pike, exegesis by Brian Kernighan.

JS-Interpreter implemented by Neil Fraser. A JavaScript interpreter in JavaScript. This file is part of a larger project for running JavaScript in a sandbox.

Microlisp, a Scheme-like lisp in less than 1000 loc of C, implemented by Michael Lazear. A single-implementation with extra files for examples and building.

Tiny Compiler implemented by Minko Gechev. It translates only arithmetic expressions, but it's well written.

Epilogue

Have you implemented a programming language in a single file? Let me know with a pull request.

Or fork your own b1fipl. If you do, please give me credit.

Image credit

Parton, James. Caricature and Other Comic Art in all Times and many Lands. Project Gutenberg. Retrieved 2021-02-04. http://gutenberg.org/ebooks/39347

b1fipl's People

Contributors

abarhub avatar felixp7 avatar marcpaq avatar masaeedu avatar naereen avatar rachelambda avatar rain-1 avatar tluyben avatar tromp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

b1fipl's Issues

How to group languages

This is one of my favorite new repos ATM, thanks for curating the collection!

The following headings would probably be more obvious at a glance:

  • Expression-based (lambda calculus: Lisp, ML, ...)
  • Statement-based (C, Pascal, Assembler, ...)
  • Stack-based (Forth, dc, ...)
  • Esoteric (Brainfuck, Unlambda, ...)

Addition to Bestiary

In your Bestiary of programming languages, could you please add in the "Logical" section:

A Prolog interpreter coded in Java, closely based on the interpreter written in C++ by Alan Mycroft, but made a little bit simpler.

Missing a whole family

For example a C compiler written in a single assembly file:
https://github.com/oriansj/mescc-tools-seed/blob/master/x86/cc_x86.M1

The Macro assembler needed to build that C compiler also written in a single file:
https://github.com/oriansj/mescc-tools-seed/blob/master/x86/M0_x86.hex2

The hex2 assembler needed to build that file, also in a single file:
https://github.com/oriansj/mescc-tools-seed/blob/master/x86/hex2_x86.hex1

The hex1 assembler needed to build that file, also in a single file:
https://github.com/oriansj/mescc-tools-seed/blob/master/x86/hex1_x86.hex0

The hex0 assembler needed to bootstrap the whole thing, in a single file:
https://github.com/oriansj/mescc-tools-seed/blob/master/x86/hex0_x86.hex0

Oh and the shell capable of doing all of those steps, in a single file:
https://github.com/oriansj/bootstrap-seeds/blob/master/kaem-optional-seed.hex0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.