Jack’s rake: A scramble through C# Published 19th Jan 2016
What does C# and a mountain have in common?
My home is up north, so I was aware that places in our beloved Lake District had sadly been flooded over Christmas and New Year. However I now found myself on a train heading for Windermere.
I had recently finished with my PhD at Cambridge, and was looking forward to joining HTI Labs for an internship in January. I had been studying Mathematics, and was keen to put some theory in to practice! Having a fondness of mountains too, I was especially excited to spend the first week in Cumbria with Neil, from the HTI team.
Over the first day, Neil had done a great job introducing me to the systems HTI use. And on the second afternoon we set off to explore the hills, discussing C# along the way! We only hoped that the clouds would lift and give us a view of the mountains….
After a pleasant climb we found ourselves at Stickle Tarn, next to the Langdale Pikes. (Neil informed me that this Tarn had been up for sale recently…any news on that?)
Our C# had taken a pause as we stared upwards, trying to discern if we could spot a route up…else resign ourselves to the longer (and, let’s be honest, far less interesting) detour! It turns out yes – like the bridge from Indiana Jones, approach from just the right angle and the route opens up…we had found “Jack’s Rake”, a narrow scramble up the front of Pavey Ark.
As part of my undergrad I enjoyed climbing and walking, so was especially keen to `dust the cobwebs’ off my scrambling skills. We followed a trickling stream upwards, and were met with lovely views from the top, as the clouds parted enough for us to look down – with only a few of the tallest peaks being hindered by the cloud.
We resumed our conversation about C# from the top - there is something very restful about combining abstract classes with the concrete vastness of mountains and valleys. We viewed the scenes from Harrison Stickle, which sits at 2,415 feet. Continuing to enjoy perusing the ridge, we reached small peaks one after the other.
Next came the way down – picking up some speed the fresh air helped me digest these new topics. I had been writing modelling programs in MATLAB for my studies, so having a patient teacher in these new topics was invaluable!
Something I’ve been learning at HTI is the importance of a rigorous testing and design process in development. While we’re on topic of mountains, let me illustrate the importance of thinking about application of a program in the design stage:
The summit of Everest (the highest point on earth measured from sea level) sits proudly at 29,030 feet. Suppose we wanted a program to store and use the heights of mountain tops. We can store all of these as a short (16 bit) int – since the maximum allowable value is 32,767. However, let us not be tripped up!
Some are not so content with Everest’s self-pride, and would rather measure by height from base to tip, even if the base lies below sea level. With this classification, the tallest mountain would be Mauna Kea, measuring more than 33,000 feet.
Our 16 bits are seemingly insufficient, or are they?
Do we really need 32,768 negative numbers to store these heights, let’s take those and use an unsigned short int. Suddenly we have 65,535 values of freedom, more than enough, and we rest content in our measuring bliss!
But not for too long.
When humans colonise Mars, they may want to take our program with them. We should ensure it is also `Martian-friendly’; would our choice extend to this too? Olympus Mons (the highest mountain on Mars, and in the solar system)sits tentatively out of reach at 69,650 feet above its datum (there is not yet a sea level on Mars…watch this space!) For this case, let’s play it safe and take a 32 bit int (I am not so impolite as to give that range here).
Of course, if I joined the modern era and measured all of these in metres, we could stick with our space-conscious 16 bits and all problems would be solved…I leave you to pick your preferred solution.
For now, back to Earth; generics and monads here at HTI Labs!blog comments powered by Disqus
Find out what we're talking about on the blog