COMP3007 Modern Programming Languages-Week2
COMP3007 Modern Programming Languages-Week2
Fall 2024-2025
Rust Go
Developed by Mozilla Research Developed by Google
Focus on memory safety and Focus on simplicity and
concurrency efficiency
Influenced by C++, Haskell, Influenced by C, Pascal, and
and others others
Rust Go
Ownership model Garbage collection
Borrowing rules Escape analysis
No garbage collection Simpler memory model
1 fn main () { 1 package main
2 let s1 = 2
String :: from("hello ");
3 import "fmt"
3 let s2 = s1; // s1 is 4
moved 5 func main () {
4 // println !("{}" , s1); 6 s1 := " hello "
// Error ! 7 s2 := s1 // s1 is copied
5 println !("{}", s2); // 8 fmt. Println (s1) // OK
OK 9 fmt. Println (s2) // OK
6 } 10 }
Rust:
Generally produces smaller executables
Static linking by default
Zero-cost abstractions don’t increase binary size
Go:
Typically larger executables
Includes runtime for garbage collection
Statically linked by default, including standard library
Considerations:
Rust: Size can be further reduced with optimization flags
Go: Offers easy cross-compilation but at the cost of larger binaries
Both: Size can vary significantly based on dependencies and
optimizations
Rust Go
Cargo package manager Go modules
Active community Large standard library
Growing adoption in systems Strong presence in cloud-native
programming development
Rust
Cargo: Build system and Go
package manager Go modules: Native
Clippy: Linter tool for catching dependency management
mistakes Gofmt: Built-in code formatter
Rustfmt: Automatic code Go toolchain: Fast and
formatting efficient compilation
Rust
Go
Robust cross-compilation
Simple cross-compilation
capabilities
Widely used in building
Extensive support for various
cross-platform tools
architectures
Popular in backend services and
Strong presence in
infrastructure
WebAssembly (Wasm)
1 GOOS=linux GOARCH =amd64 go
1 cargo build --target
build
x86_64 -unknown -linux -gnu
Rust
Go
Growing community, particularly
Large and active community,
in systems programming
especially in cloud-native
Backed by Mozilla, with
Widely used by major tech
contributions from major
companies
companies
Strong presence in DevOps,
Increasing adoption in game
backend services, and tooling
development and WebAssembly
Rust
Go
Emphasizes memory safety,
Simple concurrency model
preventing common
reduces concurrency bugs
vulnerabilities
Garbage collector introduces
Borrow checker ensures no data
non-deterministic pauses
races
Suitable for secure backend
Ideal for security-sensitive
services
applications
Rust Go
Systems programming Web services
WebAssembly Cloud infrastructure
Embedded systems DevOps tools
Examples: Firefox, Dropbox Examples: Docker, Kubernetes
Go
Rust
Good for higher-level IoT
Excellent for bare-metal
applications
programming
Garbage collector can be a
Zero-cost abstractions
limitation
No runtime or garbage collector
TinyGo project for
Rich ecosystem for embedded microcontrollers
(e.g., embedded-hal)
Easier concurrency with
Memory safety without runtime goroutines
costs
Larger runtime overhead
Resource Constraints:
Rust: More suitable for highly constrained devices
Go: Better for devices with more resources
Real-time Requirements:
Rust: Predictable performance, suitable for real-time systems
Go: GC pauses can be problematic for hard real-time systems
Development Complexity:
Rust: Steeper learning curve, but more control
Go: Easier to learn and use, but less low-level control
Ecosystem and Tools:
Rust: Growing embedded ecosystem (cargo-embed, probe-run)
Go: TinyGo improving embedded support