{"id":15520667,"url":"https://github.com/turbolent/ralph","last_synced_at":"2025-04-23T03:50:39.184Z","repository":{"id":1106100,"uuid":"972028","full_name":"turbolent/ralph","owner":"turbolent","description":"Ralph is a Lisp-1 dialect that compiles to JavaScript","archived":false,"fork":false,"pushed_at":"2019-10-17T02:15:50.000Z","size":2337,"stargazers_count":74,"open_issues_count":2,"forks_count":4,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-04-17T19:17:23.789Z","etag":null,"topics":["apple","compiler","dylan","javascript","language","lisp","macros","prefix-dylan","ralph","repl"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/turbolent.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2010-10-08T12:00:12.000Z","updated_at":"2024-08-27T02:10:11.000Z","dependencies_parsed_at":"2022-08-16T12:00:52.369Z","dependency_job_id":null,"html_url":"https://github.com/turbolent/ralph","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/turbolent%2Fralph","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/turbolent%2Fralph/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/turbolent%2Fralph/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/turbolent%2Fralph/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/turbolent","download_url":"https://codeload.github.com/turbolent/ralph/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250366685,"owners_count":21418768,"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":["apple","compiler","dylan","javascript","language","lisp","macros","prefix-dylan","ralph","repl"],"created_at":"2024-10-02T10:28:35.219Z","updated_at":"2025-04-23T03:50:39.164Z","avatar_url":"https://github.com/turbolent.png","language":"JavaScript","readme":"# Ralph\n\nRalph is a Lisp-1 dialect that compiles to JavaScript. It is heavily inspired \nby an early version of Dylan (also known as \"Prefix Dylan\"), as described in \n[Dylan – An object-oriented dynamic language](http://lispm.de/docs/prefix-dylan/book.annotated/contents.html).\n\n## Getting started\n\n### Installation\n\nFirst, install [Node.js](http://nodejs.org/) and then all necessary modules:\n\n* `$ npm install`\n\nThe directory `core` already contains the full Ralph runtime and compiler \nas pre-compiled JavaScript, so you are ready to go.\n\n### REPL\n\nTo start a local, Node.js-based REPL, run:\n\n* `$ NODE_PATH=core node repl.js`\n\nTo start a remote, browser-based REPL, install [browserify](http://browserify.org/),\ngenerate the browser evaluator, start the REPL with the `--remote` option,\nand open `index.html` in your browser:\n\n* `$ NODE_PATH=~/node_modules:core browserify evaluator.js -o evaluator.out.js`\n* `$ NODE_PATH=core node repl.js --remote`\n\n### Compilation\n\nTo compile a simple \"Hello, world!\" program:\n\n* Place `hello.ralph` into `src`:\n \n  ```\n  (define-module hello\n    import: (ralph/format-out)\n    export: (hello))\n      \n  (define-function hello (name)\n    (format-out \"Hello, %s!\" name))\n  ```\n\n* Compile the `hello` module. The compiler outputs files into `build`.\n\n  `$ NODE_PATH=core node -e \"require('ralph/compiler')['compile-module']('hello')\"`\n\n* Run the program by opening the `hello` module and calling the `hello` function:\n\n  ```\n  $ NODE_PATH=build node -e \"require('hello')['hello']('World')\"\n  Hello, World!\n  ```\n\n## Documentation\n\nThere is unfortunately no API documentation. The module [`ralph/core`](src/ralph/core.ralph) \ncontains the core runtime and the standard library. \n\nThe [manual of Prefix Dylan](http://lispm.de/docs/prefix-dylan/book.annotated/contents.html) \ncan be used as a reference and is a good introduction into the language.\n\nThere are also [slides from a talk](http://turbolent.github.io/ralph-ilc2012/) \ngiven at [ILC 2012](http://www.international-lisp-conference.org/2012/index.html),\nand a [paper](https://github.com/turbolent/ralph-ilc2012/blob/master/paper.pdf) \nexplaining the motivation, features and compilation strategy of Ralph.\n\n### Syntax\n\nFor performance reasons, Ralph is using JavaScript arrays as its core data structure,\ninstead of implementing its own list data structure based on objects. Arrays can be\ncreated using the `[]` syntax (e.g. `(first [1 2 3])`).\n\nThe syntax for numbers and strings is that of JavaScript. \n\nSymbols may contain any character which is not otherwise syntactically significant\n(e.g., introduces a number, an array, etc). The character sequence `::` in symbols\nis treated as the separator for fully-qualified symbols: The first part is \nthe module name, the second is the symbol name.\n\nKeywords have the same syntax as symbols and end with a colon (e.g., `foo:`).\n\nThe syntax for the canonical true value is `#t`, for the canonical false value `#f`.\n\nIn parameter lists, `#rest` is used to introduce the name of the variable containing\nthe additional arguments, and `#key` is used to introduce keyword parameters.\n\nA single quote is used for quoting. A backquote is used for syntax-quoting (see [macros](#Macros)).\n\nA semicolon indicates the start of a comment. \n\n## Interoperability\n\nThe special operator `%native` allows writing inline JavaScript. All strings that are\npassed to it are directly emitted as-is. Numbers are first converted to strings, and \nsymbols are properly renamed. Other forms are not supported.\n\nFor example, the following Ralph code\n\n```\n(bind ((delta 3))\n  (%native \"x += \" delta \" * \" 2))\n```\n\nwould compile to the following JavaScript code:\n\n```\nvar delta__1 = 3;\nx += delta__1 * 2;\n```\n\nRalph's compiler knows nothing about the global `x` and there is no need to \ndeclare it exists.\n\nThe utility macro `.` can be used for easily writing JavaScript method calls.\nFor example,\n\n```\n(. (%native \"console\") \n   (log \"Hello, %s\" \"World\"))\n```\n\nwould compile to:\n\n```\nconsole.log(\"Hello, %s!\", \"World\");\n```\n  \nRalph also integrates well with Node.js. To be able to use a Node.js module \nin Ralph, place a `.rm` file (ralph module definition) in `src` that specifies\nthe name, it is native (`native?: #t`) and the definitions it is exporting. \n\nFor example, a basic definition for the Node.js module `vm` could look like:\n\n```\n(\"vm\"\n native?: #t\n exports: (\"createContext\" \"runInContext\"))\n```\n\nSee [`fs`](src/fs.rm) and [`ralph/file-system`](src/ralph/file-system.ralph)\nfor a an extended example of this mechanism.\n\n\n## Macros\n\nRalph supports hygienic macros through Clojure-like syntax-quoting.\n\nIn a separate module, define the macro using `define-macro`. In the module you \nwant to use it, import the module during compilation using the `compile-time-import:`\noption in the `define-module` definition. \n\nFor a full example, see [`ralph/macro-test.a`](src/ralph/macro-test.a.ralph), which\ncan be compiled using.\n\n` $ NODE_PATH=core:build node -e \"require('ralph/compiler')['compile-module']('ralph/macro-test.a')\"`\n\nThe section \"Macro system\" in the [paper](https://github.com/turbolent/ralph-ilc2012/blob/master/paper.pdf) contains more details.\n\n## Development\n\nThe compiler can be recompiled and all tests can be run using:\n\n* `$ ./scripts/test-self.sh`\n\n\n## Status\n\nRalph is [not actively maintained](http://turbolent.com/2014/09/20/ralph-future.html).\n\nIf you have questions, are interested in using it, or even would like to continue its development, just open a new issue!\n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fturbolent%2Fralph","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fturbolent%2Fralph","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fturbolent%2Fralph/lists"}