Introduction

Sun Programming Language

Sun is a general-purpose systems programming language designed particularly for the needs of robotics and AI. It provides Rust-style memory safety, a familiar syntax, and classic concepts such as classes and interfaces. The design optimizes for performance and intelligibility, for human programmers as well as AI coding agents. Sun additionally aims to improve software distribution, especially in robotics applications, by making it easier to package and distribute portable, systems-level software modules.

Hello World

main.sun
using std.io;
 
using std;
 
/** Runs the example that prints a greeting. */
function main() void {
  println("Hello, Sun!");
}
 
manifest {
  libraries: [
    "sun/stdlib"
  ]
}

Run directly with JIT:

sun main.sun
Hello, Sun!

Or compile to a native executable:

sun -c -o main main.sun
./main
Hello, Sun!

This is examples/00-hello/ (opens in a new tab), compiled and run in CI — the source above is read straight from that folder.

Design Goals

  • Fast: Systems-level performance without runtime overhead
  • Memory safe: No undefined behavior via Rust-style borrow checking
  • Readable: Straightforward for humans (and AI agents) to read and understand
  • Unambiguous: Sun minimizes alternative syntaxes and hidden control flow with explicit class hooks for supported arithmetic operators. There are no hidden memory allocations, no implicit copies of compound values, and no macros.
  • Modular: Sun makes it simple to package and distribute pre-compiled modules (called moon libraries). Source files and dependencies are declared in a manifest block, directly in the source code, making the Sun compiler its own build system. Sun can download dependencies directly from your private GitHub and other platforms, making a centralized package manager unnecessary (though one could still be useful for hosting "trusted" packages.)
  • Designed for Robotics: Robotics software typically involves dozens to hundreds of processes that run across one or more compute nodes and communicate over a DDS (opens in a new tab) using some kind of pub-sub middleware (e.g. ROS (opens in a new tab)). The standard message serialization format is protobuf, which Sun provides built-in support for. A custom DDS and middleware are on the roadmap.
  • Designed for AI: NumPy-like N-D matrices and linear algebra are provided in the standard library. Built-in support for hardware accelerators/GPUs using LLVM Offload is on the roadmap.
⚠️

These are goals and not claims about the language's current capabilities.

Installation

Ubuntu (Debian Package)

Download and install the latest development build:

curl -fL https://github.com/namo-robotics/sun/releases/download/dev/sun_0.dev_amd64.deb -o /tmp/sun_0.dev_amd64.deb && chmod 0644 /tmp/sun_0.dev_amd64.deb
sudo apt install /tmp/sun_0.dev_amd64.deb && rm -f /tmp/sun_0.dev_amd64.deb

Using /tmp lets APT's restricted _apt user reach the package even when your home directory is private. Setting mode 0644 also handles restrictive user umasks.

The package installs sun and sun-lsp to /usr/bin and includes bundled libraries installed to /usr/lib/sun. To update, download and install the new package.

macOS (Apple Silicon)

Install with Homebrew:

brew install namo-robotics/sun/sun

That installs sun, sun-lsp, the standard library and the TLS bundle, and pulls in llvm@20 — the compiler's one runtime dependency. Update with brew update && brew upgrade sun.

Uninstalling

To uninstall the Debian package:

sudo apt remove sun
sudo apt autoremove

To uninstall on macOS:

brew uninstall sun

Build from Source

Clone the repository:

git clone https://github.com/namo-robotics/sun.git
cd sun

On Ubuntu/Debian, install dependencies and build:

./scripts/install-dependencies.sh
./build.sh --reconfigure

APT repositories must provide LLVM 20 and matching libclang development packages. Requires an x86_64 host and /usr/local/bin on PATH for static musl linking. The installer uses sudo as needed; --yes accepts prompts and --dry-run previews changes.

On Apple Silicon macOS, install Homebrew and Xcode Command Line Tools, then install dependencies and build:

./scripts/install-macos-dependencies.sh
./build.sh

Use --dry-run to preview installation. build.sh finds Homebrew dependencies and prepares or reuses static OpenSSL for TLS, unless --skip-stdlib is set.

CMake builds pinned Protobuf sources; offline builds need libprotoc-dev and -DSUN_BUNDLED_PROTOBUF=OFF. Install CUDA, GNU cross-compilers, and release packaging tools separately if needed.

To build and install the compiler, language server, and standard Moon bundles:

