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 Rust | In Fid |
|---|---|
let / let mut | val / 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 assignment | Copy on assignment. var b = a on a Vec, HashMap or str gives an independent value, shared until the first write |
trait / impl T for X | cap / impl Cap for X, with default methods, associated types and dyn |
| Macros | None. comptime blocks and functions run ordinary Fid code at compile time, with type reflection |
Result, Option, ? | The same, in the core library |
unsafe | unsafe { } 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.io | ark with path and git dependencies. The registry is planned |
| Nothing built in | Capability 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 Zig | In Fid |
|---|---|
comptime | comptime blocks, comptime fn, reflection over fields, variants and sizes |
| Memory safety by discipline | Borrows and reference escapes checked at compile time |
| Safety checks depend on build mode | Bounds, integer overflow and double frees panic in every build |
defer at scope exit | defer { } runs when the function exits, not the block |
const / var | val / var, plus const for compile-time constants |
| Self-hosted, own backends | The same idea: fid emit writes Windows and Linux executables itself, with no LLVM |
| Cross-compilation built in | Native 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 Go | In Fid |
|---|---|
| Garbage collector | None. A value is freed when its owner’s scope ends |
| Goroutines | spawn on OS threads, spawn scope { } to join them, and green-thread tasks in stdlib/task |
Channels and select | Bounded channels and select, in the language |
if err != nil | Result and the ? operator |
defer | defer { }, also at function exit |
| Interfaces, implicit | cap, implemented explicitly with impl Cap for Type |
| Data races found by tool | A spawned call’s arguments must be @send; a global written from another thread needs a lock |
go build, one binary | fid 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 C | In Fid |
|---|---|
| Your existing libraries | extern "C" declarations call them directly; the call needs an unsafe block |
| Header files | fid parse-header file.h -o out.fd writes the bindings |
| Struct layout | @repr(C) and @packed |
| Unchecked indexing, overflow | Bounds and overflow checked at run time, always; @wrapping where wrap-around is intended |
malloc / free | Values are freed at the end of their scope; raw allocation is available inside unsafe |
| Preprocessor | comptime and @cfg(...) for conditional compilation |
| Inline assembly | asm!, 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.