The blog of , a Ruby on Rails development team

Now available: Growing Rails Applications in Practice

It's finally done! We just released version 1.0 of our e-book Growing Rails Applications in Practice.

With this book we hope to provide pragmatic advice for scaling large, monolithic Rails codebases. If you've been looking for actionable, low-ceremony techniques to improve your application today, this is your book.

You can pick your own price for this book (there's a minimum price of $10). Let us know if you have questions or feedback!

Swift is not my favorite language

I really wanted to like Swift. In a world that has settled on Javascript, an ambitious language design is a rare treat. And all the money we gave to Apple should buy us a decent language.

So five years after iOS has killed Adobe Flash, Apple releases a language that looks and feels remarkably like ActionScript 3. Just like ActionScript, Swift is locked behind a $1000 paywall. Instead of bindings to proprietary stuff from Adobe it has bindings to proprietary stuff from Apple.

Some observations from my armchair, in no particular order:

Generics: It will be so much fun to watch a generation of Internet hipsters crash into the wall of complexity that is generics. The survivors will learn that you can't have an expressive type system without being Scala. And I'm not sure you want to be Scala.

Explicit null: Language tourists all over the planet are praising Apple for including optional values. This is such a horrible solution to a much deeper problem. Remember how when Java introduced checked exceptions and everyone said this would force people to handle their errors? What it got us was was empty catch clauses and everyone going back to unchecked exceptions. The same fallacy has now brought you optional values.

You can't make this issue go away with language design. You don't have a language problem, you have an API problem and an education problem. Why did anyone feel it was OK to pass or return null? The clueless developer who passed you the null in the first place will now pepper your code with exclamation marks to make the funny compiler errors go away. Enjoy.

Inconsistencies: So a language that prides itself on not doing implicit conversions (because safety) does auto-unwrap arrays during concatenation. This will ruin so many lives.

Name conflict: What really gets my blood boiling is that there already is a programming language that is called Swift. Imagine waking up one morning only to discover that someone with more money took your name and will bully you out of Google forever. I had this happen to me and it sucks. Open Source maintenance is the most thankless job on the planet and this is just a big fuck you in the face of everyone who spends their weekends working on free software.

I don't know what's more infuriating: That Apple couldn't be bothered to run a stupid Google search before deciding on the name or that they did run that search and went ahead anyway. There's still one classy move they can take to fix things, but I doubt that the issue even registers when you're sitting on a mountain of money.

In a nutshell:

  • There are now two languages called Swift
  • One has semicolons
  • Both are better than Objective-C

Our new e-book: Growing Rails Applications in Practice

Find below the opening chapter of our new e-book: Growing Rails Applications in Practice. The complete book will be published this summer. Enjoy!

How we got here

When you started doing Rails some years ago, it all seemed so easy. You saw the blog-in-ten-minutes video. You reproduced the result. ActiveRecord felt great and everything had its place.

Fast forward two years. Your blog is now a full-blown CMS with a hundred models and controllers. Your team has grown to four developers. Every change to the application is a pain. Your code feels like a house of cards.

You turn to the internet for assistance, and many solution seem to be available. You should move away from fat controllers, it says. But do avoid fat models. And use DCI. Or CQRS. Or SOA. As you cycle through patterns, your application is becoming a patchwork of different coding techniques. New team members are having a hard time catching up. And you're beginning to question if all those new techniques actually help, or if you're just adding layers of indirection.

You start missing the early days, when everything had seemed so easy and every new piece of code had its place. You actually liked ActiveRecord before it drowned you in a sea of callbacks. If only there was a way to do things "the Rails way" without having it fall apart as your application grows.

The myth of the infinitely scalable architecture

We'd like to show you one path to write Rails apps that are a joy to understand and change, even as your team and codebase grows. This book describes a complete toolbox that has served us well for all requirements that we have encountered.

But before we do that, we need to let you in on an inconvenient secret: Large applications are large. The optimal implementation of a large application will always be more complex than the optimal representation of a smaller app. We cannot make this go away. What we can do is to organize a codebase in a way that "scales logarithmically". Twice as many models should not mean twice as many problems.

Here is a chart that we made up:

Vanilla Rails vs. structured Rails

In order to walk the green line in the chart above, you don't necessarily need to change the way your application is built. You don't necessarily need to introduce revolutionary architectures to your code. You can probably make it with the tools built into Rails, if you use them in a smarter way.

Compare this to sorting algorithms. When a sorting function is too slow, our first thought is not "install a Hadoop cluster". Instead we simply look for an algorithm that scales better. In a similar fashion this book is not about revolutionary design patterns or magic gems that make all your problems go away. Instead we will show how to use discipline, consistency and organization to make your application grow more gently.

We have three principles that guide our design decisions:

1. Be boring

We have a universally applicable default design that maps any user-faced interaction to CRUD and ActiveModel. By being consistent in your design decisions we can reduce the cognitive overhead required to follow your code. This makes it easier for colleagues and new developers to navigate and change our source.

Read about this principle in the following sections:

  • Why controllers should be boring
  • Using ActiveRecord effectively
  • User-facing models without a database: ActiveModel
  • Taming style sheets

2. Be organized

We organize code in a way that encourages the creation of new classes. By isolating screen-specific concerns from a slim core model we can reduce the side effects that models can have on other parts of your application.

Read about this principle in the following sections:

  • Dealing with fat models
  • Taming style sheets
  • Taming javascripts
  • Organizing large codebases using namespaces
  • Don't let authorization infect your application

3. Be humble

Where we suggest using before/after code comparisons to avoid being sidetracked by the design fad of the day. We will make a case for adopting new technologies and patterns with care, and take full responsibility for those techniques and technologies you do choose to adopt.

  • How to test effectively
  • Hipster Patterns
  • Owning your stack
  • Surviving the upgrade pace of Rails

Are you interested in this book?

We're currently finishing up the final chapters. Growing Rails Applications in Practice will be released this summer. If you're interested in the book, please enter your e-mail address into our notification form. We will let you know as soon as we publish!

Growing pains

First off: You might have noticed that the name of this site has changed from Gem Session to simply makandra blog. It's still us, makandra. Please don't unsubscribe.

You might also have noticed that the last post before this one is from 2011. That's three years ago. Yes, we're still alive. Yes, we're still doing Ruby on Rails. We've just been super busy.

1. We've become a supplier for the Ruby industry

I'm not sure if there even was a Ruby industry a few years ago, but by now Ruby and Rails has become a huge technology sector. We now see massive Rails projects facing serious challenges of scale and security. We have moved on from being a pure Ruby consultancy to supporting owners of commercial Rails projects.

When official support for Ruby on Rails 2.3 and 3.0 ended with the release of Rails 4, we picked up the torch with Rails LTS. We now continue to provide security patches for Rails 2.3 and 3.0, protecting existing applications or providing project owners with more time for upgrading.

As a companion service we launched Ruby Backports. By backporting a gem you can use modern libraries without having to upgrade your Rails or Ruby. Or you might want to port a security patch to a version branch that is no longer maintained by the community.

By offering services like Rails LTS and Ruby Backports we hope to bring some calm into an ecosystem that traditionally had issues with API stability.

2. We're writing a book about growing Rails projects

OK, everyone's writing a book. But ours is special. Super-promise.

How to make large Rails applications not fall apart is the number one challenge Rails teams all over the globe are facing right now. There are a number of approaches like SOA, DCI or embedded engines, which all come with their benefits and drawbacks. What's missing is a good default for the average Rails team: What low-ceremony measures can you take to keep a Rails application maintainable as it grows into its second or third year of development?

By taking a dozen Rails applications from inception to deployment each year, we had the unique opportunity to experiment with different architectural patterns. Since we often maintain these projects for years afterwards, we have a pretty good idea which techniques tend to work out and which don't.

By distilling our experiences into a single book we want to show you one path to create a Rails app that is a joy to understand and change, even as your team and code base grows. We won't talk about revolutionary design patterns, hip techniques, or awesome gems that automagically solve all your problems. Instead we will show how to use discipline, consistency and organization to make your application grow more gently.

We're currently finishing up the final chapters. Growing Rails Applications in Practice will be released this summer. If you're interested in the book, please enter your e-mail address into our notification form. We will let you know as soon as we publish!

3. We've been blogging elsewhere

Remember when we told we how we open-sourced our internal knowledge base and built makandropedia? When we did this in 2010 we had about 200 HOWTOs for Ruby, Rails, RSpec, Cucumber and Javascript. Since then we've been blogging there. A lot. Today makandropedia contains over 3000 cards. We liked it so much that we sort of forgot about this blog.

We will continue to post technical guides and HOWTOs to makandropedia, so if you're following us for that, you should subscribe to makandropedia's feed. We will use this blog for rants and commentary about software craftsmanship, technology and the world of Ruby and Rails in particular.

4. We've just been busy

When we entered our third year as a company in 2011, we experienced some growing pains that are the last thing on your mind when you launch a startup. Despite this transition and all the product development we launched so many Rails projects in those years that we're having a hard time remembering them all.

We're sorry for falling off the grid. We're sorry we didn't call. But sometimes you just need to sit down and get shit done.

Expect more posts on this blog soon. Make sure you subscribe to our feed. If you're not into feed readers you can also follow us as @makandra_com on Twitter or on Facebook. We will re-post links to new blog articles on both networks.

Meet us in Berlin this weekend

We're on our way to Berlin for the Plat_Forms 2011 results presentation and awards ceremony. It will take place tonight (Friday) at the Freie Universität Berlin. You can meet us there if you’re interested. No word yet about results, but we’re rooting for the Ruby teams.

The results presentation will be followed by an unconference this Saturday. It’s free to attend, just add yourself to the attendee list. I will give a crash course into Test Driven Development. Thomas will talk about how we’re sharing knowledge at makandra and how makandropedia has eventually evolved into a knowledge management solution for everyone. There will be some other sessions as well.

If you have trouble finding us, just e-mail me your cellphone number (henning dot koch at makandra dot de). I will occasionally check my e-mail and give you a call.

Growing Rails Applications in Practice
Check out our new e-book:
Learn to structure large Ruby on Rails codebases with the tools you already know and love.
Our address:
makandra GmbH
Werner-von-Siemens-Str. 6
86159 Augsburg
Contact us:
+49 821 58866 180
Commercial register court:
Augsburg Municipal Court
Register number:
HRB 24202
Sales tax identification number:
Chief executive officers:
Henning Koch
Thomas Eisenbarth