COMP3007 - Modern Programming Languages
Week 2: Comparative Study of Rust and Go
Dr. Öğr. Üyesi Yusuf Kürşat Tuncel
Department of Computer Engineering
Fall 2024-2025
Dr. Öğr. Üyesi Yusuf Kürşat Tuncel (Department
COMP3007
of Computer
- Modern
Engineering)
Programming Languages Fall 2024-2025 1 / 22
Outline
1 Introduction
2 Language Origins and Design Philosophy
3 Syntax and Basic Concepts
4 Memory Management
5 Concurrency Models
6 Performance Characteristics
7 Ecosystem and Community
8 Error Handling
9 Tooling and Development Experience
10 Cross-Platform and Cross-Compilation
11 Community and Industry Support
12 Security Considerations
13 Use Cases and Industry Adoption
14 Embedded Systems and IoT Programming
15 Learning Curve and Developer Experience
16 Future Directions
17 Conclusion
Dr. Öğr. Üyesi Yusuf Kürşat Tuncel (Department
COMP3007
of Computer
- Modern
Engineering)
Programming Languages Fall 2024-2025 2 / 22
Introduction
Brief recap of Week 1
Importance of comparing programming languages
Goals of this comparative study
Dr. Öğr. Üyesi Yusuf Kürşat Tuncel (Department
COMP3007
of Computer
- Modern
Engineering)
Programming Languages Fall 2024-2025 3 / 22
Origins and Philosophy
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
Dr. Öğr. Üyesi Yusuf Kürşat Tuncel (Department
COMP3007
of Computer
- Modern
Engineering)
Programming Languages Fall 2024-2025 4 / 22
Syntax Comparison
Go
Rust Strong, static typing
Strong, static typing Implicit interfaces
Pattern matching Built-in concurrency primitives
No null or undefined
1 package main
1 fn main () { 2 import "fmt"
2 let x: i32 = 5; 3 func main () {
3 match x { 4 x := 5
4 1 => 5 switch x {
println !("One"), 6 case 1:
5 5 => 7 fmt. Println ("One")
println !("Five"), 8 case 5:
6 _ => 9 fmt. Println ("Five")
println !("Other "),
10 default :
7 } 11 fmt. Println (" Other ")
8 } 12 }
13 }
Dr. Öğr. Üyesi Yusuf Kürşat Tuncel (Department
COMP3007
of Computer
- Modern
Engineering)
Programming Languages Fall 2024-2025 5 / 22
Memory Management
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 }
Dr. Öğr. Üyesi Yusuf Kürşat Tuncel (Department
COMP3007
of Computer
- Modern
Engineering)
Programming Languages Fall 2024-2025 6 / 22
Concurrency Models
Rust
Go
Threads with message
Goroutines
passing
Channels
Async/await (added later)
”Share by communicating”
Zero-cost abstractions
1 package main
1 use std :: thread ;
2
2 use std :: sync :: mpsc;
3 import "fmt"
3 fn main () {
4
4 let (tx , rx) =
5 func main () {
mpsc :: channel ();
6 ch := make(chan
5 thread :: spawn(move {
string )
6 tx.send(" Hello ")
7 go func () {
7 . unwrap ();
8 ch <- " Hello "
8 });
9 }()
9 println !("{}",
10 fmt. Println (<-ch)
rx.recv (). unwrap ());
11 }
10 }
Dr. Öğr. Üyesi Yusuf Kürşat Tuncel (Department
COMP3007
of Computer
- Modern
Engineering)
Programming Languages Fall 2024-2025 7 / 22
Performance Characteristics
Compilation speed: Go > Rust
Runtime performance: Rust ≈ Go (context-dependent)
Memory usage: Rust < Go (typically)
Factors affecting performance in each language
Dr. Öğr. Üyesi Yusuf Kürşat Tuncel (Department
COMP3007
of Computer
- Modern
Engineering)
Programming Languages Fall 2024-2025 8 / 22
Executable Size Comparison
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
Dr. Öğr. Üyesi Yusuf Kürşat Tuncel (Department
COMP3007
of Computer
- Modern
Engineering)
Programming Languages Fall 2024-2025 9 / 22
Ecosystem and Community
Rust Go
Cargo package manager Go modules
Active community Large standard library
Growing adoption in systems Strong presence in cloud-native
programming development
Dr. Öğr. Üyesi Yusuf Kürşat Tuncel (Department
COMP3007
of Computer
- Modern
Engineering)
Programming Languages Fall 2024-2025 10 / 22
Error Handling
Rust Go
Emphasizes compile-time error Uses error type for error
checking handling
Uses Result and Option enums Returns errors as the last value
Explicit error handling, reducing from functions
runtime exceptions Simpler, but requires discipline
to check errors
1 fn divide (a: f64 , b: f64)
-> Result <f64 , String > { 1 func divide (a, b float64 )
2 if b == 0.0 { (float64 , error) {
3 Err(" Cannot divide 2 if b == 0 {
by 3 return 0,
zero". to_string ()) fmt. Errorf (" cannot
4 } else { divide by zero")
5 Ok(a / b) 4 }
6 } 5 return a / b, nil
7 } 6 }
Dr. Öğr. Üyesi Yusuf Kürşat Tuncel (Department
COMP3007
of Computer
- Modern
Engineering)
Programming Languages Fall 2024-2025 11 / 22
Tooling and Development Experience
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
1 cargo new my_project 1 go mod init my_project
2 cd my_project 2 go build
3 cargo build 3 go test
4 cargo test 4 go run main.go
5 cargo run
Dr. Öğr. Üyesi Yusuf Kürşat Tuncel (Department
COMP3007
of Computer
- Modern
Engineering)
Programming Languages Fall 2024-2025 12 / 22
Cross-Platform and Cross-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
Dr. Öğr. Üyesi Yusuf Kürşat Tuncel (Department
COMP3007
of Computer
- Modern
Engineering)
Programming Languages Fall 2024-2025 13 / 22
Community and Industry Support
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
Dr. Öğr. Üyesi Yusuf Kürşat Tuncel (Department
COMP3007
of Computer
- Modern
Engineering)
Programming Languages Fall 2024-2025 14 / 22
Security Considerations
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
Dr. Öğr. Üyesi Yusuf Kürşat Tuncel (Department
COMP3007
of Computer
- Modern
Engineering)
Programming Languages Fall 2024-2025 15 / 22
Use Cases and Industry Adoption
Rust Go
Systems programming Web services
WebAssembly Cloud infrastructure
Embedded systems DevOps tools
Examples: Firefox, Dropbox Examples: Docker, Kubernetes
Dr. Öğr. Üyesi Yusuf Kürşat Tuncel (Department
COMP3007
of Computer
- Modern
Engineering)
Programming Languages Fall 2024-2025 16 / 22
Embedded Systems and IoT: Rust vs Go
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
Dr. Öğr. Üyesi Yusuf Kürşat Tuncel (Department
COMP3007
of Computer
- Modern
Engineering)
Programming Languages Fall 2024-2025 17 / 22
Embedded Systems and IoT: Key Considerations
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
Dr. Öğr. Üyesi Yusuf Kürşat Tuncel (Department
COMP3007
of Computer
- Modern
Engineering)
Programming Languages Fall 2024-2025 18 / 22
Learning Curve and Developer Experience
Rust
Steeper learning curve
Powerful type system Go
Emphasis on correctness Easier to learn
Fast compilation
1 struct Point <T> {
2 x: T, Built-in formatting (gofmt)
3 y: T,
1 type Point struct {
4 }
2 X, Y int
5
3 }
6 impl <T: std :: fmt :: Display >
4
Point <T> {
5 func (p Point) Print () {
7 fn print (& self) {
6 fmt. Printf ("(%d,
8 println !("({},
%d)\n", p.X, p.Y)
{})", self.x,
7 }
self.y);
9 }
0 }
Dr. Öğr. Üyesi Yusuf Kürşat Tuncel (Department
COMP3007
of Computer
- Modern
Engineering)
Programming Languages Fall 2024-2025 19 / 22
Future Directions
Rust: Continued focus on safety and performance
Go: Potential improvements in generics and error handling
Both: Growing adoption in various domains
Potential influence on other programming languages
Dr. Öğr. Üyesi Yusuf Kürşat Tuncel (Department
COMP3007
of Computer
- Modern
Engineering)
Programming Languages Fall 2024-2025 20 / 22
Conclusion
Recap of key differences and similarities
Importance of choosing the right tool for the job
Encouragement to explore both languages further
Dr. Öğr. Üyesi Yusuf Kürşat Tuncel (Department
COMP3007
of Computer
- Modern
Engineering)
Programming Languages Fall 2024-2025 21 / 22
Thank You! Any Questions?
Dr. Öğr. Üyesi Yusuf Kürşat Tuncel (Department
COMP3007
of Computer
- Modern
Engineering)
Programming Languages Fall 2024-2025 22 / 22