Only showing posts in the "Software" category

F# - Why You Should Give an F (DDD Melbourne Presentation)

F# - Why You Should Give an F Title Slide

Today at DDD Melbourne I gave an introductory presentation on F#, .NET’s general purpose functional programming language.

The abstract for the talk is:

Are you a C# programmer that loves the power and fluency of libraries like LINQ and RX? Do you sometimes find it difficult to write your own expressive, clean, reliable and concurrent code? Have you looked at functional programming and been terrified by math symbols and scary sounding words like "monad" and "category theory"?

In this talk we'll introduce and discuss how to use F# and functional programming techniques to write that cleaner, more expressive and reliable code that you've always wanted; and we promise not to descend into crazy math symbols!

I’ve uploaded the source code and slides to a GitHub repository, so you can examine the awesome in your own time and get excited… in private. :)
I’ve also fixed the copy and paste bug that Mahesh pointed out on Twitter. Can’t let a little typo stand! :)

To compile the SQLClient type provider code, you’ll need to install the AdventureWorksLT sample database to your own SQL Server instance. You can download it from Codeplex under the name “AdventureWorksLT2012_Data”. You can follow this guide on how to attach the downloaded MDF file to SQL Server (why Microsoft don’t provide a .BAK file to restore instead, I don’t know!)

To get started coding in F#, I recommend the following tools:

To learn more about F#, I highly recommend:

  • F# For Fun and Profit – F# and functional programming explained in simple understandable language – no crazy maths stuff
  • Try F# – Online syntax tutorials and in-browser compiler
  • The F# Software Foundation – The F# community hub; has links to videos, guides and commonly used libraries

F# people to follow on Twitter (obviously not exhaustive!):

  • Don Syme – The Benevolent Dictator for Life of the F# language (he is its designer)
  • Tomas Petricek – Super F# enthusiast and founding member of the F# Foundation
  • Scott Wlaschin – Scott is the author of F# For Fun and Profit

The Corporate BS Generator Windows 8 App

On my last gig my friend Mahesh sent the team a link to Tommy Butler’s simple Corporate BS Generator page, and naturally we all cracked up. For the whole day any chat over Skype was derailed with someone chucking in some random BS, for example “that’s a good idea, but does it conveniently enable visionary services?” It was a Windows 8 app gig, so we were all neck deep in WinRT and XAML, and it came to me that this would be awesome as an app for Windows 8.

Today, I’d like to announce the release of the Corporate BS Generator Windows 8 app on the Windows Store. Tommy has given me his blessing to bring the lulz to Windows 8 and Windows RT users.

Have you ever sat through a corporate presentation and been dazzled by fancy buzzword-filled phrases? Have you ever wished that you were capable of effortlessly making normal, typical and common-sense things sound slick, hip, modern and cool? The Corporate BS Generator can help you get ahead in an industry where spin, buzzwords and vagueness reign supreme.

Swipe or click your way through randomly generated Corporate BS and impress your executives at your next meeting. Your BS will sound so good that they’ll just nod enthusiastically even though they have no idea what your plan to “compellingly target future-proof synergy” actually means!

Here’s a sampling of some of the BS it generates:

  • dynamically e-enable world-class solutions
  • globally engage intuitive methodologies
  • credibly transition ethical communities
  • uniquely embrace progressive e-tailers
  • dynamically productise orthogonal scenarios
  • continually foster stand-alone supply chains

Cracked up yet? Grab the app from the Windows Store now.

Corporate BS Generator Promotional Image

Async/Await - The Edge Cases and Unit Testing Presentation

Async Await Presentation Title Slide

Tonight I gave a short presentation at Devevening titled “Async/Await – The Edge Cases and Unit Testing”. Here’s the abstract:

In this talk we'll look at the new async await feature in C# 5, but we'll go beyond the typical toy examples and look at edge cases like exception handling, task cancellation and how we can approach unit testing asynchronous methods.

I’ve uploaded the source code and slides to a BitBucket repository, so for those who want to inspect the examples at their own leisure, please clone away:

I hope to make an extended version of the talk and present that at a future user group; I’d like to cover things in a little more detail, look at the history of async over the life of the .NET Framework, cover unit testing a bit more thoroughly, and maybe even take a peek under the covers at what the compiler generates when you write an async method. Stay tuned!

Broken Process Explorer: Missing .NET Performance Counters

