• Stars
    star
    458
  • Rank 92,376 (Top 2 %)
  • Language
    TeX
  • License
    Creative Commons ...
  • Created almost 4 years ago
  • Updated 12 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A lightweight (350MB) Lisp interpreter in Malbolge Unshackled, often dubbed the hardest turing complete programming language.

MalbolgeLISP v1.2

Made by Palaiologos, 2020 - 2021. Core (core.mb) to the public domain, the entire program is governed by the GNU GPLv3 license.

Session gif

During summer and fall of 2021, I wrote a book about MalbolgeLISP's design and implementation

What is MalbolgeLisp?

MalbolgeLisp is a LISP interpreter written in Malbolge. It's as of 2020 and 2021, the most advanced, usable Malbolge program ever created. It supports everything LISPs generally tend to support (like cond, let, lambda, etc...). The v1.2 release greatly improved the performance and reduced the code size, while adding a few features.

MalbolgeLISP supports tacit programming, partial application, de Bruijn indices, monad lifting, and more.

A few fibonacci functions programmed in MalbolgeLISP (and tested on (fibN 6)):

; Naive attempt at 1m 19s
(defun fib1 (n) (
    if [n < 2]
        n
        [(fib1 [n - 1]) + (fib1 [n - 2])]))

; Direct port of accumulator-keeping solution at 1m 6s:
(defun fib2 (n) ((lambda (a w) (
    if [w = 0]
        (#0 a)
        ((bruijn 0) (tie (#1 a) (lift + a)) [w - 1]))) '(0 1) n))

; A more idiomatic solution than the above at 54s:
(defun fib3 (n) ((lambda (x y w) (
    if [w = 0]
        x
        ((bruijn 0) y [x + y] [w - 1]))) 0 1 n))

; Iterative attempt at 43s
(defun fib4 (n) (#0 (
    iterateN n (lambda (x) (
        tie (#1 x) [(#0 x) + (#1 x)])) '(0 1))))

What is Malbolge? Why is it difficult?

Malbolge is a public domain esoteric programming language. It was specifically designed to be almost impossible to use, via a counter-intuitive 'crazy operation', trinary arithmetic, and self-modifying code. It builds on the difficulty of earlier, challenging esoteric languages like Brainfuck, but takes this aspect to the extreme. Despite this design, it is possible to write useful Malbolge programs (as this project proves).

What Malbolge instructions do depends on their position in the source code. After being ran, they are encrypted (so to make a loop, one has to decrypt it after each iteration - sounds hard already?). This is how so-called instruction cycles have been discovered - it has been observed that some instructions on certain locations form looping cycles, which is the basis of Malbolge programming.

The most complex programs made in Malbolge, to date, include an adder, a "99 bottles of beer" program, and a "Hello, world!" program (originally generated by a Lisp program utilizing a genetic algorithm).

MalbolgeLisp uses a special variant of Malbolge called Malbolge Unshackled. It's considerably harder to program for multiple reasons:

  1. The rotation width is chosen randomly by the interpreter
  2. Malbolge Unshackled lets the width of rotation be variable, which grows with the values in the D register, and since the initial rotation width is unknown, you have to probe it (because otherwise * returns unpredictable results)
  3. Malbolge Unshackled's print instruction requires unicode codepoints
  4. if the rotation width is unknown then you can't load values larger than 3^4-1, except values starting with a 1 trit
  5. to overcome this you need a loop that probes the rotation width which is probably beyond most people's comprehension
  6. the specification says that the value 0t21 should be used to print a newline, but this value is theoretically impossible to obtain without having read an end of line or end of file from I/O before.
  7. Malbolge Unshackled is actually usable because it's (as this project proves) Turing complete. The default Malbolge rotation width (10) constraints the addressable memory enough to make something cool with it.

A few example Malbolge programs:

A "Hello World" program:

(=<`#9]~6ZY327Uv4-QsqpMn&+Ij"'E%e{Ab~w=_:]Kw%o44Uqp0/Q?xNvL:`H%c#DD2^WV>gY;dts76qKJImZkj

A cat program that doesn't terminate on EOF:

(=BA#9"=<;:3y7x54-21q/p-,+*)"!h%B0/.~P<<:(8&66#"!~}|{zyxwvugJk

How to use

$ git clone https://github.com/kspalaiologos/malbolge-lisp
$ cd malbolge-lisp
$ unzip lisp.mb
$ clang -O3 -march=native fast20.c -o fast20
$ cat init_module.mb core.mb > lisp.mb
$ ./fast20 lisp.mb

More Repositories

1

bzip3

A better and stronger spiritual successor to BZip2.
C
629
star
2

kamilalisp

A functional, flexible and concise Lisp.
Java
254
star
3

asmbf

The only true brainfuck-targetting assembler.
C
101
star
4

C-Learning-Resources

Resources for learning C that are the best in my opinion.
93
star
5

qbdiff

building and applying patches to binary files
C
62
star
6

tinyz80

A minimal Z80 implementation.
C
20
star
7

sdlgames

A collection of small games made using SDL and C/++.
C++
19
star
8

blc-mb

Binary Lambda Calculus evaluation engine written in Malbolge.
C
17
star
9

A-Programming-Language

An effort to transcribe Ken Iverson's "A Programming Language" book to LaTeX.
TeX
17
star
10

tiny6502

a small (~140 line) and portable 6502 emulator demo.
Assembly
16
star
11

typeracer

A ncurses-powered typing game
C
16
star
12

lc-apl

Journey to the Center of the Lambda Calculus
APL
13
star
13

tau

a reasonably fast syntax highlighter
C
13
star
14

writings

a single place to collectively store every bit of my writings i deem at least remotely valuable.
TeX
13
star
15

modern-rzip

A backup suite. Supports FLZMA2, bzip3, LZ4, Zstandard, LSH i-node ordering deduplicating archiver, long range deduplication, encryption and recovery records
C
13
star
16

Maja

A slick numerics-oriented Mathematical library for Java
Java
13
star
17

asm2ws

alpha-grade whitespace toolchain
C
11
star
18

lz4huf

An attempt to marry a fast Lempel-Ziv codec (LZ4) with a fast entropy coder (Huff0).
C
10
star
19

ski

a 666-byte, public domain SKI combinator calculus evaluator in C, minsky machines and other stuff
Perl
9
star
20

mri

minecraft region interchange - compressing minecraft savefiles with bzip3.
C
9
star
21

compression

playing with small decompressors and good ratios :)
9
star
22

adler32-sse2

Adler32 implementation used in Alpha64 at ~13GiB/s in a 1 kilobyte binary.
Assembly
8
star
23

ski-windows

a 976-byte, GUI SKI calculus evaluator written in x86 assembly for windows
Assembly
8
star
24

nonalphanumeric-c

A compiler targetting a subset of C which doesn't use letters nor numbers.
C
8
star
25

mblzp

A lightweight (8MB) implementation of the McIlroy-Tamayo Lempel-Ziv variation in Malbolge Unshackled.
C
7
star
26

JSONFormatter

JSON formatting service in... Brainfuck?
Brainfuck
7
star
27

cosmopolitan-sk

SK calculus reducer in as many programming languages as possible.
TSQL
7
star
28

rezip

Turn any archive format supported by libarchive into an uncompressed zip file for better archiving purposes.
C
6
star
29

cursed-asm

Use AT&T syntax on even lines and Intel syntax on odd lines
Assembly
6
star
30

LambdaCalculus

Dead simple implementation of Lambda Calculus.
C
6
star
31

dirac

Delightfully Intricate Reasonably Amazing Calculator
C
6
star
32

aoc2023

Advent Of Code 2023 in APL, Haskell and C.
Haskell
6
star
33

b2all

Collection of brainfuck-to-anything compilers in brainfuck.
Brainfuck
6
star
34

esofun

esofun is an array, imperative, procedural and functional language mix.
C++
5
star
35

euler-apl

project euler solved in APL
APL
5
star
36

recreational

My submissions for Code guessing, Code golf and other recreational programming things.
C
5
star
37

apl-misc-math

Miscellaneous mathematical and numerical utilities in APL.
APL
5
star
38

MacroLogger

Simple C logging library utilizing only C89 preprocessor and standard library. It's possible to turn on ANSI colors and GNU preprocessor extensions (and they are by default)).
C
5
star
39

x86lisp

2158 byte Lisp interpreter for Windows.
5
star
40

cask

An alternative way to package Java applications.
Java
4
star
41

e8e9

A command-line wrapper for Shelwien's e8e9 algorithm.
C
4
star
42

apl-logic

Logic gate system emulation in APL.
APL
3
star
43

dx

Domain eXtensions for Dyalog APL
APL
3
star
44

esologs

Logs of the #esoteric channel on freenode.net
3
star
45

dyalog-hs

Dyalog APL Competition solved with Haskell.
Haskell
3
star
46

snakes

A KoTH programming game host for the Esolangs Discord server.
C
3
star
47

apio

a very good and not bad c++ utility library.
C++
3
star
48

YouAreAnIdiot

Classic You Are An Idiot virus that was very popular ca. 2004
HTML
2
star
49

elf-infection

Source code for https://palaiologos.rocks/essays/posts/elf-infection/
Assembly
2
star
50

Gisa

Gisa is unique programming language with pipeline compiling to Brainfuck
C
2
star
51

codegolf-submissions

My submissions on https://codegolf.stackexchange.com
mupad
2
star
52

Proton

Proton is toolkit for desktop app creation in ActionScript3
AutoIt
2
star
53

sublime-v2

sublime: an asm2bf execution bot written in typescript
Perl
2
star
54

euler

Project Euler solved in Brainfuck.
Brainfuck
2
star
55

kspalaiologos

Github description, I guess.
2
star
56

malware

Malware created for DOS/Win9x/WinNT/Office solely for educational purposes :)
Assembly
2
star
57

minits

a crude testing platform used by malbolgelisp ca. August of 2021, preserved for historical reasons.
TypeScript
1
star
58

Chess.fl

Chess.fl is simple Flash library for managing chessboards.
ActionScript
1
star
59

TinyURL-Shortener

TinyURL frontend script written in Bash. Requires cURL to be installed on target machine.
Shell
1
star
60

terranuke

Simple Terraria server exploit targeting servers that don't close connection after receiving garbage data and process it afterwards.
AutoIt
1
star
61

ILoCore-Release

Binaries of ILoCore Minecraft 1.14 plugin.
1
star
62

dotfiles

A stripped down version of my dotfiles hopefully suitable for use by others.
Shell
1
star
63

uAnnouncer

uAnnouncer is tiny AutoMessage inspired plugin supporting all stable minecraft releases
1
star
64

namechanger

simple bash script to replace one pattern with another for each of your github repositories
Shell
1
star
65

Chemal

The chemical balancer
ActionScript
1
star
66

code-guessing-backend

a (yet incomplete), fully automated code guessing automation platform.
Shell
1
star
67

sdlreversi

A reversi/othello game under 500 lines of C++ code.
C++
1
star
68

sdlmine

A SDL2 minesweeper in 1000 lines of code.
C
1
star
69

MANIAC-2

Replica of the first computer to beat human in a chess-like game.
C
1
star
70

ctlsh

A C port of the Trend Micro Locality Sensitive Hashing library.
C
1
star
71

rust-jni-template

A template for developing JNI libraries using the Rust programming language
Java
1
star
72

ppmdj1

A Github mirror of Dymitry Shkarin's PPMd var. J
C++
1
star