Efficiency. The search for log of n.

Jawwad Ahmed Farid
4 min readOct 1, 2023

My first client implementation deployed a back office accounting system at a small business in Europe.

The days of the good old client server model. One central server that served networked client machines across the office. A Novell Netware server running Interbase (hello Borland), front end on Delphi 95, reports on Crystal Reports. Other than Interbase which was a makeshift solution and Novell Netware which would get dumped later, that stack stayed with us for the next 28 years.

Every time I would start a test run on one of our key accounting reports, the owner of the business would pop right out of his room, look at me and say, could you please stop doing what you are doing so that I can do what I need to do to make enough money to pay your bills. Not in so many words, but with curated French thrown in for good measure.

Algorithmic and code efficiency is a habit that we need to build from day one in our CS education. Not later.

It is not an easy problem to solve since understanding efficiency is mostly experiential. You need to slow down a building worth of customer machines to a crawl for you to realize that your nested for loop wasn’t that great an idea. For many of us that happens when we end up working with large datasets that need time critical information in a time critical fashion.

If we all we do is run day end or day start batch at midnight on tables with less than a million rows, the challenge rarely arises. 12 hours is infinite time for a rack of processors rated at a few million MIPS.

While adding Design and Analysis of Algorithms and Algorithmic thinking to computer science curriculum has certainly helped, it is internal code reviews by senior architects that identify and point out bad habits in our personal programming styles.

Effective architects have a do not do list that they share as part of team orientation. Along with a polite heads up. Breach the list on the pain of death. Also you will never write code on this floor again because even your soul won’t find where I hid your body after doing your code review. (You know who you are).

And when a code review or an architect is not on the menu, it is the aftermath and postmortem of crashing customer servers that highlight issues at the code level. You think it will never happen at your shop, till it does. If you don’t have anyone who can dissect the debris generated from your failing code, you won’t even know why the good looking dashboard you wrote is sucking the life out of every rack in your data center.

Why is that? I didn’t learn about the trouble nested for loops caused in school. I learned it at work. Not in my first year, but much later. There is so much bad code I wrote that is now legacy floating around the world. This is true not just for me but also for many students who took the Algorithms course. Till we actually put it to work in real life our course notes remain forgotten on dusty book shelves or back up hard drives.

Back in the days of Novell Netware, we chased higher TPC-C ratings by buying bigger and better servers. But even then, the smartest of our group would focus on tweaking code to etch out a few millisecond of performance out of their code. Milliseconds compound, both in and outside of day end batch.

It is only when you run a half marathon do you realize the importance of efficient form. That or lane 8 of the 400m final at the Common Wealth games when missing the tape by 2/10th of a millisecond gives new meaning to relative time.

Which is the reason why we are having so much fun with the Big O notation this week in the Introduction of Computing Course. Milliseconds compound. In the section titled patterns in code and data we focused on faster search, faster sorts and computational complexity. All the hard work we did with exploring problem spaces, Excel Pivot tables and Power Queries comes together as we come up with new ways of running out of RAM on our shiny new laptops.

Some would say we are being over ambitious with our freshmen/women class. Never too early to talk about programming style, efficient code, bad habits or Big O. Catch them young and give them a head start. Because only fools learn from experience, wise men learn from fools.

I teach the Introduction to Computing Course at the School of Math and Computer Science, IBA, Karachi. You can find the course outline below.

Intro to Computing lecture playlist from Fall ’23 term at IBA, Karachi. As at week six.

--

--

Jawwad Ahmed Farid
Jawwad Ahmed Farid

Written by Jawwad Ahmed Farid

Serial has been. 5 books. 6 startups. 1 exit. Professor of Practice, IBA, Karachi. Fellow Society of Actuaries. https://financetrainingcourse.com/education/

No responses yet