Official website for the Feng language

Build more reliable software.

Feng combines static typing, explicit contracts, modular organization, and a straightforward workflow, so you can build everyday apps and libraries, call into C when needed, and ship packages with the same toolchain.

  • 26 Keywords
  • 23 Reserved Words
  • 6 Built-in Annotations
type spec fit @fixed .fb

Why Feng

If you want a language with compact syntax and clear rules for types, abstractions, error handling, and C interop, Feng aims to offer a more direct path.

While coding
Types are known at compile time, so refactoring and debugging stay direct instead of turning into runtime hunts.
While designing APIs
Use `spec` and `fit` to make contracts explicit, which keeps collaboration and long-term evolution stable.
While integrating existing code
Call into C with `extern fn` and `@fixed` without giving up the language's clarity.

Language features

Features

Static typing

Many mistakes show up at compile time, which makes day-to-day coding and refactoring more predictable.

Unified type system

Object types and ABI-fixed layout types live in the same language, so you spend less time switching mental models.

Explicit contracts

`spec` and `fit` keep contracts and adaptation rules in the source, which makes intent easier to read and maintain.

Functions, lambdas, closures

You can write straightforward application code and still lift behavior into reusable functions, lambdas, and closures.

Structured exceptions and memory management

Error handling stays explicit, and ordinary objects are managed by the runtime, which helps keep everyday code clean.

C interop and package distribution

When you need to call C libraries or ship binary packages, the language already gives you a clear path.

Code sample

Sample

One shows syntax, the other shows a minimal project setup.

Types, methods, and a C import
mod app.hello;

@cdecl("libc")
extern fn puts(msg: string): int;

type User {
  let name: string;
  let age: i32;

  fn say(msg: string): void {
    puts(msg);
  }
}

fn main(args: string[]): void {
  let user = User {
    name: "Houfeng",
    age: 18
  };

  user.say("Hello World: " + user.name);
}

Workflow

Workflow

01

Initialize

Start with `feng init` to get a project skeleton, a manifest, and an entry template so you can begin immediately.

feng init demo
02

Check as you go

Run `feng check` while you work so you can catch problems early instead of waiting for a later build failure.

feng check
03

Build

`feng build` reads the project manifest and produces the target artifact through one straightforward path.

feng build
04

Run or pack

Use `feng run` for applications, and switch to `feng pack` when you want a `.fb` package for a library.

feng run
# for library projects
feng pack

What to learn next

More

These are the main topics to explore after the homepage overview.

Modules and imports `mod` and `use` help you organize code, split modules, and make dependencies explicit.
Types and bindings `type`, `let`, `var`, constructors, and methods define how you organize data and behavior.
Functions and abstraction `fn`, overloading, lambdas, and closures let you move naturally from simple calls to reusable abstractions.
Control flow `if`, conditional expressions, `while`, `for`, `break`, and `continue` cover everyday control-flow needs.
Exceptions and lifetime Structured exceptions and automatic memory management define how programs handle failure and how objects are reclaimed.
Interop and distribution This area matters when you need system integration, existing libraries, or binary package distribution.