All Projects → flax-lang → Flax

flax-lang / Flax

Licence: apache-2.0
general purpose programming language, in the vein of C++

Programming Languages

language
365 projects

Projects that are alternatives of or similar to Flax

Unlisp Llvm
Compiler for a toy Lisp language
Stars: ✭ 33 (-70.27%)
Mutual labels:  compiler, llvm
Seeless
C IDE for iOS
Stars: ✭ 71 (-36.04%)
Mutual labels:  compiler, llvm
Llvm Tutorial Standalone
DEPRECATED (Use: https://github.com/llvm-hs/llvm-hs-kaleidoscope )
Stars: ✭ 38 (-65.77%)
Mutual labels:  compiler, llvm
Cfl
a Compileable statically typed Functional programming Language
Stars: ✭ 7 (-93.69%)
Mutual labels:  compiler, llvm
Numba Scipy
numba_scipy extends Numba to make it aware of SciPy
Stars: ✭ 98 (-11.71%)
Mutual labels:  compiler, llvm
Lyca
programming language compiler w/ llvm
Stars: ✭ 9 (-91.89%)
Mutual labels:  compiler, llvm
Kai
An expressive low level programming language
Stars: ✭ 68 (-38.74%)
Mutual labels:  compiler, llvm
Gocaml
🐫 Practical statically typed functional programming language implementation with Go and LLVM
Stars: ✭ 653 (+488.29%)
Mutual labels:  compiler, llvm
Enzyme.jl
Julia bindings for the Enzyme automatic differentiator
Stars: ✭ 90 (-18.92%)
Mutual labels:  compiler, llvm
Ghdl
VHDL 2008/93/87 simulator
Stars: ✭ 1,285 (+1057.66%)
Mutual labels:  compiler, llvm
Ldc
The LLVM-based D Compiler.
Stars: ✭ 937 (+744.14%)
Mutual labels:  compiler, llvm
Fanx
A portable programming language
Stars: ✭ 101 (-9.01%)
Mutual labels:  compiler, llvm
Grin
GRIN is a compiler back-end for lazy and strict functional languages with whole program optimization support.
Stars: ✭ 834 (+651.35%)
Mutual labels:  compiler, llvm
Zion
A statically-typed strictly-evaluated garbage-collected readable programming language.
Stars: ✭ 33 (-70.27%)
Mutual labels:  compiler, llvm
Numba
NumPy aware dynamic Python compiler using LLVM
Stars: ✭ 7,090 (+6287.39%)
Mutual labels:  compiler, llvm
Leekscript V2
A dynamically typed, compiled just-in-time programming language used in Leek Wars' AIs
Stars: ✭ 46 (-58.56%)
Mutual labels:  compiler, llvm
Rhine Ml
🏞 an OCaml compiler for an untyped lisp
Stars: ✭ 621 (+459.46%)
Mutual labels:  compiler, llvm
Llvmswift
A Swift wrapper for the LLVM C API (version 9.0.1)
Stars: ✭ 641 (+477.48%)
Mutual labels:  compiler, llvm
Akilang
A compiler for a simple language, built with Python and LLVM
Stars: ✭ 71 (-36.04%)
Mutual labels:  compiler, llvm
Faust
Functional programming language for signal processing and sound synthesis
Stars: ✭ 1,360 (+1125.23%)
Mutual labels:  compiler, llvm

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

  • No header files.
  • Minimal runtime
  • Minimal stupidity
  • Clean, expressive syntax

Current Features

  • Structs, unions, enums
  • Arrays (fixed and dynamic), slices
  • Pointer manipulation/arithmetic
  • Operator overloading
  • Generic functions and types
  • Type inference (including for generics)
  • Full compile-time execution (of arbitrary code)
  • Classes, including virtual dispatch and (single) inheritance

Language Syntax

  • We don't have a proper place that documents everything yet, but most of the basic stuff is probably not gonna change much. The testing code in build/tests/ (most of them, anyway — check tester.flx to see which ones we call) tests basically 90% of the language, so that's the syntax reference for now.
  • Yes, the syntax is not "officially" defined by a grammar. The reference parser implementation is the One True Definition, for now.

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

  • LLVM 11, mostly due to their obsession with changing the IR interface every damn version
  • GMP/MPIR
  • MPFR
  • libffi

macOS / Linux

  • The makefile is the preferred way to build on UNIX systems.
  • 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.
  • A C++17-compatible compiler should be used.
  • Find the flaxc executable in build/sysroot/usr/local/bin.
  • Additionally, the (admittedly limited) standard library will be copied from ./libs to ./build/sysroot/usr/local/lib/flaxlibs/.

Windows

  • Install meson.
  • 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.
  • Optionally, pass --buildtype=release to build a release-mode compiler (highly recommended).
  • Run ninja -C meson-build-dir.
  • flaxc.exe will be found in the build directory.
Libraries
  • Download the prebuilt binaries for the 4 dependencies, and place them somewhere.
  • Note: the folder structure of the libraries should be (llvm|mpir|mpfr|libffi)/(Release|Debug)/(include|lib)/....

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
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].