My new pet project

As already announced on twitter, this year is the year of my pet project.

I'm going to develop something and, hopefully, will be able to release it this year. I can't tell you much about it at this stage, but the main idea is to create some developer tooling where I couldn't find anything useful on the market up to now and of course to try out new things and stuff.

I also want to improve my personal process of development with some experiments during this project. The first will be to set up all required infrastructure I consider important for such a project.

During my efforts I want to inform you about tools and techniques I use during this experiment, so stay tuned for more.

This game has to be made: Elite: Dangerous

<Update> The Kickstarter reached it's funding goal, and also the stretch goal of 1.4 mio GBP for a Mac version. With a few hours to go it's still possible to accomplish the 1.5 mio stretch goal for 10 additional playable ships. </Update>

There is currently a Kickstarter by David Braben to create a sequel to the lengendary Elite computer game. I want this game, and so I want to point some additional people to this kickstarter. Now here's my personal story why.

When I was a kid of about 8 or 9 years (in the late 80ies), we regularly visited my uncle and aunt in the black forest. In this house lived a young guy that had an Amiga and played Elite, and I was allowed to play it. That was my first contact. Whenever we visited, I played my own commander and eventually I made it into the second galaxy on his Amiga.

We moved there a few years later on, and that guy moved away. In the early 90ies I found out that someone in the next village had a copy of the original PC Elite, which I bought from him. It is still in a good condition (even though I don't have a 5 1/4" floppy drive anymore to read the disc). See this picture I just made:

My copy of Elite for PC
My copy of Elite for PC

I loved this game, played it through various galaxies and even blew away some Thargoids.

Until now, there are some games that try to resembly the original elite.
I'm not talking about the two more or less official sequels Frontier ('Elite II') and Frontier: First Encounters. They were in the spirit of Elite (David Braben, one of the original Elite programmers, was the head here), but I personally disliked the way too realistic physics. More than a few times I ended up drifting into endless space with all the fuel used in what one would call a dogfight. I'd call it turn, burn fuel to change direction to the target, fire a few times by passing through it, turn, burn fuel etc - until one of the ships eventually runs out of fuel or gets hit.

Frontier and Frontier: First Encounters were a nice idea, but totally failed by being too realistic in physics.

What I liked to play too:

  • Wing Commander: Privateer
  • Freelancer
  • All parts of the X - Series
  • EVE Online

In my opinion the X-series games from Egosoft (a german game studio) are very good in resembling the old Elite feeling. Especially that one can build his own space stations, produce goods, own multiple ships and have them fly on auto pilot to trade is a very nice idea and I love to see the next part X: Rebirth on a totally new game engine.

Eve is a very good massive multiplayer game, but the dogfight capabilities are very limited and I really miss the pilot's perspective from the cockpit.

Nevertheless, the original Elite with his legendary ships like the Cobra, the galaxies you can level through (without jump gates like in X) and the whole feeling of total freedom is unique, and I'd love to see a sequel.

So I backed Elite: Dangerous in the hope that David Braben won't mess up the physics again and I really do hope that they get the missing 200 Pounds in the next few days.

I'm a proud backer of the Elite: Dangerous Kickstarter, and I say: This game has to be made.

Windows Server 2012 – First impressions

I thought I could play a little bit with Windows Server 2012. Said that, I logged into my Windows Azure management portal and created an extra small VM with Windows Server 2012 on it.

A few minutes later my VM was provisioned and ready. The virtual hard disk is sized to 30 GB and fits in the free storage that is part of my MSDN subscription. The VM already had a remote desktop endpoint configured and I added a new endpoint for port 80. I then logged into the VM.

At login, the server automatically started the server management application on the desktop. The new console in the 'Modern UI' style (heck, I propably stick with Metro forever), so, the Metro UI console is very clean and lean. With a few clicks the web server role was added and installed.

Even with only about 765 MB of ram the server runs smoothly and fast. The new task manager gives a lot of additional information compared to the old one, and the server manager dashboard hints directly to potential problems.

At a first glance, the system seems very capable and I think it's worth spending some more time with that VM.

The ‘Apache on OS X Mountain Lion’ problem

Whoah, I just dived into severe problems with the apache web server on my MacBook Air, running OS X 10.8 - Moutain Lion.

In preparation of my sessions "JavaScript" and "HTML5" at the EKON 16 conference in november I wanted to set up the web server that is in fact included in the OS X installation.

In previous versions of OS X there was a 'Web sharing' option in the system preferences, but this was removed in Mountain Lion. There are several posts out there in the wild showing how to manually enable apache and PHP. I found this instruction on the intertubes and read (but not exactly followed) it.

In my megalomania I went: "I already did that, it can't be that difficult now. Lets go." (several years ago I set up apache with PHP 3.something on a Linux system).

So this is what I did:
I skipped the first part of the instruction (starting apache) and directly went to the part where I enabled the user-specific /Sites directory. I set up the directory with all required options, allo/deny rules etc. and THEN I tried to start the web server.

Guess what? It didn't work.

So the next thing was to look for the error logs (remembering I once had experience with Linux and error logs were a good hint on where to look for my stupid errors). Sadly, the error log folder was empty. So I double-checked the apache config for alternate log folder configurations - and found none.

A experienced apache administrator would guess that there is something wrong with the config file itself, so that apache would not even know about a configured error folder to put its logs into - but I again needed to search for starting problems with apache: Port already taken? Nope. Wrong host name? Nope. It was quite a bit of trial and error until I found this blog post about troubleshooting apache on Mountain Lion. It hinted me to this little command:

sudo bash -x /usr/sbin/apachectl -k start

Starting apache this way prints the messages directly onto the console - and so I could see where apache failed to start. It was in the user-specific /Sites config. The problem was a simple typo in the closing tag (I hacked in 'diectory').

So far, so good. Apache launched, my user website worked at my http://localhost/~Sebastian url - but it responded with a 403 - 'Not authorized' every time I accessed the folder. Strangely enough, it delivered files when I directly navigated to them (i.e. localhost/~Sebastian/test.html).

In several other attempts I found that the default configuration for the root folder disallowed directory listings and did not allow overwriting this, and how to enable PHP (that commented out entry was hidden very well).

Struggling with apache configs distributed to several locations, unix command lines, nano and a extremely bloated apache documentation I am really grateful that I usually work with IIS in my day to day business. Gladly I don't have to set up mod_mono on my MacBook Air (yet).

Ask a Ninja: Do I need Typescript?

If the .Net Ninja would have been asked this question, this would be the answer:

A few days ago Anders Hejlsberg showed a new thing currently brewing in the Microsoft labs: TypeScript.

TypeScript is:

  • JavaScript
  • + some (optional) language extensions
  • + a Compiler (more of a extractor, in fact), that removes the extensions and throws out vanilla JavaScript

The compiler itself is also written in TypeScript, so it can be compiled down to pure JavaScript and run wherever JavaScript will run too.

So, now that we know that TypeScript is a mere superset on top of normal JavaScript - what is in these additions that could be interesting?

  • Strong typing
  • Classes
  • Interfaces
  • Simple inheritance
  • Modules

Well, in fact that's pretty much it. With some annotations in Pascal-Style (that is, colon + type identifier) you can define that a specific variable, function argument or function return value needs to be of a certain type.

var testFunc = function(arg1: string) { return "Argument was: " + arg1; };

Now the TypeScript compiler knows that only strings should be passed into the function assigned to testFunc. And it can infer from the input argument and the operation within this function, that the return value must also be a string. Now, when you try to pass i.e. a number into this function, the compiler will warn you about this, and the same goes when you want to add a number to the return value of this function.

Actually not only the compiler, but also the full IDE support in VisualStudio will highlight this as a potential problem. Also the IDE is so smart to restrict your Intellisense autocompletion to valid types only. These simple annotations are a big player in making JavaScript a bit safer when working with different types.

TypeScript also allows you, to annotate external libraries like jQuery, Prototype, Qooxdoo etc., and it comes with some of them already pre-annotated to give you a head-start.

The other interesting thing is that the way of modularizing the scripts sticks strongly to what is currently proposed to become the next EcmaScript 6 standard. Of course this is only a specification draft by now, and will take some time to be finalized, and it is not sure if the specs will stay this way forever, but this way it is very likely that what you learn with TypeScript can be used in the future for vanilla JavaScript too.

Ask the Ninja: "So, do I *need* TypeScript?"
Ninja says:
Need as in totally and absolutely required? Of course no.

TypeScript is an addition to JavaScript that, if used correctly, can help you avoid some nasty bugs. And only, if you are a fan of strong typing and come to JavaScript from other strong typed languages on the .NET or Java Platform or even from Delphi. Then TypeScript is targeted for you!

When you already are a happy JavaScript developer and make use of the dynamic typing features of the language, switch prototype chains on your objects as required and love applying and removing things at run-time, then there is nothing in TypeScript for you.

The Robocopy exit code and MSBuild postbuild error problem

The recent blog post of my friend Jeroen Pluimers about "Robocopy exit codes 0 and 1 usually mean success" reminded me of a problem I had with this fact a few years ago.

Robocopy behaves strange...
Just to sum his blog post up again: Robocopy returns exit code 0 if it successfully had nothing to do (i.e. all target files were already up to date), and returns with exit code 1 if it successfully copied something. Values larger than 1 hint to a potential problem while values equal or greater 8 indicate failure. In fact, the return values are a bit mask and only values that have bits 4 or 5 set indicate a real error situation.

... and doesn't go well with MSBuild
Now, since exit codes other than 0 mean success and 0 is in fact pretty seldom, only indicating that nothing had to be done, robocopy is a very problematic thing to call in your MSBuild pre and post build targets.

MSBuild interprets the exit codes of the pre and post build calls and if something is not okay, the whole build process errors out. And 'not okay' for MSBuild is any other exit code other than zero. So, when robocopy tells the caller "Hey, I copied your files and was successful in doing that: 1!", MSBuild goes and reads: "1? Oh darn, something went wrong. I need to abort".

What to do about that?
To solve this problem, there are - like so often - many ways.

First of all, the not-so-elegant solution would be to wrap the call to robocopy into a custom batch file (.bat or .cmd). This in turn would call robocopy (just pass through all arguments one to one), examines the return code and if robocopy inidcates success (probably even with codes up to 7), calls 'exit 0' itself. In any other case it could write a better condition on the console and exit 1 to indicate an error. See this table (also mentioned by Jeroen) for the list of conditions. This is not-so-elegant because you won't get more detailed information about error conditions than what your script returns and it is not very easy to configure. The even worse solution would be, to hard code the files to copy in your batch file, so that whenever your project changes in what to copy, you need to update your file.

Then there is the question, if calling the external robocopy is required at all. You can do a lot with the normal copy task that ships with MSBuild. It allows you to copy multiple files to multiple locations, do hardlinks instead of copying, check if the destination is newer and don't copy then and a lot more. You also can control the copy task much more easier using simple item groups and properties in msbuild so that you simply could add files to your copy task by adding some meta information to your project files.

If you really, really need to rely on robocopy because you need it's even more advnced features, then there is a full-featured MSBuild task wrapping the robocopy calls in a MSBuild-ish way in the MSBuild extension pack.

Conclusion
As so often, a tasks that seem so easy brings up some unexpected problems and strange error messages. Even besides the three options mentioned above, there are of course a lot of other possible ways to achieve what you need to copy from your MSBuild project. This post is merely an explanation of the root cause of those problems and a hint on what you can do to avoid the problems arising from the strange error-code behaviour of robocopy.