What is the difference between GTK# and Windows Forms?

12,745

Solution 1

Gtk#:

GTK# is a .NET binding for the Gtk+ toolkit. The toolkit is written in C for speed and compatibility, while the GTK# binding provides an easy to use, object oriented API for managed use. It is in active development by the Mono project, and there are various real-world applications available that use it (Banshee , F-Spot, Beagle, MonoDevelop).

In general, GTK# applications are written using MonoDevelop, which provides a visual designer for creating GTK# GUIs.

Platforms: Unix, Windows, OSX

Pros:

  • Good support for accessibility through its Gtk+ heritage.
  • Layout engine ideal for handling internationalized environments, and adapts to font-size without breaking applications.
  • Applications integrate with the Gnome Desktop.
  • API is familiar to Gtk+ developers.
  • Large Gtk+ community.
  • A Win32 port is available, with native look on Windows XP.
  • The API is fairly stable at this point, and syntactic sugar is being added to improve it.
  • Unicode support is exceptional.

Cons:

  • Gtk+ apps run like foreign applications on MacOS X.
  • Incomplete documentation.

Windows.Forms:

Windows.Forms is a binding developed by Microsoft to the Win32 toolkit. As a popular toolkit used by millions of Windows developers (especially for internal enterprise applications), the Mono project decided to produce a compatible implementation (Winforms) to allow these developers to easily port their applications to run on Linux and other Mono platforms.

Whereas the .Net implementation is a binding to the Win32 toolkit, the Mono implementation is written in C# to allow it to work on multiple platforms. Most of the Windows.Forms API will work on Mono, however some applications (and especially third party controls) occasionally bypass the API and P/Invoke straight to the Win32 API. These calls will likely have to changed to work on Mono.

In general, Winforms applications are written using Microsoft's Visual Studio or SharpDevelop, which both provide a visual designer for creating Winforms GUIs.

Platforms: Windows, Unix, OSX

Pros:

  • Extensive documentation exists for it (books, tutorials, online documents).
  • Large community of active developers.
  • Easiest route to port an existing Windows.Forms application.

Cons:

  • Internationalization can be tricky with fixed layouts.
  • Looks alien on non-Windows platforms.
  • Code that calls the Win32 API is not portable.

Source: Picking the Right Toolkit

Solution 2

They are both GUI toolkits, each having their strength and weaknesses. From my experience:

  • Winforms does not require installation on windows, Gtk# does require installation on Windows.
  • Winforms has a designer in Visual Studio, Gtk# has standalone designer and integrated designed in MonoDevelop.
  • Winforms is bound to Windows, Gtk# is cross-platform.
  • Winforms is slow and flickers. Gtk is faster.
  • Most Winforms controls are wrappers around standard windows controls and offer very limited functionality. Gtk widgets are more feature-rich.
  • Gtk allows creating forms and widgets with complex layout. Winforms offers only trivial variants of layout, and FlowLayout & TableLayout & AutoSize are too weak to be able to have complex forms that resize and automatically accomodate to different font sizes, different resolutions.
  • Cairo is faster and has more features than Gdi+ (Cairo supports output and input from more types of files, e.g., svg, pdf)
  • Gtk# is open-source, winforms is not
  • Winforms and Gtk# have 3rd-party controls/widgets (however, with Gtk# there is less need for them because basic controls work really good).

In short, I would not recommend using Winforms (except when there is a strong reason not to have more dependencies than .NET FW), but using Gtk# or WPF.

Solution 3

They are different graphical toolkits for creting windowed applications, with different origins.

GTK# is a binding for the GTK library, primarily intended for linux/unix. It also works on windows, but it's not the native environment for which it was designed.

Winforms is another toolkit, this one coming from microsoft.

They are totally different APIs for achieving the same results, but each better suited for a platform.

If you are looking for multiplatform windowing in .net, Qt may be an option now that it got LGPLed.

Share:
12,745
Josh
Author by

Josh

Updated on June 21, 2022

Comments

  • Josh
    Josh almost 2 years

    What is the difference between GTK# and windows forms? Are they totally different?

    Thanks

  • Roman Starkov
    Roman Starkov over 14 years
    Funny how you suddenly mention WPF at the very end of your answer :)
  • dmitry_vk
    dmitry_vk over 14 years
    The question was about Gtk# and S.W.F., WPF was off-topic :)
  • Camilo Martin
    Camilo Martin over 12 years
    Is there anything you have to do at compile-time to have it work on Windows and Linux, or you can simply bundle the Gtk# libraries and it will work cross-platfor out of the box? Also, is the programming model hard to get started or it's mostly like Winforms but with a different naming for things (for example, is there a paint event)? Thanks in advance.