murb ♥︎ ruby

It may not be the fastest programming language, nor is it the most popular language when it comes to the numbers game, but how can you not fall in love with:

 10.times { print "Hello!" }

(instead of something like for(var i=0; i<10; i++){ console.log("Hello!"); })

Do things with sets like:

["a", "b", "c"] & ["b", "c", "d"] # gives you ["b", "c"]
[1,2,3] + [4,5] # gives you [1,2,3,4,5]
["a", "b", "c"] - ["b", "c", "d"] # gives you ["a"]

Or (with a little (opinions differ on this one ;)) help of Rails):

10.days.ago

That offers you exactly what you would think it would return: the date of 10 days ago.

And no ;’s, only brackets when absolutely needed, everything is an object…

Yes, it’s actually a language a human might understand, and still: it is pretty powerful, powering some of the most popular sites on the web, like AirBnB, Shopify, Basecamp (they’re the creators of Ruby on Rails), Github, Kickstarter, Twitch, Strava and many more (most of the full stack projects I did & do are using ruby).

My favourite development related podcasts (2026 edition)

An article, posted 11 days ago filed in podcast, ruby, development, software, maintenance, KentBeck & hanami.

Three podcasts I’m currently enjoying on development (I listen to more, but these are asap play when they arrive):

Dead Code

Dead code always ends with “and now delete some”, followed by a death metally grunt “DEAD CODE”. But while the show is death metal themed, don’t expect just bearded men with long hair mumbling. Jared Norman discusses a wide range of topics in depth. Often his shows are triggered by someone who wrote a blogpost about some niche programming related topic. From rescript (a typed language that compiles to Javascript), new style version management tools other than git, a discussion around why (the lucky stiff) who influenced the ruby culture to something much more quirkier than others, to discussions about the language we program in (english vs. non-english, ‘css’ vs assembly…).

Maintainable - the art of improving existing software

In this podcast Robby Russel talks to experts in the field ab…

Continue reading...

Book notes: Coderspeak by Guilherme Orlandini Heurich

An article, posted about one month ago filed in development, background, design, ruby, book, book notes, review & summary.

Highlights / summaries that I made while reading Coderspeak by Guilherme Orlandini Heurich

On Community

When they contribute to open-source projects, they often say they want to ‘give back to the community’, (…which…) comes from the connection between the programmers who wrote it and the program they created.

Heurich cites Marcel MaussThe Gift:

What imposes obligation in the present received and exchanged is the fact that the thing received is not inactive. (…) It is something attached to me, the giver, and it will be permanently attached to me, even if you pass my gift along.

That is why, Heurich concludes, it is not the companies who contribute graciously, instead, but the individual developers who reciprocate. And not for the prestige (as Eric S. Raymond tends to think of it), but for a feeling of belonging to a…

Continue reading...

When to use Serializers?

An article, posted 3 months ago filed in ruby, rails, ruby on rails, service, architecture, when to use, json & JSON-API.

Define Serializer

Serialisation (I’ll use s in writing about the concept, and z when discussing the thing itself) in programming is about converting the state of an object into something that can be stored or transferred. When you really want to serialise the state of an application to disk, you probably want full, unmodified serialisation, so the question about serialisation typically comes up when you want to share data with external parties. To these parties you don’t want to share the raw data, but pre-process it a bit, perhaps convert the internal state to objects that are more generic and don’t expose the full internals. In such case you might want to consider introducing the concept of Serializers.

Alternatives to using serializers

Before introducing new tooling, always consider the following default options Rails offers:

  • Serializers live on the view-layer. The default approach rails suggests is to have e.g. {index, show}.json.jbuilder files in your v…

Continue reading...

A better Kamal deployment strategy?

An article, posted 7 months ago filed in deployment, docker, deploy, capistrano, server, debian, nginx, rails, ruby & proxy.

Kamal was introduced in 2023 (back then as MRSK) as an alternative way to deploy and manage containers on a server. It is marketed as Capistrano for containers, and as a big fan of the simplicity of Capistrano I was intrigued. I despise the political ideas of one of Kamal’s creators, but I think on the tech/implementation side he is promoting solutions that I honestly think are good (including HTML over the wire). Kamal is ‘simply’ some tooling around running images using Docker on a server, with zero-downtime deployments.

Some preparation

This is how I prepared for my testing:

  1. I had to set up an SMTP server as my sendmail solution (that actually worked quite well for my smallish projects, no need for sendgrid or the like); see my post on getting Chasquid up and running on Debian.
  2. I installed docker from the Debian repo’s (and not Docker’s), so it is automatical…

Continue reading...

Programming using the Crystal language

An article, posted 11 months ago filed in crystal, programming, ruby, crystal-lang, scripting, typing, compilation, generate, speed, performance, developer happiness & activesupport.

