Posts

Showing posts with the label Go

Why Modern Programming Languages Are Becoming Unsafe Again: The Hidden Costs of Abstraction in Rust, Go, Python, and JavaScript

Image
  Modern software development went through several cycles of escaping complexity only to recreate it in a different form. In the early days, low level languages like C gave developers full control over memory, layout, and performance, but this freedom came with high risk. Memory corruption, data races, buffer overflows, and undefined behavior were common. Later, languages like Java and C# pushed developers toward safer abstractions. Then Python and JavaScript made the runtime even more forgiving. Today, Rust and Go promise a return to predictability with strict memory models, type safety, and clear concurrency rules. Yet something interesting is happening beneath the surface. Even in languages designed for safety and simplicity, new forms of unpredictability, performance traps, and abstraction-driven risks have emerged. This does not mean these languages are unsafe in the traditional sense, but the hidden costs of modern abstractions create behaviors that developers cannot always r...

Why Indirection Is the Price of Polymorphism, With Assembly You Can Read

Image
  Polymorphism lets you call methods through an interface without knowing the concrete type at compile time. The CPU and the ABI do not understand interfaces, traits, or virtuals. They only understand bytes, fixed register widths, and stack slots. That mismatch is the root cause of why runtime polymorphism uses indirection. In this extended version I will show concrete assembly flavored examples so you can see exactly where size knowledge matters, how vtables and fat pointers are used, and what gets passed in registers or on the stack. I will use x86-64 System V ABI conventions where practical. Exact assembly will vary by compiler and flags, but the patterns are stable. The goal is to make the invisible visible. A tiny ABI checklist before we start The ABI decides how arguments are passed and where return values land. On x86-64 System V: Integer or pointer arguments are passed in RDI, RSI, RDX, RCX, R8, R9, then the stack. Floating arguments use XMM0..XMM7. The caller align...

Go’s goroutines vs Rust’s async/await (futures + runtimes)

Image
Overview Before diving into internals, let’s set the stage: both Go and Rust support writing concurrent / asynchronous programs. But they take quite different approaches. The key contrast is: Go has built-in goroutines and a runtime that multiplexes them on OS threads. The language and standard library are built around this model. Rust does not have built-in green threads (in the same sense). Instead, it supports async/await , which is sugar over futures , and you need an executor / runtime (like Tokio , async-std , etc.) to drive those futures. Rust also supports OS threads directly (via std::thread ), and you often blend OS threads + async tasks. So, comparing “Go goroutines vs Rust async” really means comparing: A language with integrated green threading + scheduler (Go) A language with zero-cost abstractions and explicit futures, where you pick or build a runtime One more distinction: in Go, goroutines can block (e.g. on I/O) transparently; the runtime handles tha...

When to Use Go and When to Use Rust: A Pragmatic Guide

  Choosing between Go and Rust isn’t about picking the "better" language; it’s about selecting the right tool for the job. Both languages excel in their own ways, and understanding their strengths and trade-offs is essential for making the right decision. Here’s a practical guide to when you should use Go and when Rust is the better choice. Performance and Resource Management There’s no significant difference in raw performance between Go and Rust for many common tasks. Both languages are compiled and optimized for speed. However, Rust’s lack of a garbage collector allows for more predictable and stable performance, particularly in applications where memory consumption and latency need to remain consistent. Rust enables fine-grained control over memory and CPU usage without the potential unpredictability of garbage collection pauses. Meanwhile, Go’s garbage collector is designed for simplicity and works exceptionally well in most workloads, especially for scalable, server...

My Take on GoLang: A Pragmatic Masterpiece

  GoLang, often simply called Go, is a language that has quietly but steadily made its mark since Google open-sourced it more than a decade ago. At first glance, Go might seem unremarkable if you’re someone who evaluates languages based on flashy features or groundbreaking paradigms. But that’s the brilliance of Go - it doesn't try to dazzle you with its complexity. Instead, it wins you over with its simplicity, its pragmatism, and its sheer focus on what matters most: getting things done. What sets Go apart isn't just its syntax or its runtime; it's the ideology behind it. Everything about this language is deliberate. It’s easy to learn - not because it sacrifices power or flexibility, but because it is designed that way. There are no sharp edges, no gotchas lurking in the shadows, and no need for mental gymnastics to understand its core principles. For someone coming from another language, whether it’s Java, Python, or even C++, picking up Go feels almost intuitive. You...