├── .gitignore ├── LICENCE.md ├── README.md ├── flake.lock ├── flake.nix ├── ki ├── .gitignore ├── Cargo.lock ├── Cargo.toml ├── build.rs └── src │ ├── grammar.lalrpop │ ├── lib.rs │ ├── main.rs │ └── test.rs ├── koka_bench ├── .gitignore ├── CMakeLists.txt ├── LICENSE ├── README.md ├── copy_wrapper.sh ├── cpp │ ├── CMakeLists.txt │ ├── cfold.cpp │ ├── deriv.cpp │ ├── fib.cpp │ ├── nqueens.cpp │ └── rbtree.cpp ├── haskell │ ├── CMakeLists.txt │ ├── cfold.hs │ ├── deriv.hs │ ├── nqueens.hs │ └── rbtree.hs ├── java │ ├── CMakeLists.txt │ ├── cfold.java │ ├── deriv.java │ ├── nqueens.java │ └── rbtree.java ├── java_wrapper.sh ├── koka │ ├── CMakeLists.txt │ ├── cfold.kk │ ├── deriv.kk │ ├── fib.kk │ ├── nqueens-int.kk │ ├── nqueens.kk │ └── rbtree.kk ├── kraken │ ├── CMakeLists.txt │ ├── cfold.kp │ ├── deriv.kp │ ├── fib-let.kp │ ├── fib.kp │ ├── nqueens.kp │ ├── rbtree-opt.kp │ ├── rbtree.kp │ └── test.sh ├── kraken_wrapper.sh ├── new_test.sh ├── newlisp │ ├── CMakeLists.txt │ ├── newlisp-builtin-rbtree.nl │ ├── newlisp-fib-let.nl │ ├── newlisp-fib.nl │ ├── newlisp-macro-cfold.nl │ ├── newlisp-macro-deriv.nl │ ├── newlisp-macro-fib-let.nl │ ├── newlisp-macro-fib.nl │ ├── newlisp-macro-nqueens.nl │ ├── newlisp-macro-rbtree.nl │ ├── newlisp-slow-fexpr-cfold.nl │ ├── newlisp-slow-fexpr-deriv.nl │ ├── newlisp-slow-fexpr-fib-let.nl │ ├── newlisp-slow-fexpr-fib.nl │ ├── newlisp-slow-fexpr-nqueens.nl │ └── newlisp-slow-fexpr-rbtree.nl ├── ocaml │ ├── CMakeLists.txt │ ├── cfold.ml │ ├── deriv.ml │ ├── nqueens.ml │ └── rbtree.ml ├── picolisp │ ├── CMakeLists.txt │ ├── picolisp-cfold.l │ ├── picolisp-deriv.l │ ├── picolisp-fib-let.l │ ├── picolisp-fib.l │ ├── picolisp-nqueens.l │ └── picolisp-rbtree.l ├── plot_demo.py ├── python │ ├── CMakeLists.txt │ ├── python-fib-let.py │ └── python-fib.py ├── relative.py ├── scheme │ ├── CMakeLists.txt │ ├── scheme-fib-let.scm │ ├── scheme-fib.scm │ └── scheme-nqueens.scm ├── swift │ ├── CMakeLists.txt │ ├── cfold.swift │ ├── deriv.swift │ ├── nqueens.swift │ └── rbtree.swift └── test.sh ├── slj ├── Cargo.lock ├── Cargo.toml ├── build.rs └── src │ ├── grammar.lalrpop │ ├── grammer.lalrpoplib.rs │ ├── lib.rs │ └── main.rs └── website ├── Inter.var.woff2 ├── JetBrainsMono-Regular.woff2 ├── LICENSE ├── Recursive.woff2 ├── codejar.js ├── default.min.css ├── favicon.ico ├── highlight.min.js ├── images ├── Kraken_Call_PE_Semantics.png ├── Kraken_NonCall_PE_Semantics.png ├── Kraken_aux_helpers.png ├── Kraken_aux_helpers2.png ├── Kraken_aux_helpers3.png ├── Kraken_pe_primitives.png ├── cfold_table.csv_.png ├── cfold_table.csv_log.png ├── deriv_table.csv_.png ├── deriv_table.csv_log.png ├── fib_table.csv_.png ├── fib_table.csv_log.png ├── lisp_timeline_screenshot.png ├── lisp_timeline_screenshot_edited.png ├── lisp_timeline_screenshot_edited.xcf ├── nqueens_table.csv_.png ├── nqueens_table.csv_log.png ├── overview.png ├── rbtree_table.csv_.png ├── rbtree_table.csv_log.png ├── slow_cfold_table.csv_.png ├── slow_cfold_table.csv_log.png ├── slow_deriv_table.csv_.png ├── slow_deriv_table.csv_log.png ├── slow_fib_table.csv_.png ├── slow_fib_table.csv_log.png ├── slow_ish_rbtree_table.csv_.png ├── slow_ish_rbtree_table.csv_log.png ├── slow_nqueens_table.csv_.png ├── slow_nqueens_table.csv_log.png ├── slow_rbtree_table.csv_.png └── slow_rbtree_table.csv_log.png ├── index.html ├── index2.html ├── quals_presentation.html ├── recursive.css ├── remark-latest.min.js └── slick.css /.gitignore: -------------------------------------------------------------------------------- 1 | _site 2 | build 3 | build-ninja 4 | *.swp 5 | *.swm 6 | *.swn 7 | *.swo 8 | *.swl 9 | *.swi 10 | *.swj 11 | *.swk 12 | .*.un~ 13 | callgrind* 14 | .stfolder 15 | *.wasm 16 | */target 17 | -------------------------------------------------------------------------------- /LICENCE.md: -------------------------------------------------------------------------------- 1 | Copyright Nathan Braswell 2 | 3 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 4 | 5 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 6 | 7 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 8 | 9 | Subject to the terms and conditions of this license, each copyright holder and contributor hereby grants to those receiving rights under this license a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except for failure to satisfy the conditions of this license) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer this software, where such license applies only to those patent claims, already acquired or hereafter acquired, licensable by such copyright holder or contributor that are necessarily infringed by: 10 | 11 | (a) their Contribution(s) (the licensed copyrights of copyright holders and non-copyrightable additions of contributors, in source or binary form) alone; or 12 | 13 | (b) combination of their Contribution(s) with the work of authorship to which such Contribution(s) was added by such copyright holder or contributor, if, at the time the Contribution is added, such addition causes such combination to be necessarily infringed. The patent license shall not apply to any other combinations which include the Contribution. 14 | 15 | Except as expressly stated above, no rights or licenses from any copyright holder or contributor is granted under this license, whether expressly, by implication, estoppel or otherwise. 16 | 17 | DISCLAIMER 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Kraken 2 | ====== 3 | 4 | The Kraken Programming Language 5 | 6 | (more information online at http://kraken-lang.org/ which is also under construction / needs to be updated / has a try-it-online feature for an older version without partial evaluation) 7 | 8 | *Heavily* inspiried by John Shutt's thesis: https://web.wpi.edu/Pubs/ETD/Available/etd-090110-124904/unrestricted/jshutt.pdf 9 | with partial evaluation during compilation to make it efficient. 10 | 11 | Currently developing the fourth iteration, a Scheme-like based on a functional Vau calculus JIT compiled for speed. 12 | 13 | Working up to a JIT for fexprs by starting with 14 | 15 | - [ ] slj - a Simple Lisp JIT (WIP) 16 | - [ ] clj - a continuation lisp JIT? 17 | - [ ] mlj - a mutation lisp JIT? 18 | - [ ] flj - a fexpr Lisp JIT? 19 | - [x] ki - A fexpr interpeter with mutation and delimited continuations 20 | - [ ] kj - A fexpr+mutation+delimited continuations JIT 21 | 22 | 23 | koka_bench: Licensed under Apache-2.0, as they are derived from the benchmarks of the Koka project, see the readme and license in koka_bench for more, or https://github.com/koka-lang/koka for the source project. 24 | 25 | Kraken (everything else besides the benchmarks in koka_bench, and Recursive/CodeJar/Highlight.js in website/) Licensed under 26 | SPDX-License-Identifier: BSD-2-Clause-Patent 27 | 28 | Note: This license is designed to provide: a) a simple permissive license; b) that is compatible with the GNU General Public License (GPL), version 2; and c) which also has an express patent grant included. 29 | 30 | (Note taken from https://opensource.org/licenses/BSDplusPatent ) 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /flake.lock: -------------------------------------------------------------------------------- 1 | { 2 | "nodes": { 3 | "flake-utils": { 4 | "inputs": { 5 | "systems": "systems" 6 | }, 7 | "locked": { 8 | "lastModified": 1694529238, 9 | "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", 10 | "owner": "numtide", 11 | "repo": "flake-utils", 12 | "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", 13 | "type": "github" 14 | }, 15 | "original": { 16 | "owner": "numtide", 17 | "repo": "flake-utils", 18 | "type": "github" 19 | } 20 | }, 21 | "flake-utils_2": { 22 | "inputs": { 23 | "systems": "systems_2" 24 | }, 25 | "locked": { 26 | "lastModified": 1681202837, 27 | "narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=", 28 | "owner": "numtide", 29 | "repo": "flake-utils", 30 | "rev": "cfacdce06f30d2b68473a46042957675eebb3401", 31 | "type": "github" 32 | }, 33 | "original": { 34 | "owner": "numtide", 35 | "repo": "flake-utils", 36 | "type": "github" 37 | } 38 | }, 39 | "moz_overlay": { 40 | "inputs": { 41 | "flake-utils": "flake-utils_2", 42 | "nixpkgs": "nixpkgs" 43 | }, 44 | "locked": { 45 | "lastModified": 1700360261, 46 | "narHash": "sha256-8fRSHx5osjDELHSL7OHEfj/cOh8q+B7M9EF/yPR3bw8=", 47 | "owner": "oxalica", 48 | "repo": "rust-overlay", 49 | "rev": "45066cb0b2505d8da581be8432a16238c867f199", 50 | "type": "github" 51 | }, 52 | "original": { 53 | "owner": "oxalica", 54 | "repo": "rust-overlay", 55 | "type": "github" 56 | } 57 | }, 58 | "nixpkgs": { 59 | "locked": { 60 | "lastModified": 1681358109, 61 | "narHash": "sha256-eKyxW4OohHQx9Urxi7TQlFBTDWII+F+x2hklDOQPB50=", 62 | "owner": "NixOS", 63 | "repo": "nixpkgs", 64 | "rev": "96ba1c52e54e74c3197f4d43026b3f3d92e83ff9", 65 | "type": "github" 66 | }, 67 | "original": { 68 | "owner": "NixOS", 69 | "ref": "nixpkgs-unstable", 70 | "repo": "nixpkgs", 71 | "type": "github" 72 | } 73 | }, 74 | "nixpkgs_unstable": { 75 | "locked": { 76 | "lastModified": 1700412808, 77 | "narHash": "sha256-1yU5WT0sfRJ2DOVZ+6oDdpUZ6j0hz0JBPpbqj8/VCJQ=", 78 | "owner": "NixOS", 79 | "repo": "nixpkgs", 80 | "rev": "38b1656c2d775b6abc6d08cfc8f38b8847a73ec4", 81 | "type": "github" 82 | }, 83 | "original": { 84 | "owner": "NixOS", 85 | "repo": "nixpkgs", 86 | "type": "github" 87 | } 88 | }, 89 | "root": { 90 | "inputs": { 91 | "flake-utils": "flake-utils", 92 | "moz_overlay": "moz_overlay", 93 | "nixpkgs_unstable": "nixpkgs_unstable" 94 | } 95 | }, 96 | "systems": { 97 | "locked": { 98 | "lastModified": 1681028828, 99 | "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", 100 | "owner": "nix-systems", 101 | "repo": "default", 102 | "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", 103 | "type": "github" 104 | }, 105 | "original": { 106 | "owner": "nix-systems", 107 | "repo": "default", 108 | "type": "github" 109 | } 110 | }, 111 | "systems_2": { 112 | "locked": { 113 | "lastModified": 1681028828, 114 | "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", 115 | "owner": "nix-systems", 116 | "repo": "default", 117 | "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", 118 | "type": "github" 119 | }, 120 | "original": { 121 | "owner": "nix-systems", 122 | "repo": "default", 123 | "type": "github" 124 | } 125 | } 126 | }, 127 | "root": "root", 128 | "version": 7 129 | } 130 | -------------------------------------------------------------------------------- /flake.nix: -------------------------------------------------------------------------------- 1 | { 2 | description = "Env for Kraken and the extacted Koka bencmarks"; 3 | inputs = { 4 | # For some reason the newer one has broken koka/emscripten (probs same change) 5 | #nixpkgs_stable_new.url = "nixpkgs/nixos-22.11"; 6 | #nixpkgs_stable_old.url = "nixpkgs/nixos-21.11"; 7 | nixpkgs_unstable.url = "github:NixOS/nixpkgs"; 8 | moz_overlay.url = "github:oxalica/rust-overlay"; 9 | flake-utils.url = "github:numtide/flake-utils"; 10 | }; 11 | outputs = { self, 12 | #nixpkgs_stable_new, nixpkgs_stable_old, 13 | nixpkgs_unstable, moz_overlay, flake-utils }: 14 | (flake-utils.lib.eachDefaultSystem (system: 15 | let 16 | pkgs_new = import nixpkgs_unstable { 17 | inherit system; 18 | overlays = [ moz_overlay.overlay ]; 19 | }; 20 | #pkgs_old = import nixpkgs_stable_old { 21 | # inherit system; 22 | # overlays = [ moz_overlay.overlay ]; 23 | #}; 24 | #newlisp = pkgs.stdenv.mkDerivation rec { 25 | #pname = "newLisp"; 26 | #version = "10.7.5"; 27 | 28 | #src = pkgs.fetchurl { 29 | #url = "http://www.newlisp.org/downloads/newlisp-10.7.5.tgz"; 30 | #sha256 = "sha256-3C0P9lHCsnW8SvOvi6WYUab7bh6t3CCudftgsekBJuw="; 31 | #}; 32 | 33 | #nativeBuildInputs = [ 34 | #pkgs.autoPatchelfHook 35 | #]; 36 | 37 | #buildInputs = [ 38 | #pkgs.stdenv.cc.cc.lib 39 | #pkgs.libffi 40 | #pkgs.readline 41 | #]; 42 | 43 | #installPhase = '' 44 | #mkdir -p $out/bin 45 | #cp newlisp $out/bin 46 | #''; 47 | 48 | #meta = with pkgs.lib; { 49 | #homepage = "http://www.newlisp.org/index.cgi"; 50 | #description = "A Lisp-like, general-purpose scripting language"; 51 | #platforms = platforms.linux; 52 | #}; 53 | #}; 54 | #wavm = pkgs.stdenv.mkDerivation rec { 55 | #pname = "wavm"; 56 | #version = "0.0.0"; 57 | 58 | #src = pkgs.fetchurl { 59 | #url = "https://github.com/WAVM/WAVM/releases/download/nightly%2F2022-05-14/wavm-0.0.0-prerelease-linux.tar.gz"; 60 | #sha256 = "sha256-+PpnwPJDty6XCjjuHVFwiHc1q+k0zPF11EbRpqSKfyY="; 61 | #}; 62 | 63 | #nativeBuildInputs = [ 64 | #pkgs.autoPatchelfHook 65 | #]; 66 | 67 | #buildInputs = [ 68 | #pkgs.stdenv.cc.cc.lib 69 | #]; 70 | 71 | #sourceRoot = "."; 72 | 73 | #installPhase = '' 74 | #mkdir -p $out/bin 75 | #cp -r bin/wavm $out/bin/ 76 | #cp -r include/ $out 77 | #cp -r lib64/ $out 78 | #cp -r share/ $out 79 | ##install -m755 -D studio-link-standalone-v${version} $out/bin/studio-link 80 | #''; 81 | 82 | #meta = with pkgs.lib; { 83 | #homepage = "https://wavm.github.io/"; 84 | #description = "WAVM WebAssembly Engine"; 85 | #platforms = platforms.linux; 86 | #}; 87 | #}; 88 | in { 89 | devShell = pkgs_new.mkShell { 90 | buildInputs = with pkgs_new; [ 91 | which # used for shell stuff when inside pure env 92 | 93 | hyperfine 94 | graph-cli # is this just for python?! 95 | 96 | chicken gambit-unstable chez 97 | #gambit 98 | 99 | wabt wasmtime #wavm 100 | #wasm3 101 | 102 | clang cmake 103 | cargo cargo-flamegraph 104 | #(rust-bin.stable.latest.default.override { targets = [ "wasm32-wasi" ]; }) 105 | #stack (haskellPackages.ghcWithPackages (p: [p.parallel])) 106 | koka 107 | #pkgs_old.emscripten 108 | 109 | #picolisp 110 | #newlisp 111 | ]; 112 | }; 113 | } 114 | )); 115 | } 116 | -------------------------------------------------------------------------------- /ki/.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | -------------------------------------------------------------------------------- /ki/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ki" 3 | version = "0.1.0" 4 | edition = "2021" 5 | build = "build.rs" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | 10 | [profile.bench] 11 | debug = true 12 | 13 | [dependencies] 14 | lalrpop-util = {version="0.19.7", features=["lexer"]} 15 | regex = "1" 16 | once_cell = "1.17.0" 17 | anyhow = "1" 18 | 19 | [build-dependencies] 20 | lalrpop = "0.19.7" 21 | -------------------------------------------------------------------------------- /ki/build.rs: -------------------------------------------------------------------------------- 1 | extern crate lalrpop; 2 | 3 | fn main() { 4 | lalrpop::process_root().unwrap(); 5 | } 6 | -------------------------------------------------------------------------------- /ki/src/grammar.lalrpop: -------------------------------------------------------------------------------- 1 | use std::str::FromStr; 2 | use std::rc::Rc; 3 | use ki::Form; 4 | 5 | grammar; 6 | 7 | pub Term: Rc