Skip to content

Docs/Getting Started/Coming from Rust, Zig, Go or C

Coming from Rust, Zig, Go or C

What carries over to Fid from Rust, Zig, Go and C, what works differently, and what Fid does not have yet.

~4 min read

On this page

Fid is a systems language with a borrow checker, capability grants on imports and effect tracking. This page maps what you already know onto Fid, and says plainly what is missing. For the current state of every feature, see Feature Status.

Coming from Rust

In RustIn Fid
let / let mutval / var
Lifetimes ('a)None. References are second-class: they cannot be stored in a struct, returned from a local, or sent to another thread
Move on assignmentCopy on assignment. var b = a on a Vec, HashMap or str gives an independent value, shared until the first write
trait / impl T for Xcap / impl Cap for X, with default methods, associated types and dyn
MacrosNone. comptime blocks and functions run ordinary Fid code at compile time, with type reflection
Result, Option, ?The same, in the core library
unsafeunsafe { } for raw pointers and C calls; fid audit lists every block a program reaches
Send@send, checked on every argument of a spawned call
Cargo and crates.ioark with path and git dependencies. The registry is planned
Nothing built inCapability grants (use lib with { IO }) and effect annotations (!IO, !{}), checked by the compiler

What you give up today: generated code is slower than Rust’s, there is no package registry, method-level type parameters and where clauses are missing, and the ecosystem is the standard library. What you gain: no lifetime annotations to write, and the compiler tells you what a dependency is allowed to touch.

Read next: Memory & Regions, Capabilities, Traits & Generics.

Coming from Zig

In ZigIn Fid
comptimecomptime blocks, comptime fn, reflection over fields, variants and sizes
Memory safety by disciplineBorrows and reference escapes checked at compile time
Safety checks depend on build modeBounds, integer overflow and double frees panic in every build
defer at scope exitdefer { } runs when the function exits, not the block
const / varval / var, plus const for compile-time constants
Self-hosted, own backendsThe same idea: fid emit writes Windows and Linux executables itself, with no LLVM
Cross-compilation built inNative Linux targets with fid emit --target; other targets go through C with zig cc

What you give up today: Zig’s cross-compilation reach and its maturity. Fid’s C backend uses zig cc for most cross targets.

Read next: Comptime, Backends & Targets.

Coming from Go

In GoIn Fid
Garbage collectorNone. A value is freed when its owner’s scope ends
Goroutinesspawn on OS threads, spawn scope { } to join them, and green-thread tasks in stdlib/task
Channels and selectBounded channels and select, in the language
if err != nilResult and the ? operator
deferdefer { }, also at function exit
Interfaces, implicitcap, implemented explicitly with impl Cap for Type
Data races found by toolA spawned call’s arguments must be @send; a global written from another thread needs a lock
go build, one binaryfid emit or fid build, one native executable

What you give up today: the standard library’s breadth, the tooling’s polish and Go’s compile speed on large programs. A Vec passed to a spawned call is still shared with the caller, and writes from both threads are not detected.

Read next: Concurrency, Errors & Effects.

Coming from C

In CIn Fid
Your existing librariesextern "C" declarations call them directly; the call needs an unsafe block
Header filesfid parse-header file.h -o out.fd writes the bindings
Struct layout@repr(C) and @packed
Unchecked indexing, overflowBounds and overflow checked at run time, always; @wrapping where wrap-around is intended
malloc / freeValues are freed at the end of their scope; raw allocation is available inside unsafe
Preprocessorcomptime and @cfg(...) for conditional compilation
Inline assemblyasm!, encoded by the native Windows backend

The practical route is one module at a time: keep the C, call it from Fid, and move a module when it is worth it. Each moved module gets borrow, bounds and overflow checks and can be imported with a capability grant.

Read next: FFI & C Interop, Safety Annotations.

Try the difference

The playground runs Fid in your browser with nothing to install. It uses the earlier, frozen compiler, so the newest checks (such as changing a Vec inside a loop over it) need an installed fid. Compiler Errors explains every message you will meet.

Report an issue