In this chapter, we will try to understand the three important aspects that make up Windows Phone Development using F# (pronounced as F sharp), namely:
What is Windows Phone?
What is F#?
Prerequisites for development
We will go over these aspects, one by one in the coming sections.
Windows Phone is the new mobile operating system from Microsoft Corporation and was launched in October 2010. After the initial release, there were a series of updates to Windows Phone with the recent one being Windows Phone 7.5 (Mango).
Windows Phone has the tagline "Put people first", and is mainly aimed at consumers or end users. Windows Phone is the successor to a previous version of mobile operating system from Microsoft known as Windows Mobile. Windows Mobile was an operating system designed around the Windows CE (Compact Edition) kernel. Windows Phone, being a new platform written from scratch, is not compatible with the earlier versions of Windows Mobile, that is, it does not support backward compatibility. So applications written for Windows Mobile won't run on Windows Phone. Windows Phone and Windows CE are just two different mobile platforms available at present from Microsoft.
The biggest problem that application developers for mobile platforms faced was the varied range of development environments they had to adapt to. The mobile development environment was completely different from those compared to either a desktop application development environment or a web application development environment. Though some development environments like Microsoft Platform, which includes developing using the popular Integrated Development Environment (IDE) Visual Studio and languages like Visual C++ or Visual C# were, to some extent, similar.
But, one had to face the challenges of handling different form factors, device capabilities, hardware differences, and other incompatibilities. With Windows Phone, Microsoft has made sure that it provides a common design and a common set of capabilities for devices from many different manufactures. So be it any device from any manufacturer, as a developer we only have one set of design and capabilities to tackle. This makes it easier for the developers to concentrate on their application and not worry about any other nuances.
The following image from http://msdn.microsoft.com/en-us/library/gg490768.aspx shows the various features a Windows Phone has to offer for both developers as well as consumers:
Windows Phone Application Platform is built on the existing Microsoft tools and technologies, such as Visual Studio, Expression Blend, Silverlight, and XNA Framework. The learning curve for developing Windows Phone Application is minimal for anyone who is familiar with the tools and technologies on which the platform is built. Windows Phone Application Platform provides two main frameworks for development. They are:
The platform itself is made up of four main components. The following figure from http://i.msdn.microsoft.com/dynimg/IC513005.jpg shows the components of Windows Phone Application Platform:
In this figure we have:
The components of interest for any developer are runtime and tools. Runtime because that's the base on which applications are developed. Tools play another major part in the development experience. Visual Studio and Expression Blend try to enhance the development experience by providing features that makes a developer's job easy while developing. Visual Studio in particular is a well-known IDE, which lets you create, debug, and deploy an application without having to go out of the IDE.
All phases of the development can be achieved staying within the IDE and this is the biggest experience one gets when on this platform. Expression Blend makes visual designing very easy as it allows the drag-and-drop capability on the design surface. When designing in Blend, you just set a bunch of properties and the code is automatically written by the Blend for you.
F# is a .NET programming language. F# was initially started as a research project at Microsoft Research Lab by Don Syme. Later, it became a mainstream .NET programming language and is distributed as a fully supported language in the .NET Framework as part of Visual Studio.
According to Microsoft Research, F# is:
A succinct, expressive, and efficient functional and object-oriented language for .NET that helps you write simple code to solve complex problems.
F# is a strongly typed language; it uses the type inference. Since it uses the type inference, programmers need not declare the data types explicitly. The compiler will deduce the data type during compilation. F# will also allow explicit declaration of data types.
Visual Studio 2010
Windows Phone Software Development Kit 7.1
Windows Phone Project and Item Templates for F#
So let's take a look at these one by one.
When you install Visual Studio 2010 (Professional or Ultimate) and choose the default options during installation, the installer will, by default, install Visual C#, Visual C++, Visual Basic, and Visual F#. This is by far the easiest way of starting to develop with F#.
The Software Development Kit (SDK) provides us with the tools needed to develop applications and games for the Windows Phone platform. The SDK can be downloaded from http://gnl.me/WPSDK71. The SDK installs the following components on your development system:
Microsoft Visual Studio 2010 Express for Windows Phone
Windows Phone Emulator
Windows Phone SDK 7.1 Assemblies
Silverlight 4 SDK and DRT
Windows Phone SDK 7.1 Extensions for XNA Game Studio 4.0
Microsoft Expression Blend SDK for Windows Phone 7
Microsoft Expression Blend SDK for Windows Phone OS 7.1
WCF Data Services Client for Window Phone
Microsoft Advertising SDK for Windows Phone
The easiest way to get up and running is to utilize one of the project templates available through the Visual Studio Gallery. These templates have been created by the F# community and they provide a great way to kick-start your project. Daniel Mohl, an F# Most Valuable Professional (MVP) has written a couple of Visual Studio templates that will help us to quickly get up and running with Windows Phone development using F#. You can download any of the following available templates based on your needs. The templates and URL from where you can download them is as follows:
F# and C# Windows Phone App (Silverlight) Template: http://gnl.me/FSharpWPAppTemplate
F# and C# Windows Phone List App (Silverlight) Template: http://gnl.me/FSharpWPListAppTemplate
F# and C# Windows Phone Panorama App Template: http://gnl.me/FSharpWPPanoramaAppTemplate
F# XAML Template: http://gnl.me/FSharpXAMLTemplate
In this chapter you learned about Windows Phone as a new mobile platform. We looked at how Windows Phone Application Platform offers a standardized platform for developers. We also looked at several features that Windows Phone provides.
Then we looked at a new functional programming language in .NET framework called F#. F#, which started in Microsoft Research Lab is now a mainstream .NET programming language.
After understanding Windows Phone as a platform and F# as a language, we then looked at the prerequisites that are required for developing applications for Windows Phone using F# as the language.
In the next chapter we will take a look at the different project templates we downloaded. We will go in depth into each project and understand the various components of each project.