{"id":13792667,"url":"https://github.com/samrushing/irken-compiler","last_synced_at":"2025-05-12T14:32:03.643Z","repository":{"id":1511704,"uuid":"1768985","full_name":"samrushing/irken-compiler","owner":"samrushing","description":"Irken is a statically typed variant of Scheme.  Or a lisp-like variant of ML.","archived":false,"fork":false,"pushed_at":"2023-01-19T21:53:28.000Z","size":17115,"stargazers_count":210,"open_issues_count":37,"forks_count":17,"subscribers_count":13,"default_branch":"master","last_synced_at":"2024-11-18T06:49:36.968Z","etag":null,"topics":["continuations","functional","ml","scheme"],"latest_commit_sha":null,"homepage":"http://nightmare.com/rushing/irken.html","language":"Scheme","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/samrushing.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-05-19T00:13:41.000Z","updated_at":"2024-09-25T08:35:20.000Z","dependencies_parsed_at":"2023-02-11T21:45:56.335Z","dependency_job_id":null,"html_url":"https://github.com/samrushing/irken-compiler","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samrushing%2Firken-compiler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samrushing%2Firken-compiler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samrushing%2Firken-compiler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samrushing%2Firken-compiler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/samrushing","download_url":"https://codeload.github.com/samrushing/irken-compiler/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253754968,"owners_count":21958934,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["continuations","functional","ml","scheme"],"created_at":"2024-08-03T22:01:14.881Z","updated_at":"2025-05-12T14:32:02.921Z","avatar_url":"https://github.com/samrushing.png","language":"Scheme","funding_links":[],"categories":["Scheme"],"sub_categories":["course"],"readme":"The Irken Compiler\n------------------\n\n![irken logo](http://dark.nightmare.com/rushing/irken/irken/irken.svg \"logo\")\n\n[![Build Status](https://travis-ci.com/samrushing/irken-compiler.svg?branch=master)](https://travis-ci.com/samrushing/irken-compiler)\n\nIrken is a statically-typed, simplified variant of Scheme.  Or... a\nlisp-like variant of ML, depending on your point of view.  If you're\nnot familiar with either family of languages, Irken is a strongly\ntyped, compiled language with a lisp-like syntax extensible with\nmacros.  It uses type inference along with a powerful type system to\ngive you the speed of a compiled language with high-level data types\nand a higher degree of safety than languages like C/C++.\n\n* Why: to host massively scalable systems without using threads.\n* How: compile using continuation-passing style to avoid using the C stack.\n* Blog: [http://alien.nightmare.com/](http://alien.nightmare.com/)\n* GitHub: [https://github.com/samrushing/irken-compiler/](https://github.com/samrushing/irken-compiler/)\n\nNews:\n-----\n\n20180829: Merged the FFI branch in.\n\n  This includes a *lot* of work:\n\n  * new FFI system that supports all three backends.\n  * `genffi` uses a full C parser to generate an interface file.\n  * ASN.1 codec\n  * Lots of crypto support code (x509, hmac, hkdf, rsa-pss, libsodium, libdecaf, ...).\n  * constant-time modular bignum arithmetic for crypto, based on Thomas Pornin's i31 code.\n  * DFA lexer and regex library based on derivatives.\n  * Earley parser.\n  * TLS 1.3 implementation.\n  * websockets/rfc6455.\n  * HTTP/2 server.\n\n20170329: Merged the bytecode backend and VM.\n\n  This has been tested on four platforms:\n\n  * amd64 osx-10\n  * amd64 freebsd-11\n  * amd64 linux-ubuntu-xenial\n  * aarch64 linux-debian rpi-3\n\nIntroduction/Tutorial:\n----------------------\n\n  [http://dark.nightmare.com/rushing/irken/irken/lang.html](http://dark.nightmare.com/rushing/irken/irken/lang.html)\n\nThe best way to get familiar with the language is to read the source code in\nthe 'self' directory, and browse over the files in \"tests\".\n\nBootstrap:\n----------\n\nIrken is written in itself, so you need to bootstrap it using a pre-compiled bytecode image.\n\nJust run ``make bootstrap``:\n\n    $ make bootstrap\n\nThe default compiler is 'clang', to use gcc:\n\n    $ CC=gcc make bootstrap\n\nWhich does the following:\n\n1. use self/bootstrap.byc to generate and compile self/compile.c.\n2. this binary will be used to recompile the compiler.\n3. that binary will recompile the compiler again.\n4. the output from steps 2 and 3 are compared, they should be identical.\n\nNote: It is not possible to compile with optimization off, because\nthis disables the tail call optimization that Irken relies on -\notherwise the stack will overflow instantly.\n\nInstallation:\n-------------\n\n    $ python util/install.py\n\nThis will install support files into `/usr/local/lib/irken` and the binary as `/usr/local/bin/irken`.\nIf you want to use a different prefix (like `/usr`), edit `util/install.py` and `self/context.scm`, and\nrebuild self/compile before installing:\n\n    $ self/compile self/compile.scm\n\nUsage:\n------\n\nHere's a sample - create a random ASCII maze:\n\n    $ irken demo/maze/maze.scm\n    $ demo/maze/maze 20 10 -ascii\n    \n     +--------+--------+-----+-----------+-----------------+-----+\n     |        |        |     |           |                 |     |\n     |  +---  |  ---+  +--+  |  +--------+  |  +-----+---  |  |  |\n     |  |     |     |     |  |  |           |  |     |     |  |  |\n     |  |  ---+---  +---  |  |  +--+  +---  +--+  |  +--+  |  +--+\n     |  |           |     |  |     |  |     |     |     |  |     |\n     |  +-----+--+--+  +--+  +---  |  |  ---+  ---+---  |  +---  |\n     |  |     |  |     |  |  |        |     |     |     |  |     |\n     |  |  |  |  |  +--+  |  +-----+--+-----+---  |  +--+  |  ---+\n     |     |  |  |  |  |  |        |        |     |  |     |     |\n     +--+--+  |  |  |  |  +------  |  ---+  |  +--+  |  ---+  |  |\n     |  |     |  |        |        |     |     |     |        |  |\n     |  |  |  |  +--+---  |  +---  +-----+-----+  ---+---  ---+  |\n     |     |  |     |        |     |           |              |  |\n     +-----+  +---  |  +-----+  +--+  ------+  +------  |     |  |\n     |        |        |     |  |           |           |     |  |\n     |  ---+--+--+-----+  |  |  |  +-----+  +-----------+  +--+  |\n     |     |     |        |  |  |  |     |              |  |     |\n     |  |  +---  |  |  ---+  |  +--+  |  +------------  |  |  ---+\n     |  |        |  |     |           |                 |  |     |\n     +--+--------+--+-----+-----------+-----------------+--+-----+\n\n\nYou might want to try looking at and understanding the 'verbose' output from the compiler,\nusing a relatively small example:\n\n    $ irken -v tests/t_while.scm\n\nIrken will use the CC and CFLAGS environment variables when compiling the C output.  You may\ntry out another compiler like this:\n\n    $ CC=\"gcc\" CFLAGS=\"-std=c99 -O2 -I.\" irken ...\n\nLLVM Backend:\n-------------\n\nTo use the LLVM backend, add the `-llvm` arg:\n\n    $ self/compile demo/parse/synlight.scm -llvm\n    $ demo/parse/synlight demo/parse/irken-lex.sg tests/tak20.scm\n\n\nBytecode Backend:\n-----------------\n\nIrken now comes with a VM and bytecode backend.  The VM runs about\n3-4X slower than compiled code, but can speed up development because\nthe edit-compile-run loop skips calling the C compiler.  Turnaround\nwhile working on the compiler (on my machine) is ~5s.\n\nTo use the bytecode/VM:\n\n    $ irken myfile.scm -b\n    $ irkvm myfile.byc\n\nYou can also run the compiler in the VM:\n\n    $ irkvm self/compile.byc myfile.scm -b\n    $ irkvm myfile.byc\n\nARMv8\n-----\n\nI was able to get Irken running on a Raspberry Pi 3, using\nthe [pi64](https://github.com/bamarni/pi64) distribution.  Good news:\nthe llvm `readcyclecounter` intrinsic seems to work just fine on ARM.\nBad news: user mode doesn't have permission to read it.  I was able to\nget everything working by commenting all rdtsc-related code in\ninclude/{header1.c,gc1.c}.  My understanding is that reading this\nregister is a Bad Idea on the ARM, so I may conditionalize it in the\nsource.\n\n\n32-bit platforms\n----------------\n\nOnce upon a time Irken compiled and ran on 32-bit x86.  With the\nSSA-style rewrite that relies on tail call elimination, this appears\nto no longer be possible.  Neither gcc or llvm seem to support full\ntail call elimination on this platform.  Even manually tagging all\nfunctions with 'fastcc' (by compiling to llvm asm and editing the\nresult) does not fix the problem.  If you really need to run Irken on\na 32-bit platform, know that the VM seems to work just fine.\n[that said, many of the library facilities assume 64-bit integers are\n available]\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamrushing%2Firken-compiler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsamrushing%2Firken-compiler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamrushing%2Firken-compiler/lists"}