Logo
Logo
16 results for
  • A teammate once spent three days replacing every String in our data model with a custom arena-allocated string type. The rationale: “String allocations are slow, and we’re processing a lot of data.” Sounds reasonable, right? After the rewrite, I ran the benchmarks. The improvement was within noise — less than 1%. The actual bottleneck was network I/O to an external API, which accounted for 94% of the request latency. Those three days of intricate unsafe string manipulation? Completely wasted. And the code was now harder to read, harder to maintain, and had a subtle use-after-free bug that we found six weeks later.

    Rust tutorial rust anti-patterns code-quality Created Sat, 19 Apr 2025 13:42:00 +0000
  • One of the most subtle security issues I’ve encountered in Go APIs isn’t an authentication bug or a missing authorization check — it’s a SQL error message showing up in a JSON response. Something like {"error": "pq: duplicate key value violates unique constraint \"users_email_key\""}. The frontend is now showing your users your database schema. Not great.

    This happens because somewhere between the repository and the HTTP response, someone got lazy with error translation. The raw database error bubbled all the way up and got written directly into the response. Error boundaries exist to prevent exactly this — they’re the translation points between layers, where internal implementation details get converted to appropriate external representations.

    Go tutorial golang Created Sat, 19 Apr 2025 00:00:00 +0000
  • Two-phase commit is theoretically elegant and operationally painful. I’ve seen it cause system-wide deadlocks during network partitions, coordinator failures that required manual database recovery, and deployment coupling so tight that every service had to be upgraded in lockstep. The saga pattern is the alternative — it trades atomicity for availability, compensates for failures with explicit rollback actions, and keeps each service’s transactions entirely local. It’s the pattern I reach for whenever I need “all of this must succeed together” across more than one database.

    Go tutorial golang microservices Created Fri, 18 Apr 2025 00:00:00 +0000
  • There’s a specific moment in every Rust developer’s journey where they discover Arc<Mutex<T>> and start putting everything in it. I’ve been that developer. I had a web service that needed to share a cache between request handlers, and my first instinct was Arc<Mutex<HashMap<String, CachedItem>>>. It worked. Then traffic went up, contention went up, tail latency went up, and I spent a weekend profiling lock contention that shouldn’t have existed in the first place — because most of my “shared mutable state” could have been restructured as message passing.

    Rust tutorial rust anti-patterns code-quality Created Wed, 16 Apr 2025 20:15:00 +0000
  • I worked on a project that had a Storage trait with twenty-three methods. Twenty-three. It handled reading, writing, deleting, listing, searching, watching for changes, managing permissions, computing checksums, and streaming large files. Every backend — S3, local filesystem, in-memory for tests — had to implement all twenty-three methods. The in-memory test backend had fourteen methods that just returned unimplemented!(). The local filesystem backend panicked on the permissions methods because POSIX permissions don’t map to the trait’s model. And every time someone added a new method to the trait, every backend had to be updated — even the ones where the new method made no sense.

    Rust tutorial rust anti-patterns code-quality Created Tue, 15 Apr 2025 09:55:00 +0000
  • I used to reach for []byte over string in performance-sensitive code, assuming strings were somehow more expensive because “immutability must cost something.” That intuition was wrong. Understanding what a string actually is — a read-only slice header — corrected my assumptions and simplified a lot of code I had unnecessarily complicated.

    The Problem

    Strings in Go are everywhere, and most developers use them without thinking about what they are at the memory level. This leads to a few common mistakes:

    Go tutorial golang internals Created Tue, 15 Apr 2025 00:00:00 +0000
  • Topological sort comes up whenever there is an ordering constraint — “A must happen before B,” “module X depends on module Y,” “this course is a prerequisite for that one.” The algorithm answers: given a directed acyclic graph (DAG) of dependencies, produce a linear ordering of all nodes such that every node appears after all its predecessors.

    The word “topological” makes it sound academic. In practice, it is one of the most industrially relevant algorithms: build systems, package managers, spreadsheet recalculation engines, compiler dependency resolution, task schedulers — they all use topological sort or something equivalent. Interviewers ask it because it tests whether you can model real-world dependency problems as graphs and then solve them correctly.

    fundamentals interviews Created Mon, 14 Apr 2025 00:00:00 +0000
  • I reviewed a library last year where the author had made literally everything generic. The HTTP client was generic over the transport, the serializer, the deserializer, the error type, the retry policy, the timeout strategy, and the logger. Using it required spelling out a type signature that looked like this:

    let client: HttpClient<
        TcpTransport<TlsConfig>,
        JsonSerializer<PrettyPrint>,
        JsonDeserializer<StrictMode>,
        AppError,
        ExponentialBackoff<SystemClock>,
        FixedTimeout,
        SlogLogger<JsonFormat>,
    > = HttpClient::new(/* ... */);
    

    The kicker? The library was an internal tool used by exactly one team. There was one transport, one serializer, one error type. Every type parameter had exactly one implementation. The author had written an extensible framework for a problem that didn’t need extending.

    Rust tutorial rust anti-patterns code-quality Created Sun, 13 Apr 2025 11:28:00 +0000
  • Without context.Context, you have goroutines running long after the user who triggered them gave up, HTTP connections burning server resources for requests nobody’s waiting for, and database queries executing on behalf of clients that disconnected ten seconds ago. Context is the mechanism Go gives you to propagate “I changed my mind” — and most engineers don’t use it until something in production embarrasses them into learning it properly.

    The Problem

    Let’s start with the most common mistake — blocking on a slow operation with no timeout:

    Go tutorial golang concurrency Created Sun, 13 Apr 2025 00:00:00 +0000
  • I once had to parse 2GB of log files per hour on a machine with 4GB of RAM. The naive approach — read line, split into fields, store as String — peaked at 6GB memory usage and fell over. The data was being duplicated everywhere: once in the read buffer, once in each split String, once in the output struct. Three copies of every byte.

    The zero-copy version peaked at 2.1GB — basically the file size plus a thin layer of parsed references. Same output, same correctness, one-third the memory, twice the throughput. Zero-copy parsing is one of the most powerful techniques in Rust’s performance toolkit, and the ownership system makes it uniquely natural here.

    Rust tutorial rust performance Created Sat, 12 Apr 2025 11:30:00 +0000