A calculator called Eric

Originally posted to Shawn Hargreaves Blog on MSDN, Wednesday, April 4, 2007

Please don't tell any of the guys here at Microsoft, but back in 2005 when I interviewed for my job on the XNA team, I had never actually written anything using .NET!

After the interview but before I accepted the job, I decided I had better learn C#, to make sure it didn't completely suck and that I wasn't going to hate programming in it.

My learning project ended up as a calculator utility called Eric. I think it's pretty neat. It can be used from the commandline to evaluate simple expressions, or you can define your own functions for more complex stuff, and it has a graph window that can display not only the usual y=f(x) type curves, but also parametric curves (x=f(t), y=g(t)), cartesian curves (f(x,y)=0), and sets.

The implementation is way more complicated than I would normally be happy with, because I was deliberately experimenting with advanced features like threading, closures, and reflection, plus trying to apply patterns from the worlds of generic, dynamic, and functional programming. I went overboard using Reflection.Emit to generate IL that evaluates user defined functions as quickly as possible. Gross overkill, but it was a great learning exercise!

The experiment was a success. I fell madly in love with C#.

Blog index   -   Back to my homepage