Day 281 – Nature of Programming

85 – “Hello World” in 100 Programming Languages

This is a more technical post than the usual 365 fare.
Apologies to the non-programmers.

On the face of it, programming is about creating programs that do something useful. Turning a problem into a solution. And hopefully a working one at that.

To me, programming is about quite a bit more than that; it’s the act of taking an abstract idea and trying to encode all aspects of that idea into a correctly functioning piece of software. I use the word “trying” with purpose, because expressions in real-world programming languages are all just approximations of this ideal. Real-world programs always have some level of defects and “good enough” about them.

In the first instance I’d always strive for the ideal though.

Programming languages provide a great many tools to express meaning; comments, named variables and methods, automated tests, type systems, code contracts with formal verification.

The strongest expressions of meaning are always preferred; a formally verified code contract beats using parameter types alone. Boxing-in the meaning through parameter types beats well considered names. And even code comments beat constraints inherent in the idea that are left un-expressed altogether.

Every piece of meaning from the original idea that is added to a piece of code improves the chances of it getting implemented and maintained correctly. Additional meaning might have the compiler catch you in a lie before it becomes a bug. Additional meaning might help you remember the nit-picky details of how things hang together when you try to work on a piece of code years after you originally wrote it.

When I start with an idea, I look at it from all the angles. I try to work out what the underlying truths of the idea are. And then I try to find a way to translate all of these truths into pieces of the program.

Code contracts can expose code paths that can lead to null pointers where my feeble brain told me it was impossible for them to appear. Exploiting the type system can let the compiler warn me when I’m about to crash the Mars lander by mixing up my feet and metres. Expressively naming my methods and variables can help me spot where I’ve forgotten to sanitise a user-input.

And the trick is to push the encoding of concepts as far as possible into the strongest encodings the language has available.

Sure, I could make all my variables dynamic, then add unit tests to verify appropriate behaviour by variable type… but why not use a strong type system instead? Dynamic variables should really only be used where there is no alternative; maybe because some aspect of the strong type system is too strong to express the flexibility inherent in an implementation. But to use them routinely and then patch the hole with unit tests shows a very profound misunderstanding of the purpose of the type system.

Sometimes approaches can be combined to make an even stronger encoding of a concept. Just using Hungarian Notation to differentiate sanitised user input from un-sanitised user input is a good start… but adding program-wide automated testing in the build system to verify that variables using the naming convention for sanitised input only are assigned from sanitised input, or from the sanitisation method reinforces the concept in a way that makes it almost part of the language itself. A visible portion of the code that is verified by almost-the-compiler.

And there will be concepts that are hard or impossible to encode to the ultimate degree.

A variable name can indicate that the assigned value should only ever be a prime number… but there is very little that can be done to guarantee this is true, beyond hoping everyone is careful not to break that promise in the code. There is no way to reasonably implement a strongly typed “PrimeNumber” type.

But that doesn’t mean we shouldn’t keep trying.

And sooner or later, the ad-hoc encodings that have broad use and applicability will turn into new programming language paradigms for the next generation of languages. And they will be harder to program in… but only because they won’t allow us to be nearly as imprecise with our “words”.

You can lament the fact that not using dynamic variables means that you need to put in some extra effort… but all I hear is “why can’t you let me have some more hard-to-diagnose bugs?”

Day 257 – Progress and Perfection

After a lot more effort than I had anticipated, I decommissioned my 4-Bay QNAP NAS this afternoon. All files finally transferred off (400MHz of 2007 ARM grunt is really not adequate to saturate my network), and the 8TB of space re-formatted ready for sale, I have put up my final eBay listing for my little electronic re-org that has lasted the last couple of weeks.

It feels good to be able to stop thinking about the old, so that I can focus on the new.

As of yet, I have not played enough with my Windows 8 start menu to optimise it for its new consolidated uses. Only today, after a driver install and a re-boot, did I manage to get my 27″ monitor to run on 2560×1440 again. It had been stuck on 1680×768 stretched out to fill the surface.

I had hoped to make more progress on some software-development posts, but I really had to focus on my tools first and foremost.

Having said that, over my chores I did do some thinking about the larger structure of those posts, and I think I have come up with a great way to illustrate the “why”. I think the underlying theme I was looking for all along was to strive for a more perfect language. A future-state in which incorrect programs are impossible. Every abstraction along the way ought to at least try strive towards that goal.

And now I have to turn my mind back to the distraction of the TV in the background.

Day 117 – Stretching


I allowed my phone to distract me for longer than I should have let it this morning in bed. By the time my brain started doing the sums on the time required to get out of bed, through a shower, out to the gym, it was 9:45am.

My class starts at 10:30am.

Oh, and I decided to grab a small coffee along the way to wake up.

Luckily, by 10:33am I was in place on my thin mat at the front of an unusually full class that hadn’t quite started yet. Not my favourite spot, but it was of my own doing.

Today was an exceptionally good class. I find I always come out wonderfully stretched out. I credit the instructor, because she always knows when there is a little more reach left in me, and she adjusts us like we’re unruly furniture. Today my warrior got a little extra attention and I found a whole batch of muscles in my side, hip and hamstring that could use some more attention.

It’s an amazing feeling when I think I’m at the limit and she finds another inch or two of give that I wouldn’t have believed was there.

After a class like that, sitting is my favourite activity.


Which is what I did on the way back home. At a little table with a cappuccino and a sausage roll, with my trusty Kindle in tow.

I do most of my reading on Sunday afternoon after Yoga and to/from/during trips to Melbourne. Everything else just seems to consume my days any other time. Which should make this coming week a good one for The Game of Thrones.

