Skip to main content

Ralsina.Me — Roberto Alsina's website

Your Editor is Not the Bottleneck

This may cause some pal­pi­ta­tions in some friends of mine who laugh at me for us­ing kwrite, but it re­al­ly is not. Any time you spend con­fig­ur­ing, choos­ing, ad­just­ing, tweak­ing, chang­ing, im­prov­ing, patch­ing or get­ting used to your ed­i­tor is time in­vest­ed, for which you need to show a ben­e­fit, or else it's time wast­ed.

Let's look at SLOC, which while dis­cred­it­ed as a mea­sure of pro­gram­mer's pro­duc­tiv­i­ty, sure­ly does work as a mea­sure of how much a pro­gram­mer types, right?

Well, es­ti­mates of to­tal code pro­duc­tion across the life­time of a prod­uct vary (just take the SLOC of the pro­duc­t, di­vide by men/­days spen­t), but they are usu­al­ly some­thing be­tween 10 and 100 SLOC per pro­gram­mer per day. Let's be gen­er­ous and say 200.

So, 200 lines in eight hours. That's rough­ly one line ev­ery two min­utes, and the av­er­age line of code is about 45 char­ac­ter­s. Since I as­sume you are a com­pe­tent typ­ist (if you are not, shame on you!), it takes less than 20 sec­onds to type that.

So, typ­ing, which is what you of­ten tweak in your ed­i­tor, takes less than 15% of your time. And how much faster can it get? Can you get a line writ­ten in 10 sec­ond­s? Then you just saved 8% of your day. And re­al­ly, does your ed­i­tor isave you half the typ­ing time?

How much time do you lose hav­ing your eyes won­der over the side­bars, but­ton­s, tool­bars, etc?

So while yes, typ­ing faster and more ef­fi­cient­ly is an op­ti­miza­tion, it may al­so be pre­ma­ture, in that, what the hell are we do­ing the oth­er 80% of the time? Is­n't there some­thing we can do to make that huge chunck of time more ef­fi­cient in­stead of the small­er chunk?

Well, I think we spent most of that time do­ing three things:

  1. Read­­ing code

  2. Think­ing about what code to write

  3. Fix­ing what we wrote in that oth­­er 20%

The first is easy: we need bet­ter code read­ers not ed­i­tors. It's a pity that the main in­ter­face we get for look­ing at code is an ed­i­tor, with its con­stant lure to­wards just chang­ing stuff. I think there is a lost op­por­tu­ni­ty there some­where, for an app where you can look at the code in orig­i­nal or in­ter­est­ing ways, so that you un­der­stand the code bet­ter.

The sec­ond is hard­er, be­cause it's per­son­al. I walk. If you see me walk­ing while my ed­i­tor is open, I am think­ing. Af­ter I think, I write. Your mileage may vary.

The third is by far the hard­est of the three. For ex­am­ple, au­to­com­plete helps there, be­cause you won't mistype things, which is in­ter­est­ing, but more pow­er­ful ap­proach­es ex­ist, like con­stant run­ning of tests suites while you ed­it. Ev­ery time you leave a line, trig­ger the af­fect­ed parts of the suit­e.

That's much hard­er than it sound­s, since it means your tools need to cor­re­late your test suite to your code very tight­ly, so that you will see you are break­ing stuff the sec­ond you break it, not min­utes lat­er.

Al­so, it should en­able you to jump to the test with a keystroke, so that you can fix those tests if you are chang­ing be­hav­iour in your code. And of course it will mean you need tests ;-)

Which brings me to a pet peeve of mine, that ed­i­tors still treat the file as the unit of work, which makes no sense at al­l. You nev­er want to ed­it a file, you want to ed­it a func­tion, or a class, or a method, or a con­stant but nev­er a file. Know­ing this was the sheer ge­nius of an­cient Vis­ual Ba­sic, which was com­plete­ly ig­nored by all the snobs look­ing down at it.

So, in­stead of tweak­ing your ed­i­tor, get me a tool that does what I need please. I have been wait­ing for it since VB 1.0. And a sand­wich.


This post is 99% lies, but I want to hear the ar­gu­ments against it. If I tell you now it does­n't count as a re­al lie, I have learned from fi­nan­cial press ;-)

UP­DATE: In­ter­est­ing dis­cus­sions in red­dit and hack­er news

Contents © 2000-2021 Roberto Alsina