{"id":20264392,"url":"https://github.com/thi-ng/charlie","last_synced_at":"2025-04-11T02:11:21.862Z","repository":{"id":47869358,"uuid":"254910577","full_name":"thi-ng/charlie","owner":"thi-ng","description":"TypeScript based Forth-like VM w/ online REPL and extensive kernel (incl. WebGL/WebAudio support)","archived":false,"fork":false,"pushed_at":"2025-03-02T01:32:37.000Z","size":382,"stargazers_count":48,"open_issues_count":1,"forks_count":2,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-03-24T23:35:31.107Z","etag":null,"topics":["canvas","cross-compiler","forth","glsl","javascript","repl","shader","typescript","vm","webaudio","webgl"],"latest_commit_sha":null,"homepage":"http://forth.thi.ng","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thi-ng.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-11T16:38:36.000Z","updated_at":"2025-03-02T01:32:41.000Z","dependencies_parsed_at":"2024-11-14T11:40:20.949Z","dependency_job_id":"f663f1cc-462f-42f0-9c25-46069b374241","html_url":"https://github.com/thi-ng/charlie","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thi-ng%2Fcharlie","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thi-ng%2Fcharlie/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thi-ng%2Fcharlie/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thi-ng%2Fcharlie/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thi-ng","download_url":"https://codeload.github.com/thi-ng/charlie/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248328160,"owners_count":21085261,"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":["canvas","cross-compiler","forth","glsl","javascript","repl","shader","typescript","vm","webaudio","webgl"],"created_at":"2024-11-14T11:40:15.172Z","updated_at":"2025-04-11T02:11:21.843Z","avatar_url":"https://github.com/thi-ng.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @thi.ng/charlie\n\n## About\n\nThis is a slightly updated version of my first\n[Forth](http://thinking-forth.sourceforge.net/) VM implementation from\n2015, originally written in JavaScript, now updated to TypeScript. Charlie is named in honour of Charles Moore, inventor of Forth.\n\nSeveral parts of the VM and core vocabulary are based on @phaendal's\n[mkforth4-js](https://github.com/phaendal/mkforth4-js), which evolved in\nparallel at roughly the same time span and was highly educational. Other\nparts are inspired by [Factor](http://factorcode.org),\n[Popr](https://github.com/HackerFoo/poprc) and other [concatenative\nlanguages](http://concatenative.org/).\n\nThe VM \u0026 REPL (10KB total) are available online via\n[forth.thi.ng](http://forth.thi.ng). The project has been online since\n2015, but was semi-broken due to CSS layout issues (now fixed).\n\nRelated projects resulting from this experiment:\n\n-   [@thi.ng/pointfree-lang](https://github.com/thi-ng/umbrella/tree/develop/packages/pointfree-lang)\n-   [thi.ng/synstack](https://github.com/thi-ng/synstack/)\n\n## Videos / screencasts\n\n-   [WebAudio multi-track synth \u0026 fx livecoding (from scratch)](https://youtu.be/NU4PSkA3pAE?t=130)\n-   [Forth-to-GLSL shader transpiler](https://youtu.be/30s3mgrkzQ0?t=123)\n-   [Mini text adventure (directed graph)](https://twitter.com/forthcharlie/status/618463324473303040)\n-   [Closures \u0026 destructuring](https://twitter.com/forthcharlie/status/618090661137522688)\n-   [Vector algebra](https://twitter.com/forthcharlie/status/616465114871504896)\n-   [Lisp style cons](https://twitter.com/forthcharlie/status/616429574331744256)\n-   [Prime numbers](https://twitter.com/forthcharlie/status/616296680225435649)\n-   [Unit conversion](https://twitter.com/forthcharlie/status/616292997261598720)\n-   [ASCII art](https://twitter.com/forthcharlie/status/616290572706430977)\n-   [FizzBuzz](https://twitter.com/forthcharlie/status/616281804866211840)\n\n## Libraries \u0026 demos\n\nThe following libraries and demos are included (also available in the\nonline REPL):\n\n-   [lib/audio.fs](https://github.com/thi-ng/charlie/tree/master/lib/audio.fs)\n-   [lib/bench.fs](https://github.com/thi-ng/charlie/tree/master/lib/bench.fs)\n-   [lib/canvas.fs](https://github.com/thi-ng/charlie/tree/master/lib/canvas.fs)\n-   [lib/glsl.fs](https://github.com/thi-ng/charlie/tree/master/lib/glsl.fs)\n-   [lib/list.fs](https://github.com/thi-ng/charlie/tree/master/lib/list.fs)\n-   [lib/math.fs](https://github.com/thi-ng/charlie/tree/master/lib/math.fs)\n-   [lib/swizzle.fs](https://github.com/thi-ng/charlie/tree/master/lib/swizzle.fs)\n-   [lib/synth.fs](https://github.com/thi-ng/charlie/tree/master/lib/synth.fs)\n\n### GLSL live coding \u0026 cross-compiler\n\nThe above\n[lib/glsl.fs](https://github.com/thi-ng/charlie/tree/master/lib/glsl.fs)\nlibrary contains a Forth -\u003e GLSL cross-compiler, based on word inlining\nand emulating a stack machine via multiple variables.\n\nThe concept was inspired by [Brad Nelson](https://flagxor.com/)'s [Forth\nHaiku](https://forthsalon.appspot.com/), however here (as an exercise)\nthe cross-compiler is entirely written in Forth itself...\n\nDemo source: [demo/webgl.fs](https://github.com/thi-ng/charlie/tree/master/demo/webgl.fs)\n\nUsage in the REPL:\n\n```\n( this includes the cross-compiler automatically )\n\"demo/webgl.fs\" include*\n```\n\nSome small examples (more are included in the demo source, also see\nlib/glsl for available functions):\n\n**IMPORTANT:** All shader code must be wrapped by `glsl\u003e ... ;;`\n\n#### Liquid paint (ported from [GLSL](http://glslsandbox.com/e#8067.3))\n\n![screenshot](https://raw.githubusercontent.com/thi-ng/charlie/master/assets/liquid.jpg)\n\n```\nglsl\u003e\n: ti  0.3 * t + ;\n: amp 0.6 swap / * ;\n: col 3 * sin 0.5 * 0.5 + ;\n: i ( x y i -- x' y' i' )\n    \u003er over over r@ * r@ ti + sin r@ amp + 1 + -rot\n    swap r@ * r@ 10 + ti + sin r@ amp + 1.4 - r\u003e 1 + ;\n: i5 i i i i i ;\n: i10 i5 i5 ;\n\nx 2 * y 2 *\n1 i10 i10 i10\ndrop over over\n+ sin -rot col swap col\n\n;; reset\n```\n\n#### Disco floor (based on [Forth Haiku](https://forthsalon.appspot.com/haiku-view/ahBzfmZvcnRoc2Fsb24taHJkcg0LEgVIYWlrdRim4xMM)):\n\n![screenshot](https://raw.githubusercontent.com/thi-ng/charlie/master/assets/disco.jpg)\n\n```\nglsl\u003e\n: stripes 9.5 * sin ;\n: fade t * sin * ;\n\nx stripes y stripes *\n2 fade\ndup 2 fade\ndup 3 fade\n\n;; reset\n```\n\n### Web audio demo\n\nSource: [demo/popcorn.fs](https://github.com/thi-ng/charlie/tree/master/demo/popcorn.fs)\n\nUsage in the REPL:\n\n```text\n\"demo/popcorn.fs\" include*\n```\n\nOnce all lib files are loaded (give it a few seconds to be sure)...\n\n```\npopcorn\n```\n\n## Building\n\n```bash\ngit clone https://github.com/thi-ng/charlie.git\ncd charlie\n\nyarn start # start dev server\n\nyarn build # production build (written to /out)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthi-ng%2Fcharlie","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthi-ng%2Fcharlie","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthi-ng%2Fcharlie/lists"}