Wt: an introduction

Wt (pronounced 'witty') is a C++ library for developing interactive web applications.

The API is widget-centric and similar to desktop GUI APIs. To the developer, it offers complete abstraction of any web-specific implementation details, including event handling, graphics support, graceful degradation (or progressive enhancement), and pretty URLs.

Unlike many page-based frameworks, Wt was designed for creating stateful applications that are at the same time highly interactive (leveraging techinques such as AJAX to their fullest) and accessible (supporting plain HTML browsers), using automatic graceful degradation or progressive enhancement.

The library comes with an application server that acts as a stand-alone web server or integrates through FastCGI with other web servers.

Interactive, secure and accessible

Page-based frameworks (based on PHP, JSP/JSF, Ruby on Rails, etc...) do not make abstraction of the underlying technologies (HTML/XHTML, JavaScript, CSS, AJAX, Forms, DHTML, SVG/VML/Canvas). As a consequence, a developer needs to be familiar with all of these evolving technologies and is also responsible for graceful degradation when browser support is lacking. The structure of the application follows mostly the page-centric paradigm of early day HTML. This means that not only will you need to implement a controller to indicate how a user moves from page to page, but when using advanced AJAX techniques you will need to design and maintain manually your client-server communication.

Generating HTML code or filling HTML templates is prone to security problems such as XSS (Cross-Site-Scripting) by unwillingly allowing JavaScript to be inserted in the page, and CSRF (Cross-Site Request Forgery) by trusting cookies for authentication. These security problems are hard to avoid when as a developer you need to be able to insert self-written JavaScript to improve your web application and thus the framework cannot filter it out.

In contrast, a web application developed with Wt can be developed in only one compiled language (C++), from which the library generates the necessary HTML/XHTML, Javascript, CGI, SVG/VML/Canvas and AJAX code. The responsibility of writing secure and browser-portable web applications is handled by Wt. For example, if available, Wt will maximally use JavaScript and AJAX, but applications developed using Wt will also function correctly when AJAX is not available. Wt will start with a plain HTML/CGI application and progressively enhance to a rich AJAX application if possible.

Typical use scenarios:

  • Web-based GUIs for web-enabled embedded systems benefit from the low footprint of a C++ web application server.
  • Web-based GUIs that require integration with (existing) C++ libraries, for example for scientific or engineering applications.
  • Creating a port of existing C++ desktop applications to the web.
  • High performance, complex web applications which are fully personalized (and thus cannot benefit from caching), fully AJAX enabled and at the same time entirely accessible and Search Engine Optimized.

Other benefits of using Wt

  • Develop web applications like you develop desktop applications.
  • Provides an extensive set of widgets, which work regardless of JavaScript availability (but benefit from JavaScript availability).
  • A single specification for both client- and server-side validation and event handling.
  • Use HTML and CSS for layout and decoration, if you want to.
  • Generates standards compliant HTML or XHTML code.
  • Portable, anti-aliased graphics optimized for web usage (using inline VML, inline SVG, HTML 5 canvas or PNG images), which can also be used to render to PDF.
  • Avoid common security problems since Wt has complete control over the presentation layer and proactively filters out active tags and attributes nor exposures business logic, which stays at the server.
  • Ultra-fast load time and low bandwidth usage, which are affected only by screen complexity, not application size. Wt implements all the common tips and tricks for optimizing application responsiveness.
  • A simple API with a robust cross-browser implementation for server-initiated events ala server push or comet).
  • Use the built-in httpd for easy development and deployment, or use the FastCGI connector to deploy as a FastCGI application in existing web servers.