Thursday, January 30, 2014

WinForms are dead... long live WinForms!

After Microsoft's introduction to WPF, a lot of .NET programmers started to announce "the death of WinForms". But is that really true?

WinForms is a GUI API that exists since the beginning of the .NET framework, it is almost identical to the MFC C++ GUI API, and it is immensely similar to other GUI APIs of other programming languages (AWT - Java, SWT - Java, Qt -C++, wxWidgets - C++). It's quite easy to learn, a lot easier to understand its concepts, and it can help you move to other languages' APIs. Yet, Microsoft decided to abandon its development in favor of the WPF API. So one would expect a lot from WPF. But is that the case?

WPF is the new GUI API from Microsoft, that makes a better use of newer technologies in graphics rendering (DirectX instead of GDI) and tries to enforce the separation of the UI logic and the business logic in an application. Sounds really great, right? Well, lets see the way it does it. WPF somewhat resembles HTML, it uses a descriptive language (XAML), which is an XML-ish format that describes the UI elements and also allows developers to do inline data bindings in UI controls, which then renders it on the screen, using DirectX subsystem. Unfortunately, Visual Studio's WPF designer is not really easy to use, unlike its WinForms designer which is really a breeze, XAML is not as easy as WinForms in constructing a complex form consisting of a lot controls and events, and in general WPF is a lot more difficult to learn and master than WinForms. Also, though one would expect a better performance in GUI rendering due to its use of DirectX subsystem, unfortunately that's not the case, especially in older PC configurations. So why use WPF at all?

WPF allows more freedom to the developer in creating UI elements, it does make the code cleaner and neater, and it is constantly being updated with every .NET framework version update. But why oh why, did Microsoft stop updating WinForms? A lot of existing enterprise solutions are based exclusively on WinForms, they are faster, easier to learn and allow extremely rapid development. I guess it's due to Microsoft's desperate attempt to promote its new ecosystem of Operating Systems, Windows 8 and Windows Phone 8, and increase the count of applications in its AppStore.

I personally believe that Microsoft did not think this through at all, it made a lot of developers to switch sides, and most Windows users refused to embrace its new philosophy, staying in older versions of Windows. Fortunately, latest announcements for Windows 8.1 Update 1 and Windows 9, seem to try and bridge the gap that Windows 8 created. My personal opinion is that Microsoft should start giving a little more love to WinForms, accepting the fact that developers are and will develop in WinForms. Making use of the DirectX subsystem, enhancing the existing controls and making better use of databinding would be a start.

Rant's conclusions:

WPF should be a great decision for developing applications that target users with newer PC configurations and newer Windows versions, and rely mostly on eye candy GUI.

WinForms should be a great decision for extremely rapid development, and for developing applications that have a more general target group of users, and rely on maintaining high compatibility for most Windows versions.