I appreciate Rust for its robust features, especially how the compiler catches errors at compile time.
However, this same feature can pose challenges for beginners. Rust is definitely not the most suitable programming language for those just starting their coding journey. As a beginner I want to have fast results, not a compiler telling me what I am doing wrong. Its syntax can be particularly complex, especially when it involves lifetime annotations. So, there must be a good alternative to Rust.
Recently, I asked a question about this on Mastodon:
Can I have a #programming language/compiler similar to #Rust, but with less syntactic complexity? Preferably a syntax more like #Python or #PHP.
In my exploration of other programming languages, I focused on a few key criteria for comparison:
- Simple syntax.
- The language must be compilable to binary and not primarily a scripting language.
- It should produce small binaries.
- An active and functional ecosystem, including a package manager, is essential.
Zig
Website: https://ziglang.org/
Influenced by C, C++, LLVM IR, Go, Rust. [1] Syntax looks nice and intuitive. The installation on macOS using Homebrew was as simple as running brew install zig
and then compiling using zig build-exe test1.zig
.
Hello world example:
const std = @import("std");
pub fn main() !void {
std.debug.print("Hello world\n", .{});
}
The binary file is ~873 KB for Zig v0.13.0 under mac OS Ventura 13.6.4. Stripped binary is ~716 KB. On a modern PC this is OK-ish.
Update 2025-03-09: I also ran the same Hello World example using Zig v0.14.0 with different build modes,
zig build-exe -O Debug -femit-bin=./test1_Debug test1.zig
:
original Debug: ~1.1 MB
original ReleaseFast: ~18 KB
original ReleaseSafe: ~267 KB
original ReleaseSmall: 17230 byte
stripped Debug: ~911 KB
stripped ReleaseFast: ~17 KB
stripped ReleaseSafe: ~229 KB
stripped ReleaseSmall: 16608 byte
Thanks @Levin for the hint: https://hachyderm.io/@levin/114132072733027611
Crystal
Website: https://crystal-lang.org/
Syntax is also influenced by Go. [2] The installation on macOS using Homebrew was as simple as running brew install crystal
and then compiling using crystal build test1.cr
.
Hello world example as simple as Ruby:
puts "Hello world"
The binary is ~1.7 MB for Crystal 1.15.1 under mac OS Ventura 13.6.4. This is huge. ~873 KB stripped, still huge.
Go
Website: https://go.dev/
Syntax is also influenced by many. [3] The installation on macOS using Homebrew was as simple as running brew install golang
and then compiling using go build test1.go
.
Hello world example [4]:
package main
import "fmt"
func main() {
fmt.Println("hello world")
}
The binary is ~2.3 MB for Go under mac OS Ventura 13.6.4. ~1.5 MB stripped. This is huge.
Conclusion
In my exploration of various programming languages, I’ve discovered that Zig has become my current favorite alternative to Rust. Despite Zig currently lacking an ecosystem and package manager, it captivates me with its features.