Archive for November, 2009

Move It Up

5 Comments »

CitydiscIn 1992, I coded the first incarnation of yellow pages on-a-map, CityDisc, the brainchild of Ben Hoefnagels, a great guy and visionary. I really liked to work for him. He would tell me what he wanted, and let met code. In those days, software had to run on a 6 MHz Intel 80286 from a 720kB floppy disc. I explained to Ben than in order to fit 3000 streets (and 30.000 addresses) on one floppy, we should use vector graphics. So Ben told me: “OK, go do it!” This first prototype was rather slow. So Ben told me: “Make it faster!” Profiling showed that 92% of the run time was consumed by one function: sqrt(). Small wonder, coding vector rendering is all about Pythagoras. For hours I, fruitlessly, tried to make a fast my_sqrt(). Then I moved the problem up one layer of abstraction. If I could not speed up sqrt(), I might find a way to speed up the function that used it: the length() function. On a hunch, I tried:

#define length(x,y) ((x > y) ? (x + y/3) : (y + x/3))

I hit <Ctrl><F9> (Yes, Turbo C.) and BANG there was the map, almost instantaneous. I never forgot that lesson: Problems can be hard on one level of abstraction but easy on an other.


The Art of Redundancy

4 Comments »
            [oo ]    [oo ]    [oo ]    [oo ]
            <   >    <   >    <   >    <   >

            [ oo]             [ oo]    [ oo]
             > <               > <      > <

            [oo ]    [oo ]    [oo ]
            <   >    <   >    <   >
 
               V
                         V

                                V
                                   ^



                                <_I_>

