Thursday, July 23, 2015

WPF is dying - Time to focus on HTML+Javascript+CSS based desktop development

"Long long ago when browsers were only used to show documents and text delivered from servers, there was a technology called Silverlight which was released by Microsoft to compete with another technology called Flash. Flash was used to add some flashy animations into static web contents and to play video and audio files..."

This must be a story I will be telling to my son when he wants me to tell technology stories. As everybody knows Silverlight is now dead though Visual Studio 2015 is still giving project template. I was one of the developers who learned and developed from the very first preview version of Silverlight itself. Also successfully run a blog called Silverlighted Web and earned so much money with my Silverlight skill. What caused SL to die? 

It was simple as the gap was filled by HTML5. Silverlight / other RIA technologies were kind of workaround to achieve Rich Internet Apps because HTML, till 4th version was just for content / document markup, not for applications. Once HTML5 came with capabilities to develop applications , obviously RIA technologies were all dead including Silverlight, Flash etc...At least in case of Flash , Adobe announced officially and provided migration to HTML5. MSFT is still not announced SL is dead.

When HTML5 arrived, smart people foresee the death of Silverlight and moved to HTML5. But there were still people who believed SL will live longer and MSFT will invest on it because their Azure Portal was using Silverlight. Microsoft is a group of smarter people than us and all of a sudden they launched their Azure portal in HTML5 and slowly ditched Azure SL portal.

Lets come back to WPF. There were speculations on WPF is going to die when Microsoft first announced that we can build Windows 8 desktop apps using HTML5 & Javascript. There were people who argued MSFT won't kill WPF because Visual Studio & Expression Blend are built using WPF. There is a road map published in .Net MSDN blog as well. According to me there are less chances that anybody will maintain a technology only because of one product.

Yes, Microsoft cannot rewrite Visual Studio using other technology between 2 versions as its desktop application and there are many plugins out there. It was different with Silverlight based Azure portal as it was web, single instance and nobody had written plugin on top of it.

Am I telling that Visual Studio is rewritten using some other technology which eventually kill WPF

Yes it is happening, but as small pieces here and there. First Visual Studio Online came. We can use it to manage our TFS projects. We can do all most all the project management activities which we were doing from VS desktop app. Only thing pending is writing code, compiling & debugging. People can argue VS desktop is for coding and debugging only. So what is the problem?

The big thing happened during the Build 2015. MSFT announced something called Visual Studio Code. What is it and what is it for WPF?

According to wiki, it is a source code editor for Windows and Linux and OS X. What is the distance between source code editor and IDE? Its simple as Compile, Run and Debug capabilities. That can be done using VS Code also. They says its "Code Editing. Redefined". Why they call it as VS Code? Why the existing Visual Studio is not enhanced to 'redefined code editing'? Why they are calling it as VS Code, a separate name? Is it only because, it can run on other operating systems such as Linux and OS X.

According to me, MSFT is once again showing that HTML+Javascript+CSS is the future by introducing a Electron based Visual Studio. Don't get shocked on hearing the new redefined code editor aka Visual Studio from MSFT is based on Electron  which is an open source cross platform technology for desktop application development using web technologies(HTML,Javascript) from Github which depends on Chromium. Yes the same technology powering Chrome browser from Google.

Electron has high degree of customization (hackable to the core) as an editor. Chromium is really stable with its multi process model. Its all proven and now we can see, VS Code download link in the VS 2015 page.

Is there any more proof required to understand, HTML5 based VS Code will replace existing WPF based Visual Studio? We probably will see VisualStudio online providing us a web page where we can write code, compile and debug in next 5 years along with its current project management features.

Will .Net platform survive the boom of Javascript and Microsoft's journey to become hosting company? Will write another post on the same

This will be my last post on this WPF technology blog. This is the blog I will surely write posts on WPF as and when I encounter interesting scenarios. But those will be published in my General Technology Blog.

Joymon v/s Code

Don't argue that I am writing all these because I want to focus only on one blog. It doesn't make any difference posting here or there.

Thursday, July 31, 2014

MVVm views without C# code behind file

The MVVm is a great technique for separating the concerns. If we take ASP.Net MVC we can see it is built for using model view controller model. So by default wont allow us to write code behind for the views (We can write inside the cshtml though). But WPF as the technology was not built to use WPF to there is no in-built way to avoid the code behind of views. 

If the development team is so technology focused, it doesn't matter as they won't break the rules of MVVm even if there is code behind file. But since companies are offshoring to get cheap labor, enforcing quality is little tricky. As always cheap things comes with less quality. Most of the time people's priority is to get things done in quick way ie by writing everything in code behind instead of going through viewmodel. 

The challenge here is how to bring quality with these less skilled labor? One of the way to enforce viewmodel  usage is to delete the code behind of views which is nothing but the user controls.

If we just remove the usercontrol.xaml.cs, it will fail as the Initialize method is missing. So how to overcome is?

Add the Initialize method in the view itself. Yes we can write C# code in XAML. So the view user control will look as follows.

<UserControl x:Class="Joymons.MVVmDemo.Views.MainView"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
            xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <x:Code>
        <![CDATA[ public MainView() { InitializeComponent(); }]]>
    </x:Code>
            <TabControl ItemsSource="{Binding ChildVMs}" SelectedIndex="0">
                <TabControl.ItemTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding Header}" />
                    </DataTemplate>
                </TabControl.ItemTemplate>
            </TabControl>
</UserControl>

I too started using VS 2013. That is why a black background in the code :)