Recently I posted ‘Doing less’. Tl;dr: I wondered why we (as tech-society) seem to be thrilled about making inefficient round trips using AI for development, or chase each other to use typed languages, while we could be using more expressive programming languages instead. Instead of guessing human input, we could write untyped short scripts that detail every edge case carefully, but without extreme uncertainty of human language input nor the extreme preciseness of typed languages. Scripting, however, is scoffed at by Real Programmers, but then why oh why do we AI?

Someone suggested I should share more about another programming language (knowing that I’m a rubyist) called Crystal, a language that shares performance characteristics of other compiled languages like C and Rust (not always in the top regions, but close). And although I heard of it a long time ago, I kinda forgot ab…

Continue reading...

Doing less

An article, posted 12 months ago filed in ruby, programming, llm, efficiency, go, ai, compilation & rust.

A lot of automation is about doing less manual labour. People who automate enjoy doing less. This desire lead to new programming languages, advanced IDE-tooling, but recently we’ve gotten a new type of assistance: AI. Microsoft using Github Copilot, Amazon with CodeWhisperer, and more will follow offering yet another Code predictor using ‘open source’ models.

But is it the right approach?

Solving problems that I don’t have

I mainly write in a language that was developed for developer happiness: ruby. It wasn’t designed for optimal performance, but allows code to be readable and easy to write (when you have a certain proficiency in Ruby that is). After having turned CodePilot on and off for a year, I’m really not impressed. It has saved me typing strings that I might have otherwise copied from an earlier test, but with the disadvantage that the resulting text…

Continue reading...

Homebrew and `puma-dev` and microservices

An article, posted about one year ago filed in homebrew, how i do it, local, localhost, Microservices, openssl, programming, puma-dev, ruby, server, ssl, tls, mac & macos.

When you’re writing server to server communication locally, and these servers are running behind some proxy like puma-dev that enables SSL connections, you may face issues with OpenSSL (or variant) not trusting the connections. That is good, you want OpenSSL not to trust just any random certificate. But how to make it pass?

Your web browser probably allows you to visit a page on a server and even approve the certificate. You should then export the chain as .pem (Firefox makes this pretty easy: click on the lock, view security, view certificate, go to the “CA”-tab for that certificate and export the chain.

This PEM chain is just a plain text file, containing the public certificates of your local ‘CA’ (created by Puma-Dev)

Copy the text using an editor of choice.

And now open up: /opt/homebrew/etc/ca-certificates/cert.pem and add it.

Also make sure that everything uses this cert.pem by symlinking it to this file, so for example with ruby run

 $ ruby -ropenssl -...

Continue reading...

I'm nitpicking a bit on naming in code...

An article, posted about one year ago filed in mental models, ruby, development, software, naming, hard, computer science, Martin Fowler & two hard things.

In a code review that I did today, I left a final note to the author of some new piece of code:

Sorry for nitpicking on naming. The approaches you take are good, but naming is hard (but important!):

There are only two hard things in Computer Science: cache invalidation and naming things.

(see here a list of variations on these two hard problem ‘jokes’ in Computer Science)

I enjoy the ruby programming language because you can get a long way by just assuming things. A collection implements each, every object has nil?, in rails, I can get the relationship of a record and use scopes to filter the relationships as defined in the class of that related record. If it ands with a questionmark, it returns a boolean(y). Anyway.

So while they might say: “never assume things”, and sure, a lot of things are chaos, but ideally not our code base :) I prefer to work from assuming things…

Continue reading...

(Database) Transactions should be used modestly

An article, posted more than one year ago filed in database, sql, programming, ruby, performance & simplicity.

It is good practice to leave your database in a consistent state. There are different ways to do this. Foreign key constraints, indexes, typing of columns, are all strategies to keep your database in a consistent state. Transactions are another way providing you a tool to keep the database consistent: if one of the inserts or updates fail, your database will rollback to the state before the first in the series of inserts and updates within that transaction.

Some languages make it really simple to create a transaction. In Ruby on Rails it is simply opening a block:

User.transaction do
  ## ... all db operations are now in a transaction
end

But be cautious; transactions don’t come for free: they lock the table or row, which is bad for performance. It can, by design, stop other processes from updating the same rows. And all this gets worse when transactions take longer, when for example they contain request to remote resources.

Hence, my approach to transact…

Continue reading...

Generating and parsing data URI's in Ruby

An article, posted more than one year ago filed in uri, data, url, data-url, ruby, link, browser, html, json & api.

