Faisalaffan Blog
|
🇮🇩
Faisalaffan Blog
Rekayasa Perangkat Lunak16 menit baca

Saya Sudah Coba Rust, Node, Java, PHP, Python — Dan Tetap Balik ke Go. Ini Datanya.

Benchmark head-to-head 7 bahasa pemrograman populer: performa, memory, concurrency, developer experience, dan hiring market. Kenapa Go menang di production yang handle jutaan request — dan kenapa saya hampir pindah ke Rust (tapi batal).

Faisal Affan
Faisal Affan
Diterbitkan
Galeri
1 / 3

Why I Choose Go as My Primary Stack

"Simplicity is the ultimate sophistication." — Leonardo da Vinci

Disclaimer

Artikel ini bukan tentang "Go is the best language ever" — melainkan tentang mengapa Go cocok sebagai primary stack untuk konteks dan kebutuhan saya, dan mengapa saya tetap terbuka dengan stack lain. Semua bahasa pemrograman adalah alat — pilih yang tepat untuk masalah yang tepat.


🎯 1. The Decision

Setiap engineer pasti pernah di titik ini: memilih primary stack. Bukan berarti menutup diri dari teknologi lain, tapi menentukan satu bahasa yang jadi "home base" — tempat kita paling produktif, paling paham ekosistemnya, dan paling percaya diri deliver production-grade software.

Setelah bertahun-tahun bekerja dengan berbagai bahasa, saya memilih Go (Golang) sebagai primary stack. Berikut alasannya, lengkap dengan data benchmark.


📊 2. Benchmark: Go vs The Rest

Compilation Speed

Salah satu hal pertama yang bikin jatuh cinta dengan Go: kompilasi yang sangat cepat.

xychart-beta
    title "Compilation Speed (Medium Project)"
    x-axis ["Go", "C#/.NET", "TypeScript", "Java", "Rust"]
    y-axis "Seconds" 0 --> 120
    bar [3, 10, 12, 20, 75]
Language Compile Time Notes
Go ~2-5 detik Incremental, sangat cepat
Rust ~30-120 detik Borrow checker + optimization heavy
Java ~10-30 detik JIT warmup terpisah
.NET (C#) ~5-15 detik Decent, tapi masih kalah
TypeScript (Node) ~5-20 detik (tsc) Tergantung config & size
PHP N/A (interpreted) No compile step
Python N/A (interpreted) No compile step
Why So Fast?

Go didesain dari awal untuk compile cepat. Rob Pike dan tim Google membangun Go karena frustrasi dengan compile time C++ yang bisa sampai 45 menit di monorepo Google. Dependency resolution Go bersifat linear — bukan exponential seperti C/C++.

Memory Efficiency

Ini critical untuk production — terutama kalau menjalankan banyak microservices di Kubernetes.

Language/Runtime Memory Usage (Idle) Relative to Go
Go ~8-12 MB 1x (baseline)
Rust ~2-5 MB 0.4x (winner)
PHP (Laravel) ~20-40 MB/worker 3x
Node.js ~30-50 MB 4x
Python (FastAPI) ~30-50 MB 4x
.NET (ASP.NET) ~50-100 MB 8x
Java (Spring Boot) ~150-300 MB 25x
The Sweet Spot

Rust memang menang di memory, tapi Go memberikan keseimbangan terbaik antara efisiensi memory dan kemudahan development. Anda mendapat ~90% efisiensi Rust dengan ~30% effort.

HTTP Request Throughput

Benchmark menggunakan skenario simple JSON response ({"message": "hello"}):

xychart-beta
    title "HTTP Throughput (requests/sec)"
    x-axis ["Rust Actix", "Go Fiber", "Go net/http", ".NET Minimal", "Java WebFlux", "Node Fastify", "PHP Swoole", "Python uvicorn"]
    y-axis "Requests/sec (thousands)" 0 --> 700
    bar [650, 550, 450, 350, 300, 150, 120, 40]
Language/Framework Requests/sec Avg Latency
Rust (Actix-web) ~650,000 ~0.15ms
Go (Fiber) ~550,000 ~0.18ms
Go (net/http) ~450,000 ~0.22ms
.NET (ASP.NET Minimal) ~350,000 ~0.28ms
Java (Spring WebFlux) ~300,000 ~0.33ms
Node.js (Fastify) ~150,000 ~0.67ms
PHP (Swoole) ~120,000 ~0.83ms
Python (uvicorn) ~40,000 ~2.5ms

Cold Start Time

Penting untuk serverless dan container-based deployments:

xychart-beta
    title "Cold Start Time (ms) - Lower is Better"
    x-axis ["Go", "Rust", "PHP", "Node.js", "Python", ".NET", "Java"]
    y-axis "Milliseconds" 0 --> 5000
    bar [8, 8, 75, 200, 350, 1000, 3500]
Serverless & Kubernetes

Di era serverless dan Kubernetes, cold start time bukan hal sepele. Go dan Rust unggul jauh di sini karena menghasilkan static binary tanpa runtime dependency. Java dengan 3.5 detik cold start bisa menjadi showstopper untuk serverless workloads.

Binary Size & Deployment

Language Binary/Artifact Size
Rust ~5-10 MB
Go ~10-15 MB
Java ~30-80 MB (JAR)
.NET ~30-60 MB
Python ~30-100 MB (venv)
PHP ~50-150 MB (vendor)
Node.js ~50-200 MB (node_modules)

Go menghasilkan single static binary — tidak butuh runtime, tidak butuh dependency manager di production:

Dockerfile
FROM scratch
COPY myapp /app
ENTRYPOINT ["/app"]

Itu saja. 15 MB Docker image. Bandingkan dengan Node.js yang butuh node_modules sebesar 200 MB.


⚡ 3. Beyond Numbers: Why Go Wins for Me

Benchmark hanya sebagian cerita. Berikut faktor-faktor yang membuat Go jadi pilihan utama:

Simplicity by Design

main.go
package main

import (
    "fmt"
    "net/http"
)

func main() {
    http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
        fmt.Fprintf(w, `{"message": "Hello, World!"}`)
    })
    http.ListenAndServe(":8080", nil)
}

