{"id":13344041,"url":"https://github.com/onyxlang/ts","last_synced_at":"2025-03-12T06:31:08.130Z","repository":{"id":94994925,"uuid":"209400018","full_name":"onyxlang/ts","owner":"onyxlang","description":"An Onyx compiler implementation in Typescript","archived":false,"fork":false,"pushed_at":"2022-09-01T12:31:05.000Z","size":109,"stargazers_count":7,"open_issues_count":8,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-10-24T16:50:23.026Z","etag":null,"topics":["compiler","deno","onyx","zig"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/onyxlang.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,"governance":null,"roadmap":"ROADMAP.md","authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-09-18T20:39:36.000Z","updated_at":"2023-01-29T21:43:51.000Z","dependencies_parsed_at":"2023-06-11T12:30:49.012Z","dependency_job_id":null,"html_url":"https://github.com/onyxlang/ts","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/onyxlang%2Fts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onyxlang%2Fts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onyxlang%2Fts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onyxlang%2Fts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/onyxlang","download_url":"https://codeload.github.com/onyxlang/ts/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243171612,"owners_count":20247877,"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":["compiler","deno","onyx","zig"],"created_at":"2024-07-29T19:32:19.816Z","updated_at":"2025-03-12T06:31:08.125Z","avatar_url":"https://github.com/onyxlang.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Onyx\n\n_Enjoy the performance._\n\n## 👋 About\n\nOnyx is a fresh programming language with efficiency in mind.\nThis repository contains the reference Onyx compiler implementation.\n\n\u003cdetails\u003e\n  \u003csummary\u003eBrief history\u003c/summary\u003e\n  \u003cbr /\u003e\n  Ever had that feeling of creating a game, but then remembering how painful it is to write in C++?\n  Any other language doesn't seem just the right tool?\n  Want something new?\n  \u003cbr /\u003e\u003cbr /\u003e\n  The first idea of Onyx came to me in 2020, at the very peak of my Open Source career.\n  Coming all the way from Warcraft® III™ map editor to Crystal, I am still struggling to find the most comfortable language for daily use.\n  \u003cbr /\u003e\u003cbr /\u003e\n  What I want is a language which I would consider perfect.\n  A language with a perfectly built ecosystem and organization.\n  A language with infinite possibilities.\n\u003c/details\u003e\n\n## ✨ Features\n\nFormally speaking, Onyx is an inference-typed imperative multiparadigmal computer programming language.\n\nOnyx is inspired by [Typescript](https://www.typescriptlang.org/), therefore comparing it would be enough for a brief introduction.\n\nFirst of all, Onyx is designed to be compiled to native machine code, still allowed to be evaluated dynamically.\nA Typescript bytecode compiler is hard to implement due to its dependence on EcmaScript, at least for version 4.5.4.\n\nNative compilation paves a way to directly interact with a lower-level language in form of [FFI](https://en.wikipedia.org/wiki/Foreign_function_interface).\nThis immediately makes Onyx a higher-level language, the concept of which is defined in the form of multiple safety levels: `unsafe`, `fragile`, `threadsafe`.\n\n```nx\nextern #include \"stdio.h\"\nunsafe! $puts($\"Hello, world!\") # The string has inferred type `` $`const char`* ``,\n                                # mapped to the C `const char*` type\n```\n\nThe code snippet above would be an error without `unsafe!` because the top-level scope has `fragile` safety by default (can be changed per compilation).\n\nAnother powerful feature of Onyx is macros, which are evaluated during compilation.\nThe ultimate goal is to write macros in the Onyx language itself.\n\n```nx\n%{\n  # You're inside an Onyx macro.\n  #\n\n  console.log(\"Debug = #{ $DEBUG }\") # Would output the C macro during compilation\n\n  [(\"roses\", \"blue\"), (\"violets\", \"red\")].map((pair) =\u003e {\n    emit(\"unsafe! $puts($\\\"#{ pair[0] } are #{ pair[1] })\\\"\")\n  })\n%}\n\n# Would be compiled exactly as:\n#\n\nunsafe! $puts($\"Roses are blue\")\nunsafe! $puts($\"Violets are red\")\n```\n\nOnyx encourages the use of exact typing when you need to, e.g. `Real` over `Float` over `Float\u003c64\u003e`.\nThe type system covers, among others, tensor and hypercomplex number literals and operations.\n\nGenerally, Onyx doesn't look at EcmaScript in terms of standard types.\n`[1, 2] : Int32[2] : Array\u003cInt32, 2\u003e` is, for example, a static array of fixed size, not a dynamic list.\n\nThe `struct` type in Onyx resembles a pure passed-by-value data structure.\nA `class` type data is an automatically-managed reference to a non-static memory, similar to such in Typescript.\n\nThere is no `interface` type in Onyx, but `trait`, which allows exclusively function declarations _and_ definitions.\n\nUnlike Typescript, there are no `async` and `await` keywords on the language level.\nInstead, _any_ function may be called asynchronously with a scheduler of your choice (or the standard one).\n\nThe will to make Onyx a compile-able language imposes some restrictions, of course, compared to Typescript.\nFor example, a lambda has explicit closure.\n\n```nx\nimport Scheduler from \"std/scheduler.nx\"\nimport { Mutex } from \"std/threading.nx\"\n\nfinal list = new List\u003cInt32\u003e()\nfinal mutex = new Mutex()\n\nfinal promise = Scheduler.parallel([list]() ~\u003e {\n  # The context here is implicitly `threadsafe`.\n  #\n\n  # list.push(42) # =\u003e Panic! Can't call `fragile List\u003cInt32\u003e::push`\n                  # from within a threadsafe context!\n\n  mutex.sync(() =\u003e list.push(42)) # OK, the access is synchronized,\n                                  # `Mutex::sync` call is threadsafe\n})\n```\n\nThese are just a few of the differences when compared to Typescript.\nFurther documentation to come!\n\n## 🚧 Development\n\nA _stage_ is defined by the a set of rules in no particular order.\nCurrently, the compiler is at the **stage I** implementation effort.\n\n### Stage I: ⬅️\n\n1. Compiler logic (i.e. _frontend_) is written in [Typescript](https://www.typescriptlang.org), utilizing [Peggyjs](https://github.com/onyxlang/peggy).\n1. [Zig](https://github.com/ziglang/zig) is used as the _backend_: Onyx source code is translated to Zig source code.\n1. Host machine is expected to have Zig installed on it.\n1. [Deno](https://deno.land) is assumed the development environment.\n1. Development speed \u003e runtime performance \u003e correctness.\n    1. Macros are not implemented.\n    1. Panics are shallow and incomplete.\n1. May assume that target is a mainstream Windows, Linux or MacOS machine.\n1. Target may rely on Zig standard library.\n\n### Stage II:\n\n1. Compiler logic (i.e. _frontend_) is written in Onyx.\n1. [Zig](https://github.com/ziglang/zig) is used as the _backend_: Onyx source code is translated to Zig source code.\n1. Host machine is expected to have Zig installed on it.\n1. Development speed \u003e correctness \u003e runtime performance.\n    1. Macros are not implemented.\n1. May assume that target is a mainstream Windows, Linux or MacOS machine.\n1. Target may rely on Zig standard library.\n\n### Stage III:\n\n1. Compiler logic (i.e. _frontend_) is written in Onyx.\n1. [Zig](https://github.com/ziglang/zig) is used as the _backend_: Onyx source code is translated to Zig source code internally.\n1. _(Extraneous)_ Host machine is expected to have Zig installed on it.[^1]\n1. Correctness \u003e development speed \u003e runtime performance.\n1. Target may rely on Zig standard library.\n\n[^1]: By that time Zig could become linkable as a static library.\n\n### Stage IV:\n\n1. Compiler is written in Onyx.\n1. Correctness \u003e (developer happiness = runtime performance).\n\n## 📜 License\n\nAny contribution to this repository is MIT licensed in accordance to [GitHub ToS § 6](https://docs.github.com/en/github/site-policy/github-terms-of-service#6-contributions-under-repository-license).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fonyxlang%2Fts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fonyxlang%2Fts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fonyxlang%2Fts/lists"}