./build.sh --install

--install defaults to an optimized Release compiler. Plain ./build.sh uses Debug for compiler development; --build-type RelWithDebInfo enables optimization with debug information. Changing the build type reconfigures the existing build directory and requires recompilation.

Binaries go to /usr/local/bin and bundles to /usr/local/lib/sun. Use --prefix /absolute/path to choose another location. Plain ./build.sh only builds; ./build.sh --uninstall removes the installed Sun files without building or removing dependencies. Use the same prefix when uninstalling.

Quick Start

The rest of this page works through the main.sun program from Hello World above.

JIT Execution

To compile and run a Sun program in one go, with just-in-time (JIT) compilation, pass the sun compiler a single .sun file containing a manifest block:

sun main.sun
Hello, Sun!

Compile to native executable

sun -c -o main main.sun
./main
Hello, Sun!

Debug Mode

Use --debug to generate artifacts for debugging the compiler itself:

sun --debug main.sun
Hello, Sun!
Debug output folder: main_debug/
  Generated: main_debug/ast.dot
  Generated: main_debug/scope_tree.html
  Generated: main_debug/ir.ll

This creates:

  • ast.dot — GraphViz visualization of the AST
  • ir.ll — the LLVM IR for the program's own code
  • scope_tree.html — HTML visualization of semantic scopes

The IR keeps only what this file compiled to; the stdlib it calls into is filtered out:

main_debug/ir.ll
; Excerpt: the Sun entrypoint and its string constant
 
@str = private unnamed_addr constant [12 x i8] c"Hello, Sun!\00", align 1
define void @__sun_main_void() {
entry:
  call void @_SUN1_301c2b20b910ebbf5751c1ef73b178d7c02fdace99dd1aec60630f7a7a7119e4(%static_ptr_struct { ptr @str, i64 11 })
  ret void
}

The _SUN1_ symbol identifies the imported println declaration. Its digest comes from the declaration’s portable identity, so unrelated declarations do not collide. The exact symbol depends on the library being used.

Visualize the AST:

dot -Tpng main_debug/ast.dot -o ast.png

Manifests

Declare source files and library dependencies in a manifest block:

manifest {
  source_files: ["utils.sun", "math.sun"]
  libraries: [
    "stdlib.moon",
    "$MYLIB/mylib.moon"
]
}

Source paths are relative to this file. Libraries are found through configured search paths. Configure downloaded libraries in sun-config.json; manifests reference their verified local .moon paths.

Paths can use variables such as $LIBS/mathlib.moon, defined in sun-config.json or with --path-var LIBS=libs. See Modules and Manifests for more options.

Sun Config

Use sun-config.json to name your package and its build products. Paths are relative to the config file.

sun-config.json
{
  "root": true,
  "package_id": "example/app",
  "entrypoints": [
    {"name": "app", "path": "src/main.sun", "type": "binary", "export": true}
  ]
}

Build the project or run its tests:

sun build
sun test sun-config.json

A workspace can include several projects, each with its own config:

{
  "projects": ["core/sun-config.json", "ui/sun-config.json"]
}

Select packages and products from a Git repository:

{
  "dependencies": [{
    "type": "git",
    "url": "git@github.com:example/toolkit.git",
    "version": "v1.2.3",
    "packages": {
      "example/core": {"entrypoints": ["core"]},
      "example/ui": {"entrypoints": ["widgets", "viewc"]}
    }
  }]
}

Import built libraries with paths such as "${example/core}/lib/core.moon". Add "config": "build/sun-config.json" to select another config in the repository.

See project configuration, Git dependencies, and target-specific settings for more options.

Moons

Moons (.moon files) are precompiled library bundles containing compiled code and type information. Create a moon from any .sun file containing a manifest:

mylib.sun
public module mylib {
  public function helper() i32 { return 42; }
}
 
manifest {
  source_files: ["utils.sun", "math.sun"]
}
sun --emit-moon -o mylib.moon mylib.sun

A moon is linked into whatever imports it, so a compiled program carries the moons it uses — nothing to install beside the binary, and nothing to load at run time.

C libraries follow the same preference: sun -c links statically by default, requiring a musl toolchain on Linux, and produces one self-contained executable. Dynamic linkage is still available — --dynamic links against shared objects, which vendor SDKs shipped only as .so files need, and macOS targets are always dynamic because Apple ships no static libSystem. See C FFI for the details.

Quick Links