For a while, I've had the problem where my .NET performance counters have been missing from my system. This had the side effect of breaking Process Explorer's ability to highlight which processes are .NET processes. Process Explorer checks for the presence of the performance counters to see whether .NET is installed, and if it doesn't find them it disables its .NET process detection.

Apparently a lot of people encounter this problem, since point 31 and 32 on the Process Explorer FAQ try to address it. However, the solutions they provide have never worked for me. However, recently I figured out what was stuffing it up. If you're in the same position as me and the FAQ doesn't help you, you might want to check this out. I run Vista x64, so if you're running XP still I can't guarantee this will work for you, since I haven't looked at it on XP.

Browse to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\.NETFramework\Performance in regedit. Have a look at the "Library" value. Does it say "donotload_mscoree.dll"? If so, that's your problem. Change it to mscoree.dll and you're set. Apparently, MSDN says this about why it's not loaded:

If the .NET Framework is installed on a system that is running Windows XP, any process that uses the Performance Data Helper (PDH) functions to retrieve performance counters may stop responding ("hang") for 60 seconds when the process exits.
This delay is caused by a bug in the .NET Framework performance extension DLL, Mscoree.dll.

Hence, they recommend disabling the counters by renaming the library to donotload_mscoree.dll. That's an awesome solution, Microsoft! Why not just fix your bugs?! Luckily, they say it only applies to .NET 1.0 and 1.1, which are so old and irrelevent I wouldn't touch them with a barge pole (no generics, for christ's sake!). However, they haven't looked at this article since November 15, 2003, so maybe it still applies to .NET 2.0+. Who knows. You'd hope they'd have fixed this epic fail bug by now.

I reckon that Visual Studio or SQL Server must have made that change in the registry, because I don't have this problem on my computer at work (Java programming, so no VS). I've also always had this problem on my home machines and I've also always has VS installed on them. Hopefully, Microsoft didn't disable it for a good reason, because I've undone it now... but somehow I doubt they'd deliberately be breaking performance counters. After all, the people who actually use them are probably .NET developers and they almost definately use Visual Studio.

The state of affairs

Finally, this semester is over. Its been a long, long, semester and I'm glad that its finally finished, exams and all. As usual, I'll write up a review of the semester, but this isn't the blog for it.

Now that I've had my two 24" screens for a couple of weeks, I can formulate a proper opinion on them. Were they worth the two grand I spent on them? Absolutely. There is nothing quite like being able to work on code on one massive screen, only to have the multitude of supporting windows that I also use on the other massive screen. Highly recommended for those that can stomach the price.

It was requested of me by a peer that I illustrate the supreme coding environment that two 24" screens provides. Here is a picture showing Visual Studio (with two panels of code), MSDN and a uni project requirements PDF all open simultaneously. Don't mind all the mess on my desk (that was good watermelon and ginger beer).

The screens are so bright that they literally light up my room. I almost don't need any other lights on in the room. That said, they can be a little glaring if you don't have some other supplemental light on.

The first thing that annoyed me was the lack of a taskbar on the second screen. I wanted all the windows on the second screen to be on their own taskbar rather than junking up the single one on the main screen. A quick search later and Ultramon solved my problems. Highly recommended for those with two screens.

However, not is all sweet smelling roses in the 24" garden. One of the screens seems to have a bit of light leakage on the right edge. My last screen had tonnes of light leakage and as such it wasn't really an issue. This screen, however, has no light leakage except for this tiny bit which makes it all the more obvious and annoying. It doesn't affect standard work but during movies with dark scenes it is particularly obvious. It only affects one screen out of my two.

So, I submitted a warranty claim with Dell to try and get it replaced, fully expecting to be rebuffed. To my extreme pleasure, I was called within a day of the report and told they will send me a replacement and I can send my existing screen back with the courier that brings the replacement. Hats off to Dell. Exemplary performance. I will recommend Dell to anyone who asks me now.

But enough raving about the screens. Now that exams are over, I am planning to put a lot of time into my web development business. We are currently developing a CMS for use in a few clients' websites. Its written in PHP 5 in a fully object-oriented manner and is turning out nicely.

Aurora (the CMS) will power the next version of The next version? Yes, this design, although nice, is getting a bit tired and as such I've developed a new design from the ground up that, when the correct components from Aurora are done, I will replace this current website with. Expect a much more robust blogging system with comments when that's released. Closer to the time, I may release some screenshots.

People may say that Microsoft has grown stagnant, and certainly some sectors haven't been doing as well as was expected (Vista for example). But, as I've always said, if there's one thing that Microsoft can do right, its development tools.
They've gone and released a new web platform called Silverlight. At first glance, it seems to be a Flash-y sort of thing, but when you look closer it seems (to me at least) to be more of a platform than a media presentation format.

However, its got one main failing point at this time. It doesn't work in Opera. Works in Firefox and IE, but not Opera. Sorry guys, but until its pervasive, its not going to take off. And they realise that. Their current plan seems to be to release an Opera version "soon" (I'm hoping with the final version of Silverlight 1.1 which is in Alpha currently). At least they are bothering, which is new for Microsoft and Opera (*cough* fix all the Windows Live services while you're at it *cough*).

Silverlight seems to be a good place that Microsoft can finally use XAML. I always thought that XAML didn't seem to be particularly useful in the Visual Studio - C# world (I haven't actually used it though, so I very well might be wrong, so take that with a handful of salt). But for a web application, XAML seems to be perfect. Check out the short tutorials on the Silverlight website to see what I mean.