10 baris. Tidak ada annotation, tidak ada DI framework, tidak ada XML config.

Concurrency: Goroutines vs Threads

graph LR
    subgraph "Go - Goroutines"
        G1["Goroutine 1<br/>~2-8 KB"] --- G2["Goroutine 2<br/>~2-8 KB"]
        G2 --- G3["Goroutine 3<br/>~2-8 KB"]
        G3 --- G4["..."]
        G4 --- G5["Goroutine 1,000,000<br/>~2-8 KB"]
    end

    subgraph "Java/.NET - OS Threads"
        T1["Thread 1<br/>~1 MB"] --- T2["Thread 2<br/>~1 MB"]
        T2 --- T3["Thread 3<br/>~1 MB"]
        T3 --- T4["..."]
        T4 --- T5["Thread ~5,000<br/>(OS limit)"]
    end

    style G1 fill:#d1fae5,stroke:#10b981,color:#000
    style G2 fill:#d1fae5,stroke:#10b981,color:#000
    style G3 fill:#d1fae5,stroke:#10b981,color:#000
    style G4 fill:#d1fae5,stroke:#10b981,color:#000
    style G5 fill:#d1fae5,stroke:#10b981,color:#000
    style T1 fill:#fee2e2,stroke:#ef4444,color:#000
    style T2 fill:#fee2e2,stroke:#ef4444,color:#000
    style T3 fill:#fee2e2,stroke:#ef4444,color:#000
    style T4 fill:#fee2e2,stroke:#ef4444,color:#000
    style T5 fill:#fee2e2,stroke:#ef4444,color:#000
concurrency.go
// Goroutines + Channels = Elegant concurrency
func processOrders(orders []Order) []Result {
    results := make(chan Result, len(orders))

    for _, order := range orders {
        go func(o Order) {
            results <- processOrder(o)
        }(order)
    }

    var processed []Result
    for range orders {
        processed = append(processed, <-results)
    }
    return processed
}
1 Million Concurrent Connections

Goroutines hanya menggunakan ~2-8 KB stack (vs ~1 MB per thread di Java/.NET). Artinya bisa menjalankan jutaan goroutines secara bersamaan dalam satu proses — dengan memory yang sama yang dibutuhkan Java untuk ~50 threads.

Built-in Tooling

PropertyTypeDescription
go fmt formatter
default: built-in
Auto-format code — no debate about style. Satu format untuk semua Go code di dunia.
go vet linter
default: built-in
Static analysis — mendeteksi bugs sebelum runtime.
go test testing
default: built-in
Testing + benchmarking + coverage — tanpa framework tambahan.
go mod package manager
default: built-in
Dependency management — reproducible builds, no lock file drama.
go build compiler
default: built-in
Cross-compilation built-in — compile untuk OS/arch manapun dari manapun.
go generate codegen
default: built-in
Code generation — automate boilerplate tanpa magic.

Cross-compile dari Mac ke Linux?

Terminal
GOOS=linux GOARCH=amd64 go build -o myapp

Selesai. Tidak perlu Docker, tidak perlu VM, tidak perlu CI khusus.