I’m fond of data-URI’s (MDN Link). 12 years ago I reappropriated a tool that stored a webpage with its related resources in a Microsoft specific format and rewrote it into something that would store it in normal HTML where the related resources were encoded in data URI’s. Recently the topic came up again at a project I was working in, where microservices are still a thing. And while discussing it with colleagues it seemed as if knowledge about this quite useful URI-scheme wasn’t on top of everyone else’s mind. Instead, the original idea was, we could upload the resource to S3, pass the link, download the resource from S3 at the receiving end, and then have some policy that takes care of deleting it… nah…

data-URI: The basics

This is the most simple data-URI:

data:,Hello%2C%20World%21

You [can open it in your browser](dat…

Continue reading...

When to use decorators

An article, posted more than one year ago filed in ruby, rails, ruby on rails, service, architecture, when to use & models.

Are you sure?

Decorators decorate your class with new set of functionality.

What are your decorators doing? Adding a few rendering specific methods to a class to help with rendering? Perhaps you should consider Presenters. But better: how will it scale, can it be grouped, will it really add the simplification. Be wary of too quick branching off functionality to decorators. Most cases I’ve seen them were overly architectured, and they didn’t bring much value.

One might consider using Concerns or mixins as an alternative. The disadvantage here is that your main object gets more public methods, but I consider it as a feature after having experienced too much potentially reusable functionality grouped arbitrarily away in other presenter / decorator classes.

Continue reading...

I love you ruby, `unless`...

An article, posted more than one year ago filed in sorting, ruby & programming.

I’m quite familiar with writing ruby code. I’ve even expressed my love for the language long time ago. But some constructs still bug me. One of them is unless…

I’ve seen variants of this code:

temperature = 36.7
unless temperature > 37.2 || temperature < 35.5
  puts "Healthy temperature. Temperature is within the normal range."
end
## Output: "Healthy temperature. Temperature is within the normal range."

Just don’t.

I like unless sometimes, but for simple expressions:

print "normal" unless abnormal

But more complex conditionals should be if statements:

if temperature > 35.5 && temperature < 37.2
  puts "Healthy temperature. Temperature is within the normal range."
end

or perhaps even nicer:

if (35.5...37.2).include?(temperature)
  puts "Healthy temperature. Temperature is within the normal range."
end

Continue reading...

Sorting text

An article, posted almost 2 years ago filed in sorting, ruby, programming, database, order, databases & sql.

There are a few hard problems in computing. Correctly handling time, naming, preventing off by one errors… sorting text may not be one of them but recently we ran into a discussion where I couldn’t make up my mind anymore. Hence, this post’s topic: sorting text.

The problem

How do you sort the following words:

  • cheese
  • Ape
  • Drums
  • dent
  • Beer

If you’d ask ruby I’d get:

 %w[cheese Ape Drums dent Beer].sort

Results in:

  1. Ape
  2. Beer
  3. Drums
  4. cheese
  5. dent

Which in my useless and ramshackle programmer’s brain translates to, well why not, it is sorted right?

But then we moved the data into a database which was correctly set up with a proper locale for ‘collation’, a term that I’ve seen but never meant anything to me until this problem. Collation is:

the assembly of written information into a standard order.

(thanks Wikipedia - Collation)

Databas…

Continue reading...

When to use x-objects?

An article, posted about 2 years ago filed in ruby, rails, ruby on rails, service, architecture & when to use.

So I wrote a few short articles on when to use FormObjects and Jobs and ServiceObjects. The question is of course “it depends”, but the leading principle I have is keep it simple. That being said, for inspiration, some suggestion for different layers to manage the application complexity from Vladimir Dementyev’s talk on Railsconf:

Presentation

  • Controllers (standard Rails)
  • Channels (standard Rails)
  • Views (standard Rails)
  • Presenters
  • Form Objects
  • Filter Objects

Application

  • Authorization Policies
  • Jobs (standard Rails) …

Continue reading...

When to use Modules / Concerns?

An article, posted more than 2 years ago filed in ruby, rails, ruby on rails, service, architecture, when to use & modules.

Whenever your model gets too heavy?

The easiest way to clean up your classes might be to create smaller, more concise methods. The next easiest way of tiding up your models is moving stuff to modules (whether they are ‘Concerns’ or not). Modules can then be included in the final classes. It will lead to a crowded list of methods exposed on these classes, for which alternative solutions exist (Presenters, Decorators), but if you shield off private methods nicely and have a consistent way of naming things, I wouldn’t be too concerned about that. Note that having many modules used in only a single class might be a code smell: perhaps you’re trying to do too much with that single class.

Concerns or Modules?

When you’re using Rails, you can make use of Concerns. They offer a few advantages over traditional modules, so use it whenever you’re bothering recreating the same behaviour using plain old ruby Modules. I prefer consistency, so if you’ve adopted Concerns, use con…

Continue reading...