{"id":20858677,"url":"https://github.com/thesephist/xin","last_synced_at":"2025-07-21T16:05:25.312Z","repository":{"id":57513389,"uuid":"232086828","full_name":"thesephist/xin","owner":"thesephist","description":"Xin (신/心) is a flexible functional programming language with a tiny core, inspired by Lisp and CSP","archived":false,"fork":false,"pushed_at":"2020-05-15T11:34:18.000Z","size":318,"stargazers_count":20,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-12T22:51:33.239Z","etag":null,"topics":["golang","interpreter","lisp","programming-language"],"latest_commit_sha":null,"homepage":"","language":"Go","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/thesephist.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":"2020-01-06T11:28:03.000Z","updated_at":"2024-09-30T18:20:20.000Z","dependencies_parsed_at":"2022-08-31T22:01:44.040Z","dependency_job_id":null,"html_url":"https://github.com/thesephist/xin","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/thesephist/xin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thesephist%2Fxin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thesephist%2Fxin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thesephist%2Fxin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thesephist%2Fxin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thesephist","download_url":"https://codeload.github.com/thesephist/xin/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thesephist%2Fxin/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266332463,"owners_count":23912661,"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","status":"online","status_checked_at":"2025-07-21T11:47:31.412Z","response_time":64,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["golang","interpreter","lisp","programming-language"],"created_at":"2024-11-18T04:46:56.660Z","updated_at":"2025-07-21T16:05:25.279Z","avatar_url":"https://github.com/thesephist.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Xin programming language\n\n[![GoDoc](https://godoc.org/github.com/thesephist/xin?status.svg)](https://godoc.org/github.com/thesephist/xin)\n[![Build Status](https://travis-ci.com/thesephist/xin.svg?branch=master)](https://travis-ci.com/thesephist/xin)\n\nXin is a functional programming language inspired by Lisp and CSP. Xin aspires to be an expressive, extensible language built on a small number of simple elements that work well together. You can find a deep dive into the language design [in the spec document](SPEC.md).\n\nXin is my second toy programming language, after [Ink](https://github.com/thesephist/ink). With Xin, I'm specifically exploring ideas around code as a data structure, lazy evaluation in an interpreter context, and streaming evented I/O.\n\nHere's the fibonacci sequence, written naively in Xin.\n\n```\n(: (fib n)\n   (if (\u003c n 2)\n     1\n     (+ (fib (- n 1))\n        (fib (- n 2)))))\n\n; 30th fibonacci number\n(fib 30)\n```\n\nXin supports proper tail calls, so we can write this in a faster (`O(n)`) tail-recursive form.\n\n```\n(: (fast-fib n)\n   ((: (f n a b)\n       (if (\u003c n 2)\n         b\n         (f (- n 1) b (+ a b))))\n    n 1 1))\n\n; 50th fibonacci number\n(fib 50)\n```\n\nYou can find more example and real-world Xin code in the sample programs in the repository:\n\n- [the standard library](lib/std.xin)\n- [quicksort, and other iterator algorithms](lib/vec.xin)\n- [pascal's triangle generator](samples/pascal-triangle.xin)\n- [clone of UNIX utility xxd](samples/xxd.xin)\n- [counting word frequently in a file](samples/freq.xin)\n- [basic TCP/IP chat server](samples/chat.xin)\n- [basic shape drawing library outputting to .bmp files](samples/art/shape.xin)\n\n## Goals\n\n- Expressive, readable, extensible syntax that's natural to read and suitable for defining DSLs\n- Programs that lend themselves to smart data structures and dumb algorithms, rather than vice versa\n- Great interactive Repl\n\n## Installation and usage\n\nWhile Xin is under development, the best way to get it is to build it from source. If you have Go installed, clone the repository and run\n\n```\ngo build ./xin.go -o ./xin\n```\n\nto build Xin as a standalone binary, or run `make install` to install Xin alongside the vim syntax highlighting / definition file.\n\nXin can currently run as a repl, or execute from a file or standard input. To run the repl, simply run from the command line:\n\n```\nxin\n```\n\nAnd a prompt will appear. Each input and output line in the prompt is numbered, and you can access previous results from the repl with the corresponding number. For example, take this repl session:\n\n```\n0 ) (+ 1 2)\n0 ) 3\n\n1 ) (vec 1 2 3)\n1 ) (\u003cvec\u003e 1 2 3)\n```\n\nWe can access `3`, the result from line 0, as the variable `_0`. Likewise, `_1` will reference the vector from line 1.\n\nTo run Xin programs from files, pass file paths to the interpreter. For example, to run `samples/list.xin`\n\n```\nxin samples/list.xin\n```\n\nYou can also pass input as stdin piped into the CLI:\n\n```\n$ echo '(log (vec::sum (nat 10))) | xin'\n55      # -\u003e output\n```\n\n## Key ideas explored\n\nWhile Xin is meant to be a practical general-purpose programming language, as a toy project, it explores a few key ideas that I couldn't elegantly fit into Ink, my first language.\n\n### Lazy evaluation\n\nIn Xin, the evaluation of every expression is deferred until usage. We call this lazy evaluation. Values are kept in \"lazy\" states until some outside action or special form coerces a lazy value to resolve to a real value.\n\n### Code as data structure\n\nLike all Lisps, the power and flexibility of Xin comes from its syntax, and the fact that it's trivial to express Xin programs as simple nested list data structures. Xin is not a \"real\" Lisp, because Xin does not use linked lists internally to represent its own syntax. But the idea of runtime syntax introspection with list data structures through macros is alive in Xin, and it's much of what makes the language so extensible.\n\nExpressing all syntax as lists (auto-resizing vectors, internally) allows functions to modify or introspect their syntax at runtime, and this allows Xin programmers to build language constructs like switch cases, variadic functions, and lambdas in the userspace, as a library function, rather than having to add them to the language core, which remains tiny.\n\n### Streaming I/O and pipes\n\nXin expresses all I/O operations as operations to streams.\n\n### Syntax minimalism and extensibility\n\nXin is unusual among even toy programming languages in that there are only four special forms defined in the language spec: `:` (called \"bind\"), `if`, `do`, and `import`. All other language constructs, like loops, switch cases, booleans, and iteration primitives are defined in the standard library as Xin forms, not in the runtime as special cases.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthesephist%2Fxin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthesephist%2Fxin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthesephist%2Fxin/lists"}