Project Structure yang Clean

  • myservice
    • cmd
      • api
        • main.go
    • internal
      • handler
        • user.go
        • order.go
      • service
        • user.go
        • order.go
      • repository
        • user.go
        • order.go
    • go.mod
    • go.sum
    • Dockerfile

Tidak ada node_modules/, tidak ada vendor/ sebesar 200 MB, tidak ada config hell. Clean, predictable, dan mudah di-navigate.


🔍 4. Where Others Shine: Honest Comparison

Memilih Go bukan berarti menutup mata dari kelebihan bahasa lain. Setiap bahasa punya sweet spot masing-masing:

🦀 Rust — When Safety & Performance are Non-Negotiable

Kelebihan:

  • Memory safety tanpa garbage collector (ownership system)
  • Zero-cost abstractions — performa setara C/C++
  • Pattern matching & algebraic types yang powerful
  • WebAssembly first-class support

Trade-off:

  • Learning curve yang steep (~6-12 bulan untuk produktif)
  • Compile time yang lama (~30-120 detik)
  • Boilerplate untuk hal-hal sederhana (lifetime annotations)

Kapan pilih Rust:

Use Case Alasan
Embedded systems Zero-cost abstractions, no runtime
OS-level programming Memory safety tanpa GC
Game engines Performa setara C++
Performance-critical components Ketika nanoseconds matter
WebAssembly First-class WASM support

Rust bukan competitor Go — mereka menyelesaikan masalah yang berbeda. Go untuk application-level, Rust untuk system-level.

🟢 Node.js/TypeScript — When Full-Stack Matters

Kelebihan:

  • Satu bahasa untuk frontend + backend
  • Ekosistem npm yang masif (~2.5 juta packages)
  • Great untuk real-time apps (WebSocket, SSE)
  • TypeScript memberikan type safety yang baik

Trade-off:

  • Single-threaded (event loop) — CPU-bound tasks problematic
  • node_modules black hole
  • Callback/Promise complexity di codebase besar

Kapan pilih Node.js:

Use Case Alasan
Full-stack web apps Satu bahasa, satu ekosistem
Real-time features WebSocket native, SSE
BFF (Backend for Frontend) Dekat dengan frontend team
Rapid prototyping npm ecosystem yang masif
🐍 Python — When Data is King

Kelebihan:

  • ML/AI ecosystem terbaik di dunia (PyTorch, TensorFlow, scikit-learn)
  • Data science & analytics (pandas, numpy, matplotlib)
  • Scripting yang mudah dan readable
  • Komunitas ilmiah yang besar

Trade-off:

  • GIL (Global Interpreter Lock) — true parallelism terbatas
  • Performa ~10-100x lebih lambat dari Go
  • Packaging yang masih fragmented (pip, conda, poetry, uv)

Kapan pilih Python:

Use Case Alasan
Machine Learning PyTorch, TensorFlow, Hugging Face
Data pipeline pandas, Spark, Airflow
Scripting & automation Readable, cepat ditulis
Prototyping Iterasi cepat
☕ Java / 🟣 .NET — When Enterprise Demands It

Kelebihan:

  • Mature ecosystem & tooling (20+ tahun)
  • Enterprise-grade frameworks (Spring, ASP.NET)
  • Strong typing & OOP patterns yang well-documented
  • Massive talent pool

Trade-off:

  • Verbose boilerplate (AbstractSingletonProxyFactoryBean, anyone?)
  • Heavy memory footprint (JVM: 150-300 MB idle)
  • Slow startup (JVM: 2-5 detik cold start)
  • Over-engineering tendency

Kapan pilih Java/.NET:

Use Case Alasan
Enterprise systems Mature, battle-tested
Legacy integration Ecosystem yang established
Large team projects Patterns yang well-known
Android native Java/Kotlin native
🐘 PHP — When Web is Everything

Kelebihan:

  • Laravel ecosystem yang excellent
  • Deployment yang simple (shared hosting friendly)
  • Komunitas yang besar dan helpful
  • PHP 8.x sudah jauh lebih modern (fibers, enums, typed properties)

Trade-off:

  • Performa yang terbatas untuk high-throughput
  • Inconsistent standard library (needle/haystack ordering)
  • Per-request model (meskipun Swoole/RoadRunner mengubah ini)

Kapan pilih PHP:

Use Case Alasan
Content-heavy websites WordPress, CMS ecosystem
Rapid web development Laravel yang produktif
Small-medium projects Cepat, murah, mudah di-deploy
E-commerce Magento, WooCommerce

🧠 5. My Stack Philosophy

Core Principle

