March 25, 2014

Finally I can code on my way to work...

I have a Windows Phone and I love it. Sure, there are a bit fewer apps and in Sweden only one phone company has the Nokia 1520 as a phone of choice. The 1520 is a big phone, most people actually question if its a phone or a tablet when they see it.

For me that is a perfect size.

It barely slips down in my pocket and it is big enough to be used as a small tablet.
When I then discovered TouchDevelop a few weeks ago everything came together. I could finally do some serious coding on my phone!

So... what is TouchDevelop?

It is a programming language by Microsoft Research that lets you create software by clicking. It is made for developing by touch and it lets you use your programs on a windows phone, iPhone, iPad, android phone or tablet or on your PC.

What is it not?

Even though the tutorials use the LOGO-turtle it is not a simple language. TouchDevelop has a lot of power under the hood and it takes a while to get in to. You could use the language to do just about anything, but the more complex the task is the more you would wish that you made it in c# instead. It is simply a perfect tool for quick hacks or games that needs to run on your phone.


So over to the case:
I am a bird watcher and I travel a lot. To be able to recognize birds I need to learn their sounds. This is seriously boring and I usually end up with listening to a couple of songs and then giving up.
This time it should be more fun to learn sounds so I want to create a bird quiz-application on my phone that plays a sound and gives me a number of birds to choose from and in the end gives me a percentage on how many correct answers I made so I can be proud of the results.

Since I only have bird songs in my song list on my phone the first step would be to play a random song.

It is a simple task but it is something that still would take some time to do in a traditional language (c#).

In TouchDevelop this would look like this:

action main()
      var mysongs := media→ songs
      var chosensong := songs→random
      player→play(chosensong)
end action

Just run this and a random song. And all this by clicking on your phone.

To be continued...