Skip to content
/ fun Public

fun is a statically-typed language that transpiles to C, combining safety and performance with C's efficiency.

License

Notifications You must be signed in to change notification settings

omdxp/fun

Repository files navigation

fun

CI License: MIT

A statically-typed programming language that transpiles to C, designed for safety, performance, and leveraging the power of C. Written in Zig.


Table of Contents


Features

  • Statically-typed language with C-like performance
  • Transpiles to readable C code
  • Simple, expressive syntax
  • Imports and modularity
  • Pattern matching with fit statement
  • Type-safe variables and functions
  • CLI with multiple output and debug options
  • AST printing and analysis
  • Comprehensive error handling
  • Example and test suite

Installation

Requires Zig (v0.14.0+ recommended).

zig build

This will build the fun compiler in zig-out/bin/fun.

CLI Usage

Usage: fun -in <input_file> [-out <output_file>] [-no-exec] [-outf] [-ast] [-help]

Arguments:
  -in      <file>  Input file to compile (required)
  -out     <file>  Output file (optional, defaults to input filename with .c extension)
  -no-exec         Disable automatic compilation and execution (optional, execution enabled by default)
  -outf            Generate .c output file (optional, disabled by default)
  -ast             Print AST nodes (optional, disabled by default)
  -help            Show this help message

Quickstart

Write your first program in hello.fn:

imp std.io;

fun main(str[] args) {
    printf("Hello, World!\n");
}

Compile and run:

zig build
./zig-out/bin/fun -in hello.fn

Examples

Explore the examples/ directory for more:

Project Structure

  • cmd/ — CLI entrypoint
  • modules/ — Core compiler modules (lexer, parser, codegen, semantics, utils, etc.)
  • examples/ — Example programs
  • tests/ — Test suite
  • build.zig — Zig build script

Contributing

Contributions are welcome! Please open issues or pull requests. See CONTRIBUTING.md if available.

Changelog

See CHANGELOG.md for release notes and development history.

License

This project is licensed under the MIT License. See the LICENSE file for details.

About

fun is a statically-typed language that transpiles to C, combining safety and performance with C's efficiency.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Languages