My reading time today stretched on a little longer than it should have though. I was too engrossed in my chapters to take much note of the weather turning. I was under cover so the drizzle and rain just didn’t directly impact me.

After a couple of hours though it started getting a bit chilly, the swirling breeze getting cooled by the falling water, and brushing past the side of the building I was sitting next to.

When I decided I should head home I had just started another chapter though… and I have a really hard time abandoning a book in the middle of a chapter. So I zipped up the front of my hoodie, and stubbornly read my way through, admittedly shivering a little by the end.

I got another coffee as I left to warm me up. This is also when I learned there is such a thing as a cheaper refill. I’m not sure it’s healthy for me to know this.

And then I rushed home to have a nice hot shower.


Stretching my brain with my little personal project consumed the rest of the afternoon. I had already worked out the concept on paper, so it was long overdue to actually get started with some work (especially with the coming week in Melbourne it’ll be tricky to make progress during the week).

I had assumed I was going to have to find a library for RSS/Atom for C# to make it work. But I was pleasantly surprised to find out that Microsoft has a handy SyndicationFeed built right into the system, which seems to be just the ticket so far.

I don’t want to try to load my feeds on page accesses, so I need a background process to load the raw data for my application. I was familiar with approaches from PHP applications based on having a URL that a timed job somewhere else hits in lieu of a timer loop, but that seemed too hacky.

So far it looks like the recommended approach is to use a Timer object started from application start-up. I’m not sure why it feels wrong; it’s probably the idea of putting something stateful into a web application that just intrinsically sends my hackles up. But recommended it is, so the solution it also is for now. I can always separate this logic into a service running somewhere separately, which is probably the Right-Way-tm to do this.


Now, please, have some sweet German baked goods lest I eat them all myself…

Stollen; usually in form of a big loaf, but Aldi also does bite-size.
Stollen; usually in form of a big loaf, but Aldi also does bite-size.

And let me dedicate this song to the day… that’s how it works, right?


Also worth looking up on YouTube for a clip involving Fraggles.

Day 79 – Driven to Distraction

I did some programming tonight. I got so absorbed in what I was doing that I completely lost track of time. *yawn*

I was actually playing around with some JavaScript for the first time, and it was an educational and frustrating experience. I really need to have a bit more of a play with Visual Studio to figure out what tooling is available for debugging.

Biggest frustration so far: Razor looks great for ASP.NET, but it was completely baffling how to get my JavaScript to come through. Sorted it out in the end, but then decided that using an MVC project was overkill to play with JS, so nuked it all. I’m sure there is an easy way to do it all, but I’ll have to look at a few MSDN tutorials to get the gist of the recommended approach here.

I definitely went in the deep end there.

And now I need to sleep.
One more day, and then a nice long weekend… to play more with this?

PS: Sorry, no header picture today. I just don’t have the energy to think of something.

Day 72 – Personal Development

Preparing for the presentation I did last Wednesday has had unexpected flow-on effects. Looking through code listings that I had not seen for a year, and re-reading my post on Reflection Performance made me want to play around and re-implement a more flexible version of the APIs in the latest .NET version.

And then the inevitable happened.

I started reading web pages.

And I remember all the techniques and methodologies I have meant to write about and apply properly. Maybe I should take this as a sign to combine the two and write a series of posts on my journey of “Doing Fast Reflection Right”.

What this would look like is something like:

I’ll try not to make (all) these posts a part of my 365 day challenge for fear of boring any non-developer readers.

Day 70 – Final Demo Prep

Tonight I have spent another evening doing preparation work for the demo I am presenting tomorrow. Maybe I’m a bit too much of a perfectionist, but it just doesn’t feel right to give a presentation without planning out what is important to cover, and how I make it all into a cohesive whole.

And then fit it within the allotted 20 minutes of time.

There will be other sessions that other developers may present on the detailed intricacies of parts of the material I am just going to gloss over, but I still need to make sure this presentation paints a compelling picture why our common libraries add so much value to our software development.

I’ve decided on a mix of slides to paint the broader context, and hands-on demos for the pieces where “show, don’t tell” will bear more fruit.

And I’m hoping I can get through the material in closer to 15 minutes, so that there are also 15 minutes for questions not 10.

I have a suspicion that there will be questions about features I will not show. And any attempt to comprehensively cover them all would probably result in a full day presentation not just half an hour. I’d rather have questions drive a few more ad-hoc demo segments and be sure that I’ll cover whatever interests the people attending.

But now… I feel a little hazy, and I should stop thinking about this.

I went to another cycle class after work and before this prep-work. Three classes into cycle, it feels like it is getting easier but I still have a serious case of gym-brain.

Day 69 – Not As Fun As It Sounds

I am still a couple of months away from the first anniversary of my new management job. Over the past 10 months I have barely touched an IDE for anything more than a quick play.

Yesterday I installed Visual Studio 2013 RC, and today I am opening some libraries that have become only dim memories to have a poke around.

This Wednesday I am due to do a 20 minute presentation on the common code libraries that a lot of our applications were built on. I’m the expert on account of having written the bulk of the code in it. I am desperately trying to change that situation by encouraging them to replace anything that they consider broken or insufficient.

Although this angle hasn’t borne too much fruit yet, I’m now doubling down by adding some education to hopefully make the work ahead more visible and more in-demand.

In short, I’m kinda-sorta having a good evening with code that I haven’t seen in what feels like years. However, it *is* work, and I should be watching TV, reading a book, or shooting something.

I hope to find some time in the near future to do something substantive with the IDE though, and hopefully drop it into a public repository somewhere.