With the invent of .NET and C#, Microsoft had already started a new era of programming which swept away the programmers world wide. And now by introducing Longhorn, the codename for the next version of Windows operating system and Longhorn programming model, Microsoft has proved its seriousness and dedication to the programmers and the programming world. In this article, I will discuss some of the key pillars of Longhorn programming model.
Longhorn Programming Model
Before we look at Longhorn programming model, let's take a quick look at current programming model in Windows. In Windows, we can write two types of applications - Windows based or Web based. In .NET, usually we use Windows Forms to write Windows applications and Web Forms (ASP.NET) to write Web applications. However, both of these technologies, i.e., Windows Forms and Web Forms are designed to solve different types of problems and there is no way one can share one with the other. Before you start an application, you must decide if you are writing your application for Windows users or Web users. In Windows application, we develop an application and deploy it on a client machine with every component it requires to run successfully and in a Web application, we build and deploy the application on a Web server where users can access the application via a URL. Now there are some limitations in both approaches such as a Windows application must be deployed on the client machine every time you makes any changes to the application and Web applications can only be accessed via a browser.
In today's date, there is no way to build a common application, that can serve both Windows and Web users. This is where Longhorn programming model comes in the picture, which allows Web users to access Windows applications and vice versa. In other words, you may be writing a Web application which can be used from a Windows client (without browser) or you may be writing a Windows application that can be used by a Web user. Not only that, it also allows developers to write a common application with all features of both of the worlds.
Longhorn programming model has these pillars:
- Longhorn SDK
- Avalon
- XAML
- Indigo
- WinFS
Note: All code written in Longhorn using Longhorn SDK is managed code and the operating system fully supports it without any additional installation.
Longhorn SDK
For Longhorn developers, the Longhorn SDK can be thought as a .NET SDK for .NET developers. It consists every component required to build, manage, and run Longhorn applications. Longhorn SDK is a part of Longhorn operating system. Similar to .NET SDK, the Longhorn SDK is available for a separate download for Windows XP and Windows Server 2003.
Avalon: Way to write UI Applications for Longhorn
Under Longhorn programming model, the presentation layer development (client application development) that used to be Windows Forms is called Avalon. Besides the capabilities exists in Windows Forms, Avalon adds many new features to the system. A few of these features are addition of a new markup language, Extensible Application Markup Language (XAML), and support for both Windows and Web applications.
The class model of Avalon is totally different than Windows Forms. In the current version, the root namespace for Avalon development is MSAvalon and then sub namespace are like MSAvalon.Windows and MSAvalon.Windows.Controls. Again, Avalon is a part of Longhorn library which is common for all programming language that supports Longhorn.
XAML: A New Scripting Language
XAML (Extensible Application Markup Language) is a new scripting language based on XML that allows Longhorn developers to build and managed UI applications via scripting. If you remember Windows Forms model, the settings of a Form and its child controls were used to store in a .cs file with all the attributes of the Form and controls. Now, all these attributes can store in an xaml file and that can run without any additional code. For example, the following code shows how to create a Form with a button saying "Hello, C# Corner".
<?xml version="1.0" standalone="yes"?>
<Window>
<Button>Hello, C# Corner</Button>
</Window>
To run this code, simply type this code in a text editor, save as xaml extension and double click on it. Of course you have to install Longhorn SDK on your machine if you are not working on Longhorn.
Similar to the above sample code, XAML has tags and attributes for every possible Windows control. You can also embed your code (C# or VB.NET) in an XAML file.
Indigo: Way to build Connected Applications for Longhorn
Indigo is an umbrella that covers all the technologies used to build connected applications in .NET. If you think about technologies used to build connected application in .NET, you will see .NET Remoting, XML Web services, COM+ services, and MSMQ. In Longhorn model, all these technologies are under a single name and that is Indigo.
For developer, who do not use Longhorn operating system, Indigo will be available as a separate download for Windows XP and Windows Server 2003. Indigo, also supports smooth migration of existing connected applications and services.
WinFS: The Smart File System
WinFS is the codename for new file system used in Longhorn. Unlike previous file systems (FAT32 and NTFS), WinFS takes advantage of database and XML and stores files and their metadata in a database. WinFS not only stores files but also stores metadata about the files which is accessible to the users from the Windows interface as well as programmatically. By having control on the file system metadata, the users and developers have more control on files. For example, you can search for the files they were written by a particular user. Not only the author, you can also query based on dates, file types, title, size and so on.
Longhorn Frequently Asked Questions
1. What is Longhorn?
Longhorn is the code name of next version of Windows operating system added in the series of Windows XP and Windows 2003 Server.
2. Can I write Longhorn applications without Longhorn?
Yes. To write and run Longhorn applications, you don't have to install Longhorn. You can write and run Longhorn applications on Windows XP, and Windows 2003 Server operating systems (not prior versions of Windows). To write and run Longhorn applications, you must need Longhorn SDK (the library you need to write and run Longhorn applications), which is a part of Longhorn operating system. Not at this time but eventually Longhorn SDK will be available as a separate download for Windows XP and Windows 2003 Server operating systems.
3. What do I need to write Longhorn Applications?
To write and run Longhorn applications, you must need Longhorn SDK (the library you need to write and run Longhorn applications), which is a part of Longhorn operating system. Not at this time but eventually Longhorn SDK will be available as a separate download for Windows XP and Windows 2003 Server operating systems.
4. What is the System Requirement for Longhorn?
At the time of beta 1, Longhorn requires 2.0 GHz processor and 1 GB RAM, in addition to ton of GB of hard drive space.
5. What is Longhorn SDK?
Longhorn SDK is a set of API (the library) that defines all the classes available to programmers to write Longhorn applications.
6. What Languages can I use to write Longhorn Applications?
At the time of beta release of Longhorn SDK at PDC, it supports C#, Visual Basic .NET, JScript .NET, and XAML. Eventually, more language compilers will support Longhorn development.
Summary
In this article, I covered the pillars of Longhorn programming model briefly.
References:
- Introducing Longhorn for Developers, by Brent Rector, Microsoft Press.
- MSDN Documentation
- MSDN Magazine