172 reputation
6
bio website tomharrisonjr.com
location Boston, MA
age
visits member for 2 years, 9 months
seen Apr 5 '13 at 20:41

Make it work, make it beautiful, make it fast.

We tend to skip the last two even if we somehow achieve the first.

Corollary: Code first, optimize later. (a.k.a Premature optimization).

What's built in here is this: please write code you can observe, measure and test as it works.

We are all sure of the things that are slow, optimal, and want to try the stuff that is new and cool. But in real life, which is to say in real software, and as time passes these "rules" change. Don't take some dictum, some claim, or some rule of thumb to be the truth. Instead, code in the simplest, most obvious, most readable way first: get it to work, first and foremost. Simplicity is king.

But make sure you can know (or learn) the difference between simple and simplistic.

Simplicity is bad when it is simplistic -- simplicity is a virtue, being overly simple (simplistic) is bad, and evidence of intellectual laziness. You need to write code that measures itself. Good code is inherently introspective. Rails exemplifies this, with built-in timings of major phases. You're not a bad person if your first few passes at coding turn out to be over-simplifications of a problem (on the contrary: try to simplify!). But when you find your model of the requirement is less than needed, keep looking for a way to make it simple. Simple is not slow, bad, or dumb: simple is artful.

You'll find that a joy of software development in the modern age is that things that are known to be slow (databases, interpreted languages, IO, etc.) are often not the bottleneck. In real code, it's usually just code that does what it needs in a silly way that makes for badness. If you can measure timings, and profile your code, you can find and fix what needs fixing, and leave the perfectly simple and elegant code alone.

It's funny, for all of the beautiful code and optimized code I have seen, it's usually the beautiful code that performs best. There's something about truly understanding the problem that is necessary to make code beautiful -- it's surprising and wonderful that this depth of understanding tends to coincide with, hence obviate the need for optimization.

But sometimes, beautiful code doesn't perform. And then, you may need to optimize. Look for the simplest and most obvious optimizations first -- a missing index, a repeated query or method, a thing that is expensive to do that is requested often is a candidate for caching.

Don't cache unless you see you need it. Don't thread unless you need it. Don't denormalize data unless you must. Don't build fancy subsystems because it seems evident that they will be needed to scale. And above all: don't be lazy (even if that's the fastest way to get it to work).

Complexity is the enemy. Simplicity is the art of making something complex look easy.

Software engineering is art.

Make it work, make it beautiful, make it fast.


Jul
2
awarded  Curious
Jan
17
awarded  Popular Question
Apr
5
comment Async load of secondary content; Google says “slow”, users see what they want faster
We do as much short-circuit logic as possible, but there are still many complex rules that apply differently not only by user but also by article.
Apr
5
comment Async load of secondary content; Google says “slow”, users see what they want faster
Thanks Tim. Yeah we have many fixes and simplifications in the queue so mostly curious if user experience was in conflict in any way with site performance as seem by google. I would still go for better user experience :-)
Apr
5
accepted Async load of secondary content; Google says “slow”, users see what they want faster
Apr
3
asked Async load of secondary content; Google says “slow”, users see what they want faster
Feb
14
comment Google Analytics Kiosk: URL that compares current month to last, and is permalink
Thanks Steve -- nice to see you, too. I normally hang out on SO :-)
Feb
14
accepted Google Analytics Kiosk: URL that compares current month to last, and is permalink
Feb
14
asked Google Analytics Kiosk: URL that compares current month to last, and is permalink
May
1
awarded  Scholar
May
1
comment SSL between customer's domain having CNAME to our secured server?
thanks for your reply. This gives us an option for customers who really, really want their own domain name. It hadn't occurred to me. Thanks!
May
1
accepted SSL between customer's domain having CNAME to our secured server?
May
1
asked SSL between customer's domain having CNAME to our secured server?
Feb
28
awarded  Teacher
Feb
28
awarded  Supporter
Feb
28
awarded  Student
Jan
8
comment How can I track “user returns after X days” as a goal in Google Analytics?
Thanks @danlefree -- The advanced segment solution does not exactly solve my problem as I initially meant, although it it a pretty good idea for spot analysis. The issue with advanced segments is that we use many others and they cannot be ANDed together. So, for example, if I wanted to see registered users (an existing advanced segment) who have come back within 7 days, I would have to have another segment that has the rule for "registered user" AND the new logic for days since last visit. I would like the data to be recorded and stored over time, in the same way that a goal is stored. This al
Jan
4
asked How can I track “user returns after X days” as a goal in Google Analytics?
Nov
4
answered Google Analytics reporting 5% of users using IE on one site. Most other sites I track are still around 40%. What gives?
Nov
4
comment Google Analytics reporting 5% of users using IE on one site. Most other sites I track are still around 40%. What gives?
@joshua and disgruntled -- thanks. The one large source of ad traffic I mentioned was StumbleUpon, who provided one possible cause of IE issues (see below).