Home

Awesome

Flax

A low level, general-purpose language with high level syntax and expressibility.

forthebadge forthebadge

build status      build status      Build Status


Disclaimer

I work on Flax in my spare time, and as the lone developer I cannot guarantee continuous development. I'm no famous artist but this is my magnum opus, so it'll not be abandoned anytime soon.

Language Goals


Current Features


Language Syntax


Code Sample

import std::io as _

@entry fn main()
{
	println("hello, world!")
}

do {
	fn prints<T, U>(m: T, a: [U: ...])
	{
		for x in a => printf(" %.2d", m * x)
	}

	printf("set 6:")
	let xs = [ 1, 2, 3, 4, 5 ]
	prints(3, ...xs)

	printf("\n")
}

do {
	union option<T>
	{
		some: T
		none
	}

	let x = option::some("foobar")
	let y = option::some(456)

	println("x = %, y = %", x as some, y as some)
}

Building the Flax compiler

Dependencies

macOS / Linux

Windows

Libraries

Building Flax Programs

Since 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 <sysroot>/<prefix>/lib/flaxlibs/. Prefix is set to /usr/local/ by default.

Since 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.

For 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, 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.


Contributors

Special thanks to the Unofficial Official Language Consultants: darkf, adrian17, sim642, and ryu0.

Contributing

Feel 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 welcome.

Licensing

The Flax compiler itself (this repository) is licensed under the Apache 2.0 license (see LICENSE file). For ease of building, some dependencies are included in the repository itself (under the external folder) and compiled together, instead of as a separate library (shared or otherwise). These are:

  1. mpreal, GPL
  2. utf8rewind, MIT
  3. tinyprocesslib, MIT