Wt and JWt 3

  • Posted by koen
  • Wednesday, November 4, 2009 @ 08:10

Finally, we bit the bullet and released Wt and JWt 3.

We wanted to have the JWt Reference Documentation clean and clutter-free before having the first solid release of the Java version of our web library.

We moved to a new major version number mainly because we needed to break the API for signals and slots. Some ideas for performance improvements required such a fundamental API change. We took the opportunity to also break the API in some other places, such as for a reworked WResource API.

But other than huge performance improvements and code clean-ups, also many other improvements happened over the last 9 months, and even more exciting features are sitting in unstable branches.

Biggest changes in Wt 3

Let’s step back and review the biggest changes since we started evelopment of the Wt 3 branch (starting at Wt 2.99.0):

Signal accessors

Signals are now accessed through an accessor method, rather than being exposed with a public member.

Previously, you would write:

WPushButton *button = new WPushButton("Click me");
button->clicked.connect(SLOT(button, WPushButton::disable));

Since 2.99.0, this should be:

WPushButton *button = new WPushButton("Click me");
button->clicked().connect(SLOT(button, WPushButton::disable));

The benefit is that signal objects are created only on-demand. Because most signals are not used, this resulted in both runtime and memory improvements.

WFlags (C++) and EnumSet (Java)

Rather than using an untyped int for passing a set of enum flags, which is used throughout the API, we are now using a WFlags<E> class (in C++) and an EnumSet<E> (in Java). This allows type-safe combination of different enums, improving compile-time checks. WFlags should not have any runtime overhead. This probably does not require changes to your existing code, though.

Modified WResource API

The WResource API (C++/Java) has been redesigned and greatly simplified. The new API is simpler (requires only one virtual method to be implemented) and more powerful, providing support for continuations to serve large resources without blocking a thread or requiring large memory usage (currently in C++ only, as this is only supported in the next version of the Java Servlet API).

Resources now have better thread-safety in C++: they are now by default reentrant (requests for a single resource may be handled concurrently) and they are protected from concurrently being destroyed by the main event loop.

In addition, the mechanism for indicating that a resource has been changed and thus needs to be updated in its views, has been improved and sanitized.

Item delegates

The WTreeView (C++/Java) MVC view class has been updated to use a WAbstractItemDelegate (C++/Java) to perform the actual rendering of cells. This allows the view to be customized for specialized rendering of table cells.

In the future, we will extend the default view delegate, WItemDelegate (C++/Java) to support inline editing, but, you can already implement your custom inline editing delegate.

Better support for testing

We added a WTestEnvironment (C++/Java), which allows you to write integration and unit tests that involve Wt widgets and objects.

Progressive (hybrid) bootstrap

Wt has has always supported both AJAX clients and plain HTML clients. To differentiate between the two, a small bootstrap page was used that sensed for AJAX availability, and which loaded the first page contents either using JavaScript, or by redirecting to a new page.

Some discussions on the mailing list indicated that this could be done better, suggesting a hybrid bootstrap model: the first page could contain already the entire page as plain HTML, and in the back-ground AJAX presence could be detected to upgrade this to a full AJAX interface. This would have several benefits, including a faster initial response (one round trip instead of two) and better support for JavaScript libraries that need to load in the initial request, such as Google Ads.

We finally got around implementing this. When enabled, first a plain HTML session is assumed, and widgets may later be asked to upgrade themselves to their AJAX version (C++/Java). This is the principle of progressive enhancement, right there, entirely automatically embedded in your application !

Future ?

What to expect in the near future? In order to stabilize and polish Wt and JWt 3, we have confined a lot of new developments in private branches. Several of them are looking promising, and will hopefully find their way to Wt 3 in the near future:

Wt::Dbo

We are finalizing an Object-Relational-Mapping (ORM) layer, which might be useful in many web applications. This blog is actually our pilot project to find out how usable the current implementation is (and, it seems, no web framework is considered complete without a blog as example). We can already tell you that it does not use code generation, XML or ugly macro hacks, but instead you can declare the mapping entirely in plain compact C++. More on it later!

CSS Themes

Many users have complained that the default look of Wt’s widgets is boring, and we must confess, we have always given priority to functionality rather than looks. We intend to change this with the advent of theme support. All CSS that is currently provided within the inline stylesheet by each widget class, will be pushed out to external style sheets, and a small API has been added to select a particular theme.

XHTML Templates

It finally occurred to us that many things could be simplified if we admitted to support for XHTML templates. Unlike traditional frameworks, Wt templates will be used to describe the XHTML for a single widget. Within each template, widgets may be instantiated, and strings resolved. This simplifies those situations where you would like to express the layout using XHTML/CSS, rather than using a nested hierarchy of WContainerWidgets.

This blog implementation uses this templating system to display posts, comments, and the authoring dashboard.

Tags:
22 comments
  • Posted by anonymous
  • 14 years ago
Lovely!
would it possible for you to provide a compiled package for windows/mac installation. So that beginners can start trying out Wt using say Visual C++ without having to get all the Wt dependencies from different places and compile?
  • Posted by anonymous
  • 15 years ago
fantastic! please keep up the good work.
  • Posted by anonymous
  • 15 years ago
Yay! Is wt library 64 bit compatible ?
  • Posted by koen
  • 15 years ago
For sure! It is written in portable C++, and has been ported to a wide variety of compilers and target operating systems.
  • Posted by dgalic89
  • 15 years ago
yay too!
  • Posted by anonymous
  • 15 years ago
yay!
  • Posted by anonymous
  • 15 years ago
Team, API is eveloping at a fantastic rate. I have noticed in your blog that an Wt::Dbo API is in the works ? What database compatiblity will it provide ?
PostgreSQL..
MySQL..
SQLite..
ODBC..

  • Posted by koen
  • 15 years ago
Hey, we currently provide a simple database abstraction layer for which we implemented the SQLite backend.
I was recently pointed out that soci was going to be adopted into boost (is that sure now?). When soci makes it in boost, it would perhaps be worthwile to switch to soci for backend support.
That being said, the whole SQLite backend implementation is 264 lines, so it isn't such a head-ache to support other libraries (Postgres and MySQL or obvious candidates, ODBC is more of an archaism these days or not ?).
  • Posted by denn
  • 15 years ago
I am extremely surprised that you haven't heard of the OTL library http://otl.sourceforge.net
This is the most mature API out there for C++ and works on every major Database out there.

All versions of Oracle (natively via OCI), DB2 (natively via DB2 CLI), SQLServer (natively via SNAC), Informix (natively via CLI), TimesTen, ODBC 3.0 and ODBC 2.5 compliant databases via MS ODBC dirvers or unixODBC for Unix being Sybase, MySQL, PostgreSQL, EnterpriseDB, SQLite, MS ACCESS, Firebird

WELL WORTH LOOKING INTO RATHER THEN REINVENTING YET ANOTHER WHEEL :)

I just had a look at soci ! Very nice API as well I must admit. No where near as mature as OTL just yet.
  • Posted by koen
  • 15 years ago
We did look at OTL, and indeed it looks like it has been around already a long time.
However, handling sqlite through ODBC is a bit of a pity: sqlite is the most easy database to interact with (and I like it therefore very much for this reason alone), while I have never succeeded in getting ODBC to work. Since I wanted to get going quickly (to validate all of the great ideas in Wt::Dbo), I went with the quickest solution.

I am surely prepared to revisit this, but probably would prefer to move to soci if they are getting successfully absorbed by boost. I am unsure why I prefer soci, but depending a 35000 lines header file somehow doesn't feel right, and boost adoption gives me a false sense of confidence that it must be any good (given that there are quite a few boost libraries that are actually really bad). I any case, we will first focus on making Wt::Dbo add alot of value on top of these low-level SQL backend libraries, before reconsidering the backend problem.
  • Posted by simpleit
  • 14 years ago
Hi Koen, please consider Poco/Data:

http://pocoproject.org/blog/?p=24
pocoproject.org/wiki/index.php/DataUserManual
http://pocoproject.org/docs/Poco.Data.html

It's much alike SOCI as it borrowed SOCI concept. It has released under Boost License and also has commercial support. It's API is very mature.
  • Posted by bart
  • 15 years ago
I've been given a sneak preview and for now they have the sqlite backend working. But I am guessing support for at least MySQL will be added swiftly.
  • Posted by zhmsong
  • 15 years ago
Greate News! Congratulations!
  • Posted by bart
  • 15 years ago
It seems smoother now. One suggestion for now : make the comment box open at the location of the add comment link instead of below the comments. And of course hide that link when the comment box is opened.
  • Posted by anonymous
  • 9 years ago
  • Posted by koen
  • 15 years ago
Good suggestion.
Did this now, except for the hiding of the link since it crosses my widget boundary (to show it again when a comment was posted).
  • Posted by bart
  • 15 years ago
Same thing when hitting the reply link : it stays visible even if the comment box is already open. (And if you click it multiple times funny things happen!)
  • Posted by koen
  • 15 years ago
They are only funny if that isn't what you expected to happen!
Am I the only one that wants to edit multiple replies simultaneously? :-)
  • Posted by anonymous
  • 15 years ago
no
  • Posted by anonymous
  • 15 years ago
yes
  • Posted by raphinou
  • 15 years ago
congrats with the release!
Future also looks very promising!
  • Posted by wim
  • 15 years ago
Huray for Wt 3.0!

Contact us for more information
or a personalised quotation