In 1981 I coded a Space Invaders clone for the Apple ][ Europlus. I knew I should not have used Microsoft’s super slow Applesoft BASIC, but I just did. It was an animated ASCII-art program with a main-loop moving 12 invaders, the defender, the up-bullet and the five down-bullets. The latter two with collision detection and scoring. However it was not fast enough. I then tried, what I now would describe as redundancy. I replaced the code that printed the 12 invaders one at a time with one that would print 4 at a time (i.e., a whole row). I used ON (II%*2+FF%) GOSUB to go to any of the (2^4)*2 “subroutines” that would print the correct row. That made the game totally playable. It taught me that redundancy is not always a bad thing.


Actions are Buttons, Places are Links

1 Comment »

Picture 1Three months back, I went on a coding spree to create a simple wiki system to coordinate the creation of a school magazine. I tried several open-source wiki systems. Did not work. Main culprit? The navigation. First in all wiki systems I tried, everything was a link, second, some things—like uploading an image—took five actions in a specific order. So I created a super simple system, where actions are buttons and places are links. I was very happy with it, but the audience was not. There was one [-edit-] button per page, and to the audience it was unclear what would be edited if they clicked it. So I added lot’s of redundancy, now every item has it’s own edit button. As it turned out, images need a different edit button, because to the audience images are uploaded, not edited. I gave all the buttons a fixed column, leaving blank the ones that do not apply. Sometimes it is so hard to fully respect the GUI coding rule: “Write for your audience, not for your peers.” (Ryan Opaz) [Free Advice]

(Also I cheated, I could not make everything self explicatory, so I made two instruction screen-casts. Now everybody is happy.)


Choosing a Language

No Comments »

Managers often are confronted with a need to choose a programing language. Usually they ask themselves questions like: “How simple is it to learn language X?”, “Do our coders like to switch to language X?”, “How well does our IDE support language X?”, “How well known is language X?”

These questions, however, might not be all that relevant. While a Turing Machine can be used to code graphic animations, probably a more abstract and domain specific language like Processing would be more productive (and fun). However a Turing Machine might score better on the questions above. The more relevant questions for selecting a language focus on two terms domain and abstraction. I won’t try to explain why, or even define these two terms (click the link, Luke). Suffice it to state that: Experienced coders use more abstract features to make more compact code and, thus, be more productive. Domain specialists use more domain specific features to code quicker and, thus, be more productive.

One could be forgiven the mistake of thinking that the more abstract a language is the less domain specific, and vice versa. A random counter example is PostScript, a powerful, abstract, concatenative language, used almost exclusively in the domain of printers.

So if you employ a domain specialist (count your blessings and) choose a domain specific language. If you employ a code wizard (count your blessings and) choose an abstract language. About the worst you can do, is pick a abstract, general-purpose, multi-paradigm language like Python for a mathematician to code math models. Best case this will eventually lead to a huge and clunky library stack like Python(x,y), that dictates every other aspect of all the code that interfaces with it. Very soon, the lack of flexibility will drive everybody back to using a spreadsheet for their modeling. Maybe a better choice would be a language like R, or indeed that spreadsheet.


One Thousand Cuts Per Day

No Comments »

musashi-sDo not choose setup.exe. Choose setup. Why? By default, Windows hides common extensions and what appears to be setup.exe is actually a file called setup.exe.config and setup is actually setup.exe. Anyone with any pretensions towards technical savvy will sidestep that trap intuitively, it does begin to feel horribly familiar. (Mark Whitehorn) [SQL Server 2008 - from semi-relational to sublime]
The design of you code can escape into the real world. Split second decisions like: “Ok, I need a name for this configuration file. Let’s add “.config” to the executable name.” is one of one thousand decisions per day. And all these split second brethren need more than casual thought. Non coders usually don’t understand the magnitude of mental reflexes needed for this. But also they will never know the deep satisfaction it brings to fight the devil and win, to write really good code.


Oil to Voice

No Comments »


In our category CodeReuse, today, the step from oil-echo-location to auto-tune. And yes, you can have it on your iPhone [I am T-Pain].


Look Ma No Web Developer Toolbar

No Comments »

I use the following bit of CSS to help visualize the structure of an XHTML (or HTML) document by putting a colored outline around the border of every element. At each level in the hierarchy the color changes so you can see when “depth” changes.

  * { outline: 2px dotted red }
  * * { outline: 2px dotted green }
  * * * { outline: 2px dotted orange }
  * * * * { outline: 2px dotted blue }
  * * * * * { outline: 1px solid red }
  * * * * * * { outline: 1px solid green }
  * * * * * * * { outline: 1px solid orange }
  * * * * * * * * { outline: 1px solid blue }

I usually keep this block of rules at the top of a stylesheet, commented out with /*…*/, which I remove when I want to see the structure. (Chris Page) [A Handy CSS Debugging Snippet] Almost as handy as Web Developer Toolbar Add-on for Firefox. [via: DI]


Breaking Software Development

No Comments »

Why are programmers so fussy about their employers’ morals? Partly because they can afford to be. The best programmers can work wherever they want. They don’t have to work for a company they have qualms about. [...] And it’s not fun for a smart person to work in a place where the best ideas aren’t the ones that win. (Paul Graham) [Apple's Mistake] True that. If you want the best programmers, be the place they want to be at hardest. If you want the smartest programmers, don’t give them a manager that want’s to win, give them one that wants to serve. [via: DI]


Coding Weapon of Choice

No Comments »

developer
Mobius is an invite-only event, hosted by Microsoft, where the invited guests are shown what Microsoft is doing in the mobile space. [Mobius 2009] Guess what most of these creme-de-la-creme Microsoft mobile developers (and journalists) use as their weapon of choice? [via: DI]


Long Matters Short

No Comments »

Banks play a pivotal role in the finance system, they perform a kind of miracle, they make short money long. Come to think of it, most companies, not just banks, perform such miracles. Companies, make long visions short. Management takes the long term goals of a company and by ways of a miracle translates them into short term goals for the people that actually do the work. So, wonder no more, that is what management is good for … in theory. In practice management often emits quick and dirty shorts that do not sum into coherent longs. With most tech-companies, this is even more difficult to spot because a manager, feeling the lack of effort behind their decision, will effort-up the decision by trying to express it in quasi tech-terms.

So next time, you go WTF? Just ask them two things. First, why are you telling me how-to-do instead of what-to-do? And second, what long term goal does this serve?