Another indication that Microsoft have still got the smarts, so to speak, is the new Popfly mashup creator/website creator/community that they've created, built on Silverlight. I was raving for hours after I saw this. The coolest thing about Popfly is its mashup creator. You literally drag "blocks" onto a drawing surface and join them with lines to join together services like Virtual Earth and Flickr. Its insane.

For example, (as shown on the Popfly website), you can create a Virtual Earth map that shows the location of the people who made the latest posts on Twitter. You basically drag a Twitter block (a literal cube object) onto the design surface, drag on a Virtual Earth block and join them together with a line. However, you find that Twitter provides the user's location as a name (eg Melbourne, Australia) and Virtual Earth requires latitude and longitude. So you drag on a block that converts from location name to latitude and longitude (called GeoNames). You join Twitter to GeoNames and then GeoNames to Virtual Earth with lines, tell Virtual Earth to get its coordinates from GeoNames and bam, you've got a VE map with Twitter users on it. Popfly handles all the AJAX, Javascript, Silverlight etc for you.

You can create your own blocks as well. There is a Visual Studio plugin you can download that helps you with this. You can then share these blocks on the little community thing that Popfly's got. Don't like what someone's shared? You can easily copy it, edit it and reshare the updated version!

If you need to dig a bit deeper into the code, say in the web site developer tool, or in the mashup creator, you can. And its even got Intellisense code prompting. In a web browser. Insane.

Popfly's only in Alpha so its still a little rough around the edges. But its remarkably stable. I haven't fiddled with it all yet, but what I have used has been remarkably smooth and polished. The alpha is still only in invitation only mode, but I was lucky enough to get an invite. If you hurry up, you might get one too. To see the really awesome presentation of Popfly check out their page here (you need Silverlight installed to view the movie).

Just to put a downer on all this new-found excitement, Apple released a PC version of their Mac Safari browser. Why do I hate this? Because its another damn browser I've got to now test for, me being a web developer. I've already got enough to tear my hair out with, what with Opera, Firefox and IE 6 and 7, since bloody people seem to not want to update to version IE7 (go find some statistics and see). The Inquirer has a nice article that explains why Apple dumped this pile on us and its not because they love us.

What probably makes my hackles stand on end the worst, is the fact that they tout it as the fastest browser. In fact, in typical Apple fashion, its not, but they insist on preaching to their zealot ("my life for Apple!") masses that it is. "Huh?" you say, "I've seen benchmarks that prove that it is the fastest!". Those benchmarks are probably wrong. Turns out that Safari's Javascript onload event fires before all the loading is done (unlike all other browsers who only fire onload when everything is loaded). Therefore, all the Javascript benchmarks record Safari as finishing loading before it actually does. Of course, Apple doesn't tell you that, do they? Here's the hard evidence from the guy that did the original browser benchmark.

Hell, now that I've got all annoyed with Apple, I might as well focus some rage on their zealot fanboys. A perfectly innocent ZDNet blogger wrote that the new MacOS X that is coming soon isn't too different from Vista. Although I don't agree with everything that she said (especially the part about Coverflow looking like a rip off of Flip3D), she made a lot of good points. However, she was literally threatened and abused into backing down by angry Apple zealots. She was literally told that she should "find a new career", that she "should be running a car wash in Frezno", and one of the zealots was going to complain to her manager to get her fired.

