Golang
Error handling and defer in Go (Concurrency and synchronization) | Patterns, idioms, and best practices in Go
Error handling in Go is significantly different from the familiar Java approach with exceptions. Instead of try/catch, Go uses returning an error as a separate value, and `defer` helps safely release resources regardless of whether an error occurred or not. 1. Error handling idioms Error handling ...
Memory / Runtime / Allocator - Go vs Java
Memory management, pointers, and profiling are fundamental aspects of efficient code. Let s consider three key concepts: slice backing array, pointer, and profiling (pprof / trace), and compare Go with Java. 1. Slice backing array A slice in Go is a lightweight structure over an array: it holds a po...
Practical patterns and optimization in Go vs Java | Concurrency part 3
← Part 2 — Synchronization and Safety in Go In this part, we will discuss practical patterns for parallel task processing: worker pool, pipeline pattern, and result assembly schemes. These patterns help improve performance and avoid deadlocks. Worker Pool Worker Pool - Worker Pool 🤲⚙️ a lim...
Synchronization and security in Go vs Java | Concurrency part 2
← Part 1 — Basics of Concurrency in Go for Java Developers In the second part, we will dive into synchronization and safety of concurrent code in Go. For a Java developer, it is useful to see the analogs: synchronized, ReentrantLock, CountDownLatch, atomic operations, and threading schemes. W...
Основы параллельности в Go для Java-разработчиков | Сoncurrency часть 1
Если вы Java-разработчик, привыкший к потокам и ExecutorService, Go предлагает более лёгкий и удобный подход к параллельной обработке — goroutine и каналы. В этой статье мы разберём ключевые концепции Go concurrency и сравним их с Java-аналогами. 1. Goroutine vs Thread Goroutine — это лёгкая единица...
Go vs. Java - Comparing Memory Models - Part 2: Atomic Operations, Preemption, Defer/Finally, Context, Escape Analysis, GC, False Sharing
Atomic operations Atomic operations ensure correct execution of variable operations without race conditions, guaranteeing a happens-before between reads and writes. Go example: import "sync/atomic" var counter int32 func increment() { atomic.AddInt32(&counter, 1) // atomic increment } Java examp...
Go vs Java - comparison of memory models: happens-before, visibility, reorder, synchronization events, write/read barriers
Memory model is a layer between the program and the processor. Modern CPUs aggressively optimize execution: instructions may be reordered, data may be stored in core caches, and operations may be performed speculatively. Without strict rules, two threads could see completely different values of the ...
Useful Articles:
In Java, performance is often determined not by the "beauty of the code," but by how it interacts with memory, the JIT compiler, and CPU cache. Let s analyze why the usual for is often faster than Str...
Signs of a legacy project: how to recognize an old ship A legacy is not just old code. It is a living organism that has survived dozens of changes, team shifts, outdated technologies, and numerous tem...
← Part 2 — Synchronization and Safety in Go In this part, we will discuss practical patterns for parallel task processing: worker pool, pipeline pattern, and result assembly schemes. These patte...
New Articles:
Concurrency is not about “starting many threads”. It’s about agreements between them. Imagine a restaurant kitchen: — cooks (threads / goroutines) — orders (tasks) — and the main question: how do th...
Imagine a typical production service. 32 CPU hundreds of threads configuration / session / rate limits cache tens of thousands of operations per second And somewhere inside — a regular Map. At first...
Zero Allocation — is an approach to writing code in which no unnecessary objects are created in heap memory during runtime. The main idea: fewer objects → less GC → higher stability and performance. ...