"Use the right tool for the right job." — Semua bahasa pemrograman adalah alat. Seorang tukang kayu tidak hanya punya palu — dia punya gergaji, bor, pahat, dan amplas. Masing-masing untuk kegunaan yang berbeda.

Decision Framework

Bagaimana saya memilih stack untuk sebuah project:

graph TD
    A["🆕 New Project"] --> B{"Apa domain-nya?"}

    B -->|"Backend / API / CLI / Infra"| C["🐹 Go"]
    B -->|"Frontend / UI"| D["⚛️ TypeScript + React"]
    B -->|"Mobile"| E["📱 Flutter / Dart"]
    B -->|"ML / Data Science"| F["🐍 Python"]
    B -->|"System / Embedded"| G["🦀 Rust"]
    B -->|"Quick Script"| H["🐍 Python / 🐚 Bash"]
    B -->|"Legacy Maintenance"| I["🐘 PHP / ☕ Java"]

    C --> J{"Perlu ultra-low latency?"}
    J -->|"Yes"| G
    J -->|"No"| C

    style A fill:#dbeafe,stroke:#3b82f6,color:#000
    style C fill:#d1fae5,stroke:#10b981,color:#000
    style D fill:#e0e7ff,stroke:#6366f1,color:#000
    style E fill:#fce7f3,stroke:#ec4899,color:#000
    style F fill:#fef3c7,stroke:#f59e0b,color:#000
    style G fill:#fee2e2,stroke:#ef4444,color:#000
    style H fill:#f3e8ff,stroke:#a855f7,color:#000
    style I fill:#f1f5f9,stroke:#64748b,color:#000
    style J fill:#fef3c7,stroke:#f59e0b,color:#000

My Toolbox

🐹 Primary — Go (90% Backend Work)

API services, microservices, CLI tools, infrastructure tooling, system programming. Go menangani 90% kebutuhan backend saya dengan efisiensi luar biasa.

⚛️ Frontend — TypeScript + React/Next.js

Ekosistem terbaik untuk modern UI. Type safety, component-based architecture, dan komunitas yang masif.

📱 Mobile — Flutter/Dart

Cross-platform, single codebase. Performa native-like dengan development speed yang tinggi.

🐍 Data & ML — Python

Untuk machine learning, data pipeline, dan scripting. Tidak ada alternatif yang lebih baik di domain ini.

🦀 Performance-Critical — Rust

Ketika Go tidak cukup cepat — embedded, WASM, atau compute-intensive components.

The 80/20 Rule

pie title "My Stack Usage Distribution"
    "Go (Backend)" : 50
    "TypeScript (Frontend)" : 20
    "Dart (Mobile)" : 15
    "Python (Data/Script)" : 10
    "Others (Rust/PHP/Java)" : 5

Go menangani 80% kebutuhan saya dengan 20% complexity. Itu sweet spot yang sempurna. Ketika saya butuh sesuatu di luar kemampuan Go, saya switch ke tool yang tepat — tanpa ego, tanpa fanatisme.


📈 6. Real-World Impact

Beberapa metrics dari production systems yang saya bangun dengan Go:

Metric Sebelum (Node.js/PHP) Sesudah (Go) Improvement
Response Time (p99) ~250ms ~15ms 16x faster
Memory per Instance ~512 MB ~50 MB 10x less
Docker Image Size ~350 MB ~18 MB 19x smaller
Cold Start ~3s ~10ms 300x faster
Monthly Infra Cost ~$500 ~$80 6x cheaper
Cost Impact

Angka-angka di atas dari real production experience. Efisiensi resource Go secara langsung berdampak pada penghematan biaya infrastruktur yang signifikan. Ketika Anda menjalankan 20+ microservices, perbedaan ~460 MB memory per instance berarti bisa menjalankan 10x lebih banyak service di hardware yang sama.

graph LR
    subgraph "Before: Node.js/PHP Stack"
        A1["Service 1<br/>512 MB"] --- A2["Service 2<br/>512 MB"]
        A2 --- A3["Service 3<br/>512 MB"]
        A3 --- A4["= 1.5 GB<br/>for 3 services"]
    end

    subgraph "After: Go Stack"
        B1["Service 1<br/>50 MB"] --- B2["Service 2<br/>50 MB"]
        B3["Service 3<br/>50 MB"] --- B4["Service 4<br/>50 MB"]
        B5["Service 5<br/>50 MB"] --- B6["..."]
        B6 --- B7["Service 30<br/>50 MB"]
        B7 --- B8["= 1.5 GB<br/>for 30 services"]
    end

    style A1 fill:#fee2e2,stroke:#ef4444,color:#000
    style A2 fill:#fee2e2,stroke:#ef4444,color:#000
    style A3 fill:#fee2e2,stroke:#ef4444,color:#000
    style A4 fill:#fee2e2,stroke:#ef4444,color:#000
    style B1 fill:#d1fae5,stroke:#10b981,color:#000
    style B2 fill:#d1fae5,stroke:#10b981,color:#000
    style B3 fill:#d1fae5,stroke:#10b981,color:#000
    style B4 fill:#d1fae5,stroke:#10b981,color:#000
    style B5 fill:#d1fae5,stroke:#10b981,color:#000
    style B6 fill:#d1fae5,stroke:#10b981,color:#000
    style B7 fill:#d1fae5,stroke:#10b981,color:#000
    style B8 fill:#d1fae5,stroke:#10b981,color:#000

