This is the fourth article in a twelve-part series that discusses the twelve finalists and their calculator submissions for the OMGWTF Programming Contest. The entries are being presented in the order submitted, and the winner will be announced on June 18, 2007.


I learned an interesting thing when reviewing Entry #100103 (Welbog’s TerseCalc): a whole lot of computers today don’t have mathematical coprocessors! I was a bit skeptical at first, but then I remembered something: our 386 computers had a slot for the 387 chip, i.e. Intel’s mathematical coprocessor, and my computer today does not have a slot for me to add a mathematical coprocessor! Therefore, this fact must be true. It was also written in an authoritative-looking PDF, so double-therefore, it must be very true.

Fortunately, in order to spread the wonderful world of mathematics to the world, the fine folks at Welbog have created TerseCalc, the calculator for PCs without mathematical coprocessors. In addition, TerseCalc’s innovative n-tier architecture allows for the Math Tier to directly return values to the User Interface Tier without wasting all that time going through the Parsing Tier. This following diagram explains the magic perfectly:

To learn more, I had a quick chat with Welbog’s founder, CEO, and only employee, Dean.

So Dean, we all want to know: how does the magic behind TerseCalc work?
Our one-way communication protocol is a Welbog secret. What I can tell you is that it saves a lot of trips through a lot of layers. Oh, and no other company does what we do: TerseCalc is top-of-the-line and bleeding-edge technology.

You are currently Welbog’s Chief Software Architect. Tell me, how did it all begin?
It all started back in middle school, where I had a “technology” class where we learned to make web pages. I liked HTML so much that I taught myself CSS and JavaScript, and just kept going through highschool and university.

Where did you attend university?
The University of Waterloo, which was a bit of hike from my hometown of Florenceville, New Brunswick, Canada. I was awarded a bachelor of mathematics in computer science.

I bet that helped with TerseCalc! What drew you to the OMGWTF contest?
I just love programming contests! I participated in a few programming contests in university, but failed them miserably.

 I was able to show off some of the magic behind TerseCalc. The rest of the code (and magic) is avaiable in the download link at the end of the article. Following is the Addition function, which demonstrates not only the enterprisiness of the solution (abstracting numbers and operations into classes), but how the one-way communication happens:

/*
 * Fast addition is implemented using a recursive bitwise
 * algorithm, similar to machine addition. This algorithm
 * is pre-optimized so as to not confuse the compiler.
 */
void Addition::operate(VECTOR args) {
	unsigned int addend, other, carry, sum;
	
	try { args[0]->getValue(); } catch (int result) { addend = result; }
	try { args[1]->getValue(); } catch (int result) { other = result; }
	carry = SHIFT(other & addend);
	sum = other ^ addend;
	if (carry == 0) {
		char buffer[13];
		sprintf(buffer,"%i",sum);
		throw new string(buffer);
	}
	VECTOR v;
	v.push_back(new Number(carry));
	v.push_back(new Number(sum));
	this->operate(v);
	throw new string(ERROR);
}

As you can see, the Addition function is void and does not return a value. It does, however, throw a value all the way back up to the UI tier. Now that’s efficiency!

And I almost forgot, I also asked Dean if he’d replace Window’s Calculator with TerseCalc.

Between you and me, there’s no way I’d use TerseCalc in place of the calculator IRC bot (KevBot) I currently use for all of my arithmetic needs.

Download Entry #100103, TerseCalc (ZIP File)

[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!