Introduction
Why should I use Silverlight? Why does Silverlight stand ahead of all other technologies?
Well!! When I began to write small applications using Silverlight, there were many questions in my mind.
Why do we use Silverlight? What would be the reason for Silverlight when there is ASP.NET, Windows apps, and the latest WPF.
I am trying to resolve these conflicts over here.
As per my working knowledge, Microsoft released ASP.NET and the Windows Application platform. It was a great revolution for the web and the internet world.
Windows applications are called thick clients and an ASP.NET Web application is called a thin client. Since a Windows application will be installed in the client machine, it is called a thick client. Whereas in a web application, there is no installation required on the client-side.
But, there were two problems the company/developer faced.
- They needed to maintain two versions for Windows and web applications. i.e. the company has to maintain two versions of the same application. Because some clients want the same application in both a Windows version and a web version. So, it becomes a great headache for companies and developers. Since it was taking not only time for the UI design/Application layer but also for code-behind work.
Even though Ajax is a superb concept adapted to ASP.Net for animation like some of the visual effects, still there was difficulty achieving the same UI types for both web and Windows Applications.
- Since there is a need for two versions of applications, there is a maintenance problem.
So later Microsoft came up with a new technology called "WPF". WPF was introduced with a new style of markup language called XAML. There are two types of applications; one is Web browser WPF and WPF application. A WPF web browser app runs in a browser and works as a web application and the other WPF application works as a Windows application. So a developer can use the same XAML for both versions.
The look and feel of both versions are the same and it provides a rich UI better than a normal ASP.Net and Windows application.
But, again there was a problem; that is, again the company/developer must maintain two versions of an application:
- Web browser WPF.
- Normal WPF (as Win form).
So, again Microsoft came up with a new and robust technology called "SILVERLIGHT". Silverlight falls in between thin and thick client concepts.
So, in Silverlight Microsoft has introduced Silverlight applications and Silverlight out-of-browser applications. Silverlight as an out-of-browser application provides the same effect as Windows applications. Even though its run's under the sandbox and doesn't have full pledge permissions as in Windows applications, still it has some of the permissions to access local resources.
So, there is no need to maintain two versions of applications. Any Silverlight application can be converted into an Out-Of-Browser app and as well as revert it into a web app. The app will have the power of the desktop but delivered by the web.
Next, let me cover some more extra futures of Silverlight:
- Smart client
Already I have explained the smart client concept in my previous articles.
A smart client is nothing but, the application will be installed on the client, and whenever the application launches, downloads the latest and also is able to handle online as well as offline with the help of a local DB.
- Service-oriented business applications
- Socket Programming.
One of the most important things is socket programming in Silverlight. First of all, what are sockets?
Silverlight has built-in support for sockets which creates really very interesting possibilities.
Suppose, if I need to update on the client-side for each update in the server, then probably I should go for polling.
In this polling, the client contacts the server for each regular interval of time to get the updates.
Even though there is no update on the server, still the client checks for updates. So, this could cause a traffic overload or unnecessary server round trips.
How would it be, if there is a system which sends the updates from the server whenever the data is changed?
In this case, sockets are relevant. So, sockets are nothing but, a listener server to listen to clients.
By using this socket, a client can send data to the server as well as the server can send data to the client. So, it is a two-way transaction or duplex mode.
The .Net framework supports sockets in the namespace "System.net.sockets".
I will explain about socket programming in the next chapter.
- While operating outside the sandbox of the browser.
There are some restrictions for the web application so that they can not get round in the browser because of security. We can't access the system, can't write the user's disk except for cookies and HTML 5 offline storage. Also can't access devices connected to the user machine.
By using a Silverlight Out –of – Browser app or elevated trust these restrictions can be lifted.
- When an application needs to look exactly alike in all platforms.
There is no guarantee on HTML5/web applications about rendering over different browsers. So, if you want a pixel perfect app, then Silverlight would be the better option.
- When there is a need to support multi-touch.