{"id":13760050,"url":"https://github.com/flax-lang/flax","last_synced_at":"2026-01-11T04:57:17.132Z","repository":{"id":23298226,"uuid":"26657531","full_name":"flax-lang/flax","owner":"flax-lang","description":"general purpose programming language, in the vein of C++","archived":false,"fork":false,"pushed_at":"2021-06-20T18:03:30.000Z","size":5510,"stargazers_count":147,"open_issues_count":12,"forks_count":10,"subscribers_count":10,"default_branch":"master","last_synced_at":"2024-08-03T13:04:10.643Z","etag":null,"topics":["c-plus-plus","compiler","flax","language","language-design","llvm","programming-language"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/flax-lang.png","metadata":{"files":{"readme":"README.md","changelog":"changelog.md","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":"2014-11-14T21:07:34.000Z","updated_at":"2024-06-24T15:42:14.000Z","dependencies_parsed_at":"2022-08-21T15:20:48.159Z","dependency_job_id":null,"html_url":"https://github.com/flax-lang/flax","commit_stats":null,"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flax-lang%2Fflax","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flax-lang%2Fflax/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flax-lang%2Fflax/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flax-lang%2Fflax/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/flax-lang","download_url":"https://codeload.github.com/flax-lang/flax/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224949674,"owners_count":17397208,"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":["c-plus-plus","compiler","flax","language","language-design","llvm","programming-language"],"created_at":"2024-08-03T13:01:02.655Z","updated_at":"2026-01-11T04:57:17.067Z","avatar_url":"https://github.com/flax-lang.png","language":"C++","readme":"# [Flax](https://flax-lang.github.io)\n\nA low level, general-purpose language with high level syntax and expressibility.\n\n\n[![forthebadge](https://forthebadge.com/images/badges/made-with-crayons.svg)](http://forthebadge.com)\n[![forthebadge](https://forthebadge.com/images/badges/built-with-resentment.svg)](http://forthebadge.com)\n\n[![build status](https://ci.appveyor.com/api/projects/status/c9cmm08t27ef1hji/branch/master?svg=true)](https://ci.appveyor.com/project/zhiayang/flax/branch/master)\n\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\n[![build status](https://github.com/flax-lang/flax/workflows/CI/badge.svg)](https://github.com/flax-lang/flax/actions)\n\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\n[![Build Status](https://semaphoreci.com/api/v1/zhiayang/flax/branches/master/badge.svg)](https://semaphoreci.com/zhiayang/flax)\n\n\n-----------------------------------------------\n\n#### Disclaimer ####\n\nI work on Flax in my spare time, and as the lone developer I cannot guarantee continuous development.\nI'm no famous artist but this is my magnum opus, so it'll not be abandoned anytime soon.\n\n### Language Goals\n\n- No header files.\n- Minimal runtime\n- Minimal stupidity\n- Clean, expressive syntax\n\n\n-----------------------------------------------\n\n\n### Current Features\n\n- Structs, unions, enums\n- Arrays (fixed and dynamic), slices\n- Pointer manipulation/arithmetic\n- Operator overloading\n- Generic functions and types\n- Type inference (including for generics)\n- Full compile-time execution (of arbitrary code)\n- Classes, including virtual dispatch and (single) inheritance\n\n-----------------------------------------------\n\n\n### Language Syntax\n\n- We don't have a proper place that documents everything yet, but most of the basic stuff is probably not gonna change much.\n  The testing code in `build/tests/` (most of them, anyway — check `tester.flx` to see which ones we call) tests basically 90% of the\n  language, so that's the syntax reference for now.\n- Yes, the syntax is not \"officially\" defined by a grammar. The reference parser implementation is the One True Definition, for now.\n\n-----------------------------------------------\n\n\n\n### Code Sample\n\n```rust\nimport std::io as _\n\n@entry fn main()\n{\n\tprintln(\"hello, world!\")\n}\n\n```\n\n```rust\ndo {\n\tfn prints\u003cT, U\u003e(m: T, a: [U: ...])\n\t{\n\t\tfor x in a =\u003e printf(\" %.2d\", m * x)\n\t}\n\n\tprintf(\"set 6:\")\n\tlet xs = [ 1, 2, 3, 4, 5 ]\n\tprints(3, ...xs)\n\n\tprintf(\"\\n\")\n}\n\ndo {\n\tunion option\u003cT\u003e\n\t{\n\t\tsome: T\n\t\tnone\n\t}\n\n\tlet x = option::some(\"foobar\")\n\tlet y = option::some(456)\n\n\tprintln(\"x = %, y = %\", x as some, y as some)\n}\n```\n\n-----------------------------------------------\n\n\n### Building the Flax compiler\n\n#### Dependencies ####\n- LLVM 11, mostly due to their obsession with changing the IR interface every damn version\n- GMP/MPIR\n- MPFR\n- libffi\n\n\n#### macOS / Linux\n\n- The `makefile` is the preferred way to build on UNIX systems.\n- LLVM needs to be installed. On macOS, `brew install llvm` should work, and you might need to do some PPA fiddling for Debian-based distros.\n- A C++17-compatible compiler should be used.\n- Find the `flaxc` executable in `build/sysroot/usr/local/bin`.\n- Additionally, the (admittedly limited) standard library will be copied from `./libs` to `./build/sysroot/usr/local/lib/flaxlibs/`.\n\n\n#### Windows\n\n- Install [meson](https://mesonbuild.com/).\n- Run `env MPIR_ROOT_DIR=... LLVM_ROOT_DIR=... meson meson-build-dir` to set the locations for the dependencies (see `meson.build` for the names, there are 4) and configure the build.\n- Optionally, pass `--buildtype=release` to build a release-mode compiler (highly recommended).\n- Run `ninja -C meson-build-dir`.\n- `flaxc.exe` will be found in the build directory.\n\n##### Libraries\n- Download the [prebuilt binaries](https://github.com/flax-lang/flax/releases/tag/win-build-deps) for the 4 dependencies, and place them somewhere.\n- Note: the folder structure of the libraries should be `(llvm|mpir|mpfr|libffi)/(Release|Debug)/(include|lib)/...`.\n\n\n-----------------------------------------------\n\n\n### Building Flax Programs\n\nSince nobody in their right mind is *actually* using this, please pass `-sysroot build/sysroot` to invocations of the compiler -- else the compiler will default to looking somewhere in `/usr/local/lib` for libraries. Speaking of which, standard libraries are looked for in `\u003csysroot\u003e/\u003cprefix\u003e/lib/flaxlibs/`. Prefix is set to `/usr/local/` by default.\n\nSince version 0.41.2, executables can be generated on all 3 of our supported platforms! For Linux and macOS, all that is required is a working C compiler in the `$PATH`; we call `cc` to link object files.\n\nFor Windows, even if you are not building the compiler from source (eg. you are using a released binary), Visual Studio 2017 or newer must still be installed, with the \"Desktop development with C++\", \"MSVC v142 (or whatever)\", and \"Windows 10 SDK\" components. However, we currently find the toolchain through [established means](https://gist.github.com/machinamentum/a2b587a68a49094257da0c39a6c4405f), so that `link.exe` does not have to be in the `%PATH%`, ie. you do not have to call `vcvarsall.bat` before running the compiler.\n\n-----------------------------------------------\n\n### Contributors\n\nSpecial thanks to the Unofficial Official Language Consultants:\n[darkf](https://github.com/darkf), [adrian17](https://github.com/adrian17),\n[sim642](https://github.com/sim642), and [ryu0](https://github.com/ryu0).\n\n\n\n\n### Contributing\n\nFeel free to open an issue if you feel that there's any missing feature, or if you found a bug in the compiler. Pull requests are also\nwelcome.\n\n\n\n### Licensing\n\nThe Flax compiler itself (this repository) is licensed under the Apache 2.0 license (see `LICENSE` file). For ease of building, some dependencies\nare included in the repository itself (under the `external` folder) and compiled together, instead of as a separate library (shared or otherwise).\nThese are:\n\n1. [mpreal](https://bitbucket.org/advanpix/mpreal), GPL\n2. [utf8rewind](https://bitbucket.org/knight666/utf8rewind), MIT\n3. [tinyprocesslib](https://gitlab.com/eidheim/tiny-process-library), MIT\n\n\n\n\n\n\n\n\n\n\n\n\n","funding_links":[],"categories":["Embed-Script/VM/","C++","Other"],"sub_categories":["Lua"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflax-lang%2Fflax","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflax-lang%2Fflax","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflax-lang%2Fflax/lists"}