This sort of thing, people, is completely unacceptable. The Internet is not a place where you can threaten and abuse people. Its a place where you can present your viewpoint. Its okay that someone else has a different opinion to you. Its not okay to insult and threaten those other people. These people are one of the reasons why I dislike Apple. I don't want to be painted with the same brush as these spineless cowards who didn't even leave their real email address when they posted their insults so that Mary Jo (the blogger) could respond to them rationally. Here's a good rule of thumb for the zealots: if you want people to join up with Apple, try to act in a mature manner. If you need to hide your real name and email address, what you are saying is not appropriate.

Cooling down now, I am aware however, that this vocal minority of users is just that: a minority. There are plenty of rational people with Macs. My favourite lecturer has a Mac, one of my best friends has a Mac and some of my uni mates have Macs. I still am interested in Apple's progress and activities. Hell, maybe one day I'll get a Mac. But that day is not now nor in the foreseeable future at this point.

Getting back from another Apple rant (sorry, its a habit I've got to get over), let me bring this massive blog to a close on a positive note. At the end of my presentation that I gave on Monday (which went brilliantly), the marker told me about a Google presentation video that talks about tagging as a concept and kindly sent me the link in an email. It sounds boring, but in fact it was an entertaining and facinating video to watch. I highly recommend it. Here's the link. Its long (about an hour) but well worth the watch.

Especially on a 24 inch screen.

SDP Blog - Suggestions for Improvement

This is the third blog I am doing for my Software Development Practices subject.

Scintilla Text Editor, normally known as SciTE, is a light-weight text editor built for programmers and scripters. It supports syntax styling, bookmarks and some nice code editing tools such as block commenting (where you select an area of text and the editor will surround it with syntax-specific comment symbols such as /* and */).

The pain points that SciTE is probably trying to solve for its user base of programmers are:

  • Other simple text editing solutions (eg Notepad) do not support syntax styling
  • Other text editors that do have syntax styling do not allow the programmer to create a new style for a new syntax
  • Other text editors do not have tools for fixing indentation, doing automatic block commenting and changing file line-ending types
  • More comprehensive text editing solutions cost money and can suffer from feature bloat

SciTE’s main functions are:

  • The display of syntax styled source code files
  • Block commenting can be performed
  • Ability to read multiple line-ending formats (eg CR, LF, CRLF)
  • Able to fix incorrect indentation in source code files
  • Able to search (and replace) using regular expressions
  • Able to set bookmarks to certain lines

SciTE’s form is made up of the following:

  • Syntax styling properties are read from configuration files that are user-configurable
  • Syntax styling can be turned on and off or manually changed from one syntax to another
  • Runs on Windows and Linux
  • Displays multiple text files using tabs
  • Multiple windows can be opened if preferred
  • Code blocks can be “folded” (compacted into one line)
  • Displays code tips (small text pop-ups that describe a method’s arguments)

SciTE mostly solves the pain points that its users have. It is lightweight and has the bare necessities and a few niceties that any programmer or scripter wants in a text editor. It also provides an extreme level of customisability via its configuration files which let you create new syntax styling rules for languages that, perhaps, SciTE does not support by default. However, SciTE’s configuration files are where its worst failing is. Although allowing the user to change everything down to the position that the SciTE window will open at on start up, it does so through a very hostile interface: its own text editor.

Configuring an entire program via a text configuration file is difficult: you must learn the format and search through it manually, looking for the setting you want to change. If I were the one to write SciTE, I would have put effort into putting a real GUI behind the program’s configuration, especially the syntax styling. A similar editor to the one that the IDE Eclipse provides would be appropriate, where you can change keyword colours and tab settings. It would obviously need to be extended to allow the definition of a new syntax: a UI would need to be created to allow the setting of syntax rules like keywords and block delimiters.

Overall, SciTE does solve the pain points of its users. It does provide a lightweight text editor that has syntax styling and some code specific features like indentation fixing. Its configuration methods, however, leave a lot to be desired in terms of usability. It can be difficult to configure new syntaxes or change existing ones using SciTE’s text file based configuration approach.

SDP Blog - Basic Software Review

This is a blog I have to do for my Software Development Practices subject. Its shorter than I'd like and hence not particularly comprehensive but I was forced to fit it on a single A4 page or lose marks.

Software Name: Opera
Version: 9.20
Date Released: April 11 2007
Developer: Opera Software ASA
Classification: Web browser

Opera is a little known and little used web browser. That doesn’t stop it from being a gem, however. It performs the same functions as the more popular browsers like Internet Explorer and Firefox: web browsing, downloads, favourites, history and so on. It supports tabbed browsing, which is the latest “rage” in the browser market, is quite compliant with web standards, and is very fast. In fact, according to, it beats Firefox and IE in almost every speed test (on Windows).

The Opera main window

The Opera main window

Obviously, I’m not going to bother telling you about the basics of the browser, since you’re probably viewing this blog using one. These days the main innovations with browsers are in the usability and speed area. I’ll instead highlight the main features and the strengths and weaknesses of Opera.

Opera takes great strides in making a browser more usable. Sure, it’s got all the standard features of today: tabbed browsing etc, but it innovates with new ways to interact with the browser. The main one is “mouse gestures”. Basically, you move your mouse in certain patterns while holding right-click and browser performs actions. For example, you can hold right-click and then move the mouse downwards then release the click, and you open a new tab. If you do that over a hyperlink on a webpage, you open it in a new tab. You can close a tab by moving the mouse down and then right. It takes a little time to learn the gestures, but once you’ve mastered them they becomes as essential as typing. It simply is a natural way to interact.

Speed Dial

Speed Dial

Another usability improvement Opera presents is the “Speed Dial” panel you view when you open a blank tab (see right). There are nine boxes you put your favourite websites into and the box will show a small preview of the specified website. When you click the box it opens the website in the tab. It sounds simple, but like all good usability features it’s so simple and easy to use it becomes transparent to the user.

There is one large feature that Opera lacks: a robust extension system like Firefox or, to an extent, Internet Explorer. If a feature is missing in Firefox, you can simply get an extension for it. For example, you can get mouse gestures in Firefox via an extension. Opera does not support extensions, which limits it a bit in the eyes of a power user.

As a result, I favour Firefox when developing webpages, because of its superb web developer tools via its extensions, and then I use Opera for everything else since it does it better. It is “Simply the Best Internet Experience”.


  • Fast
  • Mouse Gestures
  • Speed Dial


  • Doesn't support extensions

Overall Rating: Excellent

Leave the gun. Take the Audioscrobbler.

Over the last week or so I have started scrobbling my music. What the hell is scrobbling? Audioscrobbling is where you submit the music you listen to, as you listen to it, to a central database where is it tracked. Doesn't sound so cool now, does it? That's probably why they called it audioscrobbling, not as-you-listen-music-tracking. :)

