Foreword iii
along named Rist, Rast, or Rost, he’ll be an expert in that too. It’s an odd
speciality, but he’s clearly got it locked down.) But I do want to suggest a
controversial possibility: maybe the standards of expertise in our industry are
so low that all you have to do, to radically outpace every Rails programmer
you know, is actually read this book, start to finish.
I know it’s over 700 pages, but every single book in George RR Martin’s A
Song of Ice and Fire is longer than that, and I know at least half the people
who buy this book will have read that entire series. If you can sit through
an endless list of pheasant pies and random food involving persimmons, as if
anyone even knows what a persimmon is, you can sit down and invest some
time in actually getting good at the thing that you do for a living. Stranger
things have happened.
Rails is often seen as a newbie-friendly shorthand for building web apps.
Unwise people say that it makes building web apps so simple that anybody
can do it. I’m going to recommend that you regard that point of view as utter
bullshit. Here’s an alternative paradigm: Rails is a user interface for web
development which streamlines complex tasks. It doesn’t take the complexity
away. It streamlines your interaction with that complexity. There are two
things you should really watch out for here.
The first is that in programming, all abstractions are ultimately leaky ab-
stractions. For example, it’s irresponsible to write any kind of code which
handles money and currency if you don’t understand the basics of floating-
point math, including the reasons why computers can’t actually do floating-
point math. It’s literally impossible to represent many decimal fractions as
binary fractions, and computers represent everything in binary because they
ultimately run everything through logic gates. This means that it’s impossible
to accurately represent certain numerical values as floating-point numbers,
and people can take that mathematical impossiblity quite personally when
it affects the accuracy of their bank account balances. In other words,
the realities of calculation in silicon are very important when you’re doing
financial transactions. That’s just an example, but in every case, if you’ve got
a system which makes complex stuff simple, it’s still a really good idea to know
what those underlying complexities ultimately are.
The second thing you should understand, to avoid the majority of pitfalls in
Rails, is that building a good user interface is a lot of work. Every project out
there will encounter the tricky situation where you get the first 90% of the
problem out of the way, and then you discover that the remaining 10% of the
problem – all the random little edge cases and details – will take as much code
as the first 90% did. User interface code is all about that remaining 10%. And
Rails really is a user interface for web development. So entire libraries within
Rails, such as Active Relation, are dedicated to that little 10%.