🏁 7. Conclusion

TL;DR

Memilih Go bukan tentang mengatakan bahasa lain jelek. Semua bahasa pemrograman adalah alat — dan alat yang baik dipilih berdasarkan kebutuhan, bukan fanatisme.

Go menjadi primary stack saya karena memberikan:

Performa Mendekati C/Rust Dengan development speed mendekati Python.

Best of both worlds.

Simplicity 25 keywords. Kode yang mudah dibaca, di-maintain, dan

di-debug oleh siapapun di tim.

Concurrency First-Class Goroutines + Channels. Jutaan concurrent

connections dengan memory minimal.

Effortless Deployment Single static binary. COPY dan selesai. 15 MB

Docker image.

Cost Efficiency Efisiensi resource yang berdampak langsung ke

penghematan biaya infrastruktur — 6x lebih murah di production.

Tapi saya tetap menulis TypeScript untuk frontend, Dart untuk mobile, Python untuk data work, dan tidak menutup kemungkinan menggunakan Rust untuk use case yang membutuhkan performa maksimal.

The best language is the one that solves your problem effectively. Go kebetulan menjadi bahasa itu untuk sebagian besar pekerjaan saya. Dan saya tidak akan ragu switch ke bahasa lain ketika konteksnya menuntut demikian.

Karena pada akhirnya, kita bukan "Go developer" atau "Java developer" — kita adalah engineer yang menggunakan tools terbaik untuk menyelesaikan masalah.

Topik:#Go#Rust

Artikel terkait

Rekayasa Perangkat Lunak

Search & Catalog 15k SKU Q-Commerce: Relevan + In-Stock Real-time

System design search dan catalog untuk quick commerce dengan 15.000+ SKU. Elasticsearch full-text search dengan multi-match query dan typo tolerance (fuzziness), filter ketersediaan per-hub via Redis pipeline query-time filtering, ranking berbasis relevansi, ketersediaan, margin, dan popularitas, index update via Kafka streaming, dan autocomplete handler. Implementasi Golang lengkap dengan worker concurrency pattern untuk index sync.
Faisal Affan
Faisal Affan
Diterbitkan

Real-time Order Tracking Q-Commerce: Driver Bergerak di Peta Live

System design real-time order tracking untuk quick commerce. Driver GPS ingestion via WebSocket dengan throttling dan validasi, Kalman filter untuk position smoothing, Redis pub/sub fan-out by order ID untuk scale ribuan driver concurrent, dan Server-Sent Events (SSE) push ke user client. Implementasi Golang dengan pattern WebSocket goroutine pool, pub/sub broker, dan concurrent connection management.
Faisal Affan
Faisal Affan
Diterbitkan
Rekayasa Perangkat Lunak
Real-time Inventory Dark Store: Cegah Oversell di Q-Commerce

Real-time Inventory Dark Store: Cegah Oversell di Q-Commerce

Desain inventory per-hub untuk Astro (instant grocery). Reservation pattern dengan Redis DECRBY atomic + TTL, async sync ke Postgres, stock partitioning untuk hot SKU, reaper job untuk reservation leak, dan cycle counting untuk stok fisik vs sistem. Implementasi Golang lengkap.
Faisal Affan
Faisal Affan
Diterbitkan

Promo & Voucher Engine Q-Commerce: Rule Engine Anti-Abuse

System design promo engine untuk quick commerce. Rule engine dengan kondisi komposable (min transaksi, first-N-order, area, kategori) ke efek (discount, free ongkir), atomic counter untuk limit penggunaan Redis Lua, anti-fraud device fingerprinting, stackable vs eksklusif promo resolution, dan budget cap. Implementasi Golang lengkap dengan composable condition interface, AND/OR composite tree, concurrent-safe redeem, serta Kafka event streaming untuk audit trail.
Faisal Affan
Faisal Affan
Diterbitkan