So what's the point of scrobbling your music? As you submit the tracks you listen to to the audioscrobbler main database, it watches and recommends other artists that you may like and lets you see statistics on your listening habits. You can listen to free online radio in the genre that you like best (determined by the system by looking at your listening habits).

So how do you go about audioscrobbling? They've made it pretty simple. is the place where it is all centred. You download a client for your computer which installs plugins into your favourite music player. I use Winamp (it really whips the llama's arse!) to play and manage my music, so it installed a plugin for that. When you start your media player, it starts the client software as well, which hides away in your system notification area. As you play your music, the plugin in Winamp will send what you are playing to the client software which will submit that to the main audioscrobbler database.

As you listen to your music you can tag the tracks with tags (short informative labels) which helps classify them. So for example, if you tag a track as "vocal trance" your tag gets added to the database of all the tags that everyone else has tagged that track with. The song could then (if has it) be found on the "vocal trance" tag radio. You can also mark tracks as Loved or Banned and recommend them to to other users. You do this through the client software or through the website if you're using that to listen to music.

Most of the functionality of the software can only be accessed via the website. The client is very weak, in my opinion. It lets you do standard operations such as play radio (by artist, or by tags), set tags, Love, Ban, and Recommend, but not much else. Its got a weak display that talks about the artist of the track being played and lists the track's play count, but compared to the website, it does nothing.

The website. That's where the functionality of audioscrobbling all comes together. Its a bit of a web 2.0 application, a community based app where users create the content. However, it is presented in a slish usable fashion and is actually useful, so don't blacklist it along with MySpace as an annoying, rubbishy "Web 2.0" application.

The website lets you view your statistics such as top artists listened to, play count, etc. But its best feature is its recommendations. By looking at your listening habits, the system will recommend you music to listen to. You can listen to specific tracks on the website (normally 30 second clips, but if the artist is feeling generous, the whole track) using a Flash object, or you can listen to a radio stream via a Flash object or via the client software.

You can do other Web 2.0 things like add friends, write journals, talk in forums, post in peoples' (and artists') shoutboxes. You can join groups of other users who have a similar taste in music and tune into that group's radio or talk with its members. I don't find I use those features much, other than the friends feature. Its pretty cool to be able to see what your mates are listening to right now and be able to recommend them tracks.

I find the most useful feature of the website is music discovery. It lets me find new artists to listen to and when I get bored of my current music collection I'll jump into a radio station and listen to that. I can view the artist I've found on the website and preview their music and see what artists are similar to them.

Audioscrobbling is an open protocol. You can write your own applications that use the data generated by their database, or you can write your own plugin or application to submit tracks listened to. has the protocol specifications and data feeds.

I use an iPod to listen to music on the train to University, so naturally I wanted to scrobble the music I listened to on my iPod as well. I don't use iTunes (rubbish software) and instead use Winamp + ml_ipod, which made my life a little difficult trying to scrobble my iPod music. The plugin that ml_ipod has that does scrobbling isn't compatible with the client software (the client software must be relatively new) so I couldn't use that. I have ended up using Audiopod+, a simple Java application that has a distinct "hacked together overnight" feel about it.

Its a bit of a pain to use: first you need to set it up. Launch it and set the preferences. Tick the two checkboxes to delete the playcounts after scrobbling and set it to only scrobble when you tell it to. Then you have to connect your iPod (make sure Winamp is closed), start Audiopod+ and set the path to your iPod database in the preferences. It probably won't find any music to scrobble. Close the app. Listen to some music, then connect the iPod again (making sure Winamp is closed). Start Audiopod+. It should detect the music you have played. You can then scrobble the tracks you want. Its messy and hacky, but it works.

Words of warning: note that because iPods only record the last date a track was played, if you listen to a track twice without scrobbling it you will only be able to scrobble it once. Also note that you should NOT scrobble any other music from any other source until you have scrobbled your iPod. The audioscrobbler database will not accept music submissions from a time previous to the time that the last track was scrobbled. So if you come home after listening to your iPod on the train, listen to a little music in Winamp (which gets scrobbled), then decide to scrobble your iPod music, you will not be able to. This is apparently a spam prevention mechanism.

My account is ratfink88 so if you want to give me a shout in my shoutbox go ahead. Add me as a friend and if you are a trance fan (especially vocal trance) recommend me some tracks.

"The Future's Bright. The Future's Audioscrobbler."

Tip: Check out the bottom of for a random selection of Audioscrobbler quotes like the ones I used for the title of this blog and the last sentence. Some of them are gold.

Just a Little Wibble

Bah, I seem to be attracting hardware failures of late. The new stick of RAM I bought for my laptop in June decided to up and die, corrupting my Windows installation along with it. Luckily it has lifetime warranty, so I didn't lose anything, except my patience with the sluggish remaining 512MB of "not enough" RAM and having to reinstall everything which sucks when you're a developer (it takes ages).

But let's move onto the more interesting things. What I've begun doing is having a folder in my bookmarks in Opera, and when I get a particularly interesting article I stick it in there to write about later. This should mean I will blog more frequently*.
* Terms and Conditions Apply. :)

So. The first item: Windows PowerShell has gone 1.0! As we all know, the standard command prompt and scripting offered in Windows blows when compared to Bash in Linux. PowerShell is here to rectify that. However, don't go jumping into it thinking that you can just run all of Windows from the shell. Windows is still a strongly GUI-centred operating system and you can't just run the OS from the command-line like you can in Linux. Certainly it has been touted to make Windows Server administrators' lives easier, but unlike Linux, most apps for Windows aren't written with command-line functionality or COM interfaces.

The PowerShell syntax is a weird amalgam of C# syntax with a little Bash and some weirdness thrown in there for good measure. I almost wish it was more C#ish; just some things like the equality operator being -eq, as opposed to the more C-style ==, seem strange when you are doing C# style foreach loops.

Where Bash is often centered around plain text hacking, PowerShell does it differently. When you "pipe" things around you are piping objects. Yes, PowerShell is weirdly object oriented. Kind of. PowerShell is built on top of the .NET Framework, and it shows through. Passing objects around instead of plain strings is better since different cmdlets (pronounced "command-lets", these are the commands in PowerShell) can act on the objects differently without the need of string hacking ala Bash. For example, instead of (in Bash) getting a list of files, using awk to rip out the filenames then throwing them into file, PowerShell does it by getting objects that represent the files and passing those objects to some other command which will extract the filename object property and write them to a file. Its a crappy example, I know, but I haven't spent a lot of time in PowerShell yet. :)

If you're interested, you can download PowerShell here, and read a rather good starter tutorial here. In my summer holidays I'm looking forward to fiddling around more in PowerShell.

The next item on today's agenda: threading in the Source Engine! If you don't know what the Source Engine is you either live under the "I don't play computer games" rock or you play way too much Starcraft. For you people, the Source Engine is the game engine that powers the bestselling Half-Life 2 game and has been licenced for other good games like Dark Messiah - Might and Magic, and Sin Episodes.

Most game engines these days don't properly take use of dual/quad core CPUs because they are not "multithreaded". A program that is multithreaded has multiple lines of execution all running concurrently. This means, on a multi-core computer, more than one thing is happening at once. If your game isn't threaded it pretty much means a whole half (or three-quarters or whatever) of your CPU is going to waste. So its an important thing for games to become multithreaded.

Valve (the makers of the Source Engine, oh uneducated ones :P) have started work on making the Source Engine multithreaded. This is difficult since threading can be a real pain in the butt and will require a large amount of the engine to be rewritten. There are three main ways that multithreading can be done in a game engine: in a coarse fashion, in a fine fashion, and in a hybrid fashion that uses elements from both coarse and fine.

The coarse fashion is where different game subsystems are put on different threads. Valve found this to be ineffective in utilising the entire CPU fulltime. The fine fashion is where low level tasks are split across cores. This method was also unsatisfactory since not all tasks are well suited to being split in this fashion. Valve settled on the hybrid method which pretty much means it uses the coarse fashion where it suits the problem and the fine fashion where it suits the problem. This way is the most complex but it scales well and maxes out the CPU.

What Valve has done is to create N-1 threads (for N cores on the CPU) with the other thread being the master controller thread. Valve uses lock-free algorithms to help remove the problem of threads sitting around blocking (doing nothing) while they wait for access to data (two threads cannot write to the same piece of data at the same time, that would be bad).

Multithreading in Source can only bring benefits to Source-based games. I know that currently half of my CPU (1 core of 2) sits around doing nothing when I play games, and last time I checked I didn't fork out good cash for it to be slacking! There is a full on article about multithreaded Source which goes into more detail and has a good focus on the technical side of the threading, which a lot of the other articles about this didn't.

A nice thing to hear is that Valve uses iterative development on the Source Engine (building and improving it piece by piece over time, rather than writing it and then rewriting it from scratch for upgrades) because my course at University likes to rave about iterative development. Wonder whether they do unit tests :).

And finally on today's show is a little something to back up my rant on Apple a few blogs ago. I will now degrade into IM-speak: LOFL, ROFLMAO, LOL.

Bad Apple

Apple really gets my goat sometimes. I'm not going to turn this into an Apple bashing session, because I honestly like what they make. They make a good operating system that is, in many ways, superior to Windows. Their computers are really nice looking with some nice features, especially now that they are x86 based. Their software, for example iMovie, is very nice.

But it really gets my goat when Apple acts like a spoilt brat. I only follow Apple based activities with a cursory eye, and get major overloading updates from my Mac man friend even now and again. But when I see Apple making ads like their "Mac Guy, PC Guy" ones, that really pisses me off. For an example, go watch this.

I'm going to drop an expletive here, so if you don't like that then skip a couple of words. Fuck you, Apple. Fuck you. Okay, I've got that out now. I find those ads rather offensive. Kind of like if Apple came and spat in my face. They are incredibly derogatory and worse, condescending. They completely disrespect any person who uses a PC over a Mac. In fact, it reminds me of a child who screams at their parents trying to get their attention. I'm sorry, Apple, but face the facts. You own, what?, two percent of the market? Consumers vote with their wallets and you lost 98 to 2.

Their TV ads are nothing less than straight propaganda. For example, their viruses ad. They quite correctly state that PC's have lots of viruses and Macs don't. Okay, known fact. What they fail to tell the average consumer who knows nothing of this type of thing is that the only reason Mac OS X doesn't have viruses is because no one uses it. If anyone used it, say 98% of people (*cough* like Windows *cough*), then it would have viruses.

Plus the whole PC guy, Mac guy stereotype thing. Apparently, all PC guys wear boring business suits, wear glasses, are overweight, and have bad hair. Mac users are the "cool, hip" guys. Again, I find this offensive. I'm sure there are PC users out there that look like that PC guy, but I can guarantee you that there are Mac users like that guy too. I can also guarantee you that I know lots of "cool" people who use PCs. That would be, ahh, most of the population. And really, judging people by their looks is incredibly childish. Remember the saying "Don't judge a book by its cover"?

Another thing that annoys me about the Apple ads it that they openly piss on Microsoft. Okay, Microsoft has screwed up a bit. But standing back, pointing and laughing really is a particularly childish thing to do. And that fact that Microsoft just takes it, not a word said in return. That, that simple act of not getting involved, and of not lowering themselves to Apple's name-calling level instils great respect for Microsoft in me. It draws parallels with the things you were told as a child: "If someone is being nasty, simply ignore them. Don't lower yourself to their level."

All this crap was brought to my attention by Paul Thurrott who wrote a brilliant article article about Apple's new upcoming OS X version versus Vista. I heartily recommend you read it, it really sums up my feelings about Apple. Paul doesn't support Microsoft, per se, but he sure shows that he does not approve of the propaganda that Apple generates daily and their pathetic childish attention seeking.

And the worst part is, people lap it up. People lap it up. Especially Mac fans. Have you noticed that for an Apple fan, Apple can do no wrong? A slight exaggeration would be if Steve Jobs told a Mac fan to run off a cliff, the guy would do it. Anything Apple makes is instantly legendary in the eyes of their fans. An example:
Jobs: "Hey Mac users! We want to completely change the operating system from Mac OS (OS 9) to Unix (OS X). This means none of your applications will work anymore (unless you emulate, which will be discontinued shortly)! We also are not letting you install OS X on older hardware. That's right, you have to buy our expensive upgrades! How do you like that?"
Mac fans: "Yay Steve, I'll buy a new computer just for you. You are so right in doing this!"
They are almost religious in their fanaticism.

Also notice the constant upgrades in Mac OS X. Steveo sees this as a good thing. No Steve, its not. Not when new apps are locked from running on the old OS X versions (eg iLife), forcing you to upgrade Mac OS X for a fee. If that happened in Windows, Microsoft would be shot. Notice Windows' massive backwards compatability? Christ, if Jobs started sending empty cases to users instead of computers, the fans would just go "What an innovation! Look how light it is! And it doesn't need cooling! Suck on that PC users!"

What also annoys me is the claims that Microsoft has been sitting on its butt twidling its thumbs since XP. Okay, so it screwed up Vista big time, but what about all the other stuff. For example, .NET Framework 1, 1.1, 2.0. Visual Studio 2002/3/5. C#. Just because Microsoft stuffed up making its operating system for a couple of years doesn't mean its completely useless and makes nothing good. On the contrary. .NET Framework and C# brings a whole new dimension to easy development of stable systems.

People don't realise how good they've got it with Windows. And how hard it is to make an OS like Windows in comparison to Mac OS X. Windows has massive hardware support. Mac OS X has Mac hardware only. Windows is massively backwards compatible, Mac OS X is not. Windows can run everyone's software and makes software development a breeze. Mac OS X has little software in comparison.
Windows' backwards compatibility is the thing that really limits Windows' development compared to Mac OS. Microsoft doesn't have the luxury of a rabid fan base that won't mind upgrading completely to run applications. Jeez, enough people are bitching that Halo 2 is only for Vista, and that Vista won't run well on crappy hardware. If Microsoft could throw away their current code base and redesign like Apple did with Mac OS 9 to Mac OS X, I think Windows would be freaking awesome.

Some of Apple's claims of "stolen features" also annoy me. Paul Thurrott in his article expressed that especially well. For example, Spotlight, Mac OS X's instant searching utility that they stole off Microsoft. Ok, so they got it to market first, but it was Microsoft's idea originally.

Damn, I guess this did turn into an Apple bashing session. My main point is not that Apple makes bad products, on the contrary, their stuff is excellent. But the fact that they behave like goddamn schoolchildren with their (white)lying and name-calling. I could put up with their selective information advertisements/propaganda where they don't tell the whole story. But the derogatory PC guy vs. Mac guy ads really piss me off. It just shows how insecure they are if they feel the need to drag others down around them. Their vying for attention like a short kid jumping up and down in a crowd of tall kids is nothing short of pathetic.

If you haven't yet read Paul Thurrott's article, go read it now. Its a must-read eye-opener.