Sign up

Max Chernyak

Not verified No WebSub updates No webmention support Not yet validated

Max Chernyak's software engineering blog

Public lists
I ♥ RSS
Fetched

Max Chernyak
• Max Chernyak

Don’t Build a General Purpose API (4 Years Later)

In 2021 I wrote an article encouraging people not to build general purpose APIs for their own front-ends. (You should probably read it before reading this one.) It got featured on Hacker News twice, albeit with a worse reception (and more heated discussion) the second time a...

Max Chernyak
• Max Chernyak

Failover to Human Intelligence

There’s no denying that AI is getting very capable, but one thing keeps bothering me: what happens if something goes wrong? Right now, self-driving cars still require human monitoring and intervention (outside of specially-designated areas). Isn’t this also true of a suffici...

Max Chernyak
• Max Chernyak

Getting Answers from a Big PDF with RubyLLM

Some API vendors give you an API doc in a giant custom-edited PDF file. In my case it’s >1200 pages, with a “helpful” table of contents that itself spans about 20 pages. Well, I dislike reading giant PDF docs, love writing Ruby, and there’s an awesome RubyLLM gem, and Gem...

Max Chernyak
• Max Chernyak

Long Term Refactors

Big (or “Long Term”) refactors are hard to pull off in a busy company. To succeed, we must: Convince business that it’s worth the delay. Decide what features will have to wait. Produce regular status updates and ETAs. Justify the refactor as we go. Is it the right approach?...

Max Chernyak
• Max Chernyak

4 Reasons to Leave a Code Comment

I originally wrote this list as a part of Writing Maintainable Code is a Communication Skill, then made a tweet. Since then, I had to link this list multiple times. This post makes it easier to link.

Reasons

  1. An odd business requirement (share the origin story)
  2. It took research (summarize with links)
  3. Multiple options were considered (justify decision)
  4. Question in a code review (answer in a comment)

Important caveat for number 4: if your code can be restructured in a way that answers the question without a comment, do that instead.

Max Chernyak
• Max Chernyak

Adventures in Ruby-esque type enforcement

In Ruby you can kinda pretend that you have type enforcement at runtime, because Ruby is very flexible. This could be a useful-enough thing to do to organize and formalize the “guarding” of your data. As a disclaimer, I’m not actually a huge fan of this practice, because I t...

Max Chernyak
• Max Chernyak

Rails — narrative vs model centric approach

I’ve explored DHH’s way of writing Rails applications. His introduction of CurrentAttributes and suppressors of callbacks a few years ago made me want to revisit his Youtube Screencasts on Basecamp 3 and try to really appreciate this approach with an open mind. I soon unders...

Max Chernyak
• Max Chernyak

Good Engineering is not Premature Optimization

The term “premature optimization” is often misused. It’s supposed to be about trading simplicity for unnecessary performance gains. Instead, it’s used as a blanket dismissal of anything unfamiliar. That’s both inaccurate, and hostile to good engineering. Throughout my career...

Max Chernyak
• Max Chernyak

Ruby Enumerator.new(size)

Every ruby enumerator supports count. It’s a method that will iterate over every item and return their total count. irb> enum = Enumerator.new { |yielder| (1..100).each do |i| puts "counting item: #{i}" yielder << i end } irb> enum.count counting ite...

Max Chernyak
• Max Chernyak

Writing Maintainable Code is a Communication Skill

Writing maintainable code is easy. Just keep methods and argument lists short, names and comments long, and follow a styleguide. Boom! Done. Unfortunately, as one famous journalist once wrote: “For every complex problem there is an answer that is clear, simple, and wrong.” ...

Max Chernyak
• Max Chernyak

Mindful Code Reviews

Code Reviews are First-Class Citizens Code reviews are an integral part of our daily work as engineers. They help us reduce bugs, share knowledge, collaborate asynchronously, build rapport, feel recognized, and most importantly, keep software maintainable. Diligent code revi...

Max Chernyak
• Max Chernyak

Don’t Build A General Purpose API To Power Your Own Front End

Update 2025-12-11: There is now a follow up article (4 years later). TL;DR YAGNI, unless you’re working in a big company with federated front-ends or GraphQL. It’s popular in web dev nowadays to build a backend that serves JSON, and a frontend that renders the app. This is f...

Max Chernyak
• Max Chernyak

3 Reasons Not To Implicitly Memoize

The other day I was listening to this Bikeshed podcast episode, where the hosts were discussing when is it a good idea to memoize values using ||= ruby idiom. Since this is a common question even among seasoned developers, I decided to write up my take on it. The short answe...

Max Chernyak
• Max Chernyak

Don’t use docker to run your app in development

Using docker in development can be very convenient, but running your actual app (you know, the one you’re coding) in docker introduces various headaches. Mounted volumes are slow and error-prone You need hacks and shortcuts to run any console/debug commands in containers Li...

Max Chernyak
• Max Chernyak

Elasticsearch gems and modules, clearly explained

Non Rails-specific Gem elasticsearch-transport Provides a bare-bones HTTP client that doesn’t have any Elasticsearch-specific api methods, but knows how to discover and connect to multiple servers, rotate connections, and log things. readme: elastic/elasticsearch-ruby/elast...

Max Chernyak
• Max Chernyak

6 practices for super smooth Ansible experience

I started porting my setup from Chef to Ansible a few weeks ago. Having had plenty of experience with Chef gave me a pretty good idea of what I wanted to achieve. One of the main advantages I see in Ansible is the ability to drive your server setup via ssh from your own mach...

Max Chernyak
• Max Chernyak

Linux permissions cheatsheet

chmod [a]bcd bit scope description a sticky:1, setgid:2, setuid:4 (optional, default: 0) b owner x:1/w:2/r:4 - xw:3/xr:5/wr:6/xwr:7 c group x:1/w:2/r:4 - xw:3/xr:5/wr:6/xwr:7 d everyone x:1/w:2/r:4 - xw:3/xr:5/wr:6/xwr:7 Note: only file/dir owner can chmod ...

Max Chernyak
• Max Chernyak

CMS Trap

Many years ago there was a Rails app. It started with things. These things were actually blueprints for other things. The other things needed many associated parts, and parts of parts. How many? The blueprints knew. The blueprints absolutely had to have an admin interface, b...

Max Chernyak
• Max Chernyak

Tips on Rails 3 load paths

If you add a dir directly under app/ Do nothing. All files in this dir are eager loaded in production and lazy loaded in development by default. If you add a dir under app/something/ (e.g. app/models/concerns/, app/models/products/) Ask: do I want to namespace modules a...

Max Chernyak
• Max Chernyak

Multiple Table Inheritance With ActiveRecord

Imagine writing an online shop with different types of products. Normally all products would have common attributes such as title and price. Some attributes will likely differ. Tee may have size such as S, M, or L, while a Pen could have an ink_color. It’s easy to see that T...