In in the chapter “Why Go for CLI Development?” several languages where reviewed under a list of evaluation criteria. Two criteria that can be exemplified in code are Readability and Type Model. The following Hello World code examples demonstrate those concepts.
Python
# hello.py
import sys
# ← Dynamically typed, concise logic with conditional indexing
name = sys.argv[1] if len(sys.argv) > 1 else "World"
# ← Clean and highly readable string interpolation
print(f"Hello, {name}!")
Rust
// hello.rs
use std::env;
fn main() {
// ← Explicit type declaration with Vec<String> and collect()
let args: Vec<String> = env::args().collect();
// ← Option handling with unwrap_or to provide a fallback value
let name = args.get(1).unwrap_or(&"World".to_string());
// ← Print macro with placeholder substitution
println!("Hello, {}!", name);
}
Go
// hello.go
package main
import "fmt"
func main() {
name := "World" // ← Minimal syntax with implicit typing via := keeps things clean
fmt.Printf("Hello, %s!\n", name) // ← Clear, simple syntax with formatted output
}