Wt 4 reflections

  • Posted by koen
  • Wednesday, September 30, 2015 @ 14:47

I realize you may be waiting for 3.3.5 now, rather than have us thinking about Wt 4.0 but the recent cppcon (which we regretfully didn’t attend) inspired us here (at Emweb) to reflect on what could be the spark for Wt 4.0.

We quickly concluded the following list of things we would like to see for Wt 4.0:

  • Support c++11 (and later) only: no more support for c++03

  • Reduce reliance on boost (in favor of std)

  • Align with the C++ Core Guidelines in a pragmatic way

  • These things together should result in faster compile times

  • Fix some errors in our APIs that require a breaking change (most notably boost::any in WAbstractItemModels)

As you can see, functional changes aren’t per se on this list because we don’t see any functional change that warrants breaking the API, we have been managing these fine over the history of Wt with incremental updates.

It would be nice to hear your thoughts though (especially dropping support for c++03) on what’s included and what’s missing from this list!

Modeled after a now 20-year old library (Qt), Wt has never been, nor tried to be, a poster-child of modern c++. Admittedly, when Wt was created (I know realize we are celebrating a 10th anniversary in December!) c++11 wasn’t around the corner, and we did already make some choices (STL, standard library, boost) which made Wt less of an archaism than Qt is today.

But even then we more than happy to get our inspiration from what is probably still the best and consistent desktop UI toolkit around rather than experimenting with fancy new c++ features.

Today, it seems that after c++11, and c++14, with excursions in new complex features (move semantics, decltype, etc…), there’s a new focus on how to use all of this behind the scenes to allow programmers young and old create good software (nicely illustrated in the keynote of Herb Sutter). The goal clearly is to make c++ again an enjoyable language.

One of the main changes we foresee is to align with the core guidelines with respect to the preference for smart pointers over raw pointers. We believe that the strict ownership model of Wt (and Qt) is quite intuitive, mostly transparent, and gives few problems in terms of memory leaks or dangling pointers. But it would be nice to express transfer of ownership in APIs, as well as get exceptions rather than segmentation faults if one de-references a dangling pointer. In other words, we do not want to change the ownership model, but rather make it more clear and safe.

Another change that we are looking forward to is the removal of some arcane boost libraries that we’ve been dragging along for years. One such library is Boost.Signals (or Boost.Signals2), of which we use only a tiny portion, for the use-case in Wt, resulting not only in faster compile times (experiments indicated a factor of 2 should be feasible) but also faster code (for those that worry) and simpler stack-traces. Along the same lines, another choice that we have regretted since we understood it’s a bottleneck is the use of boost::any in our public APIs.

Specific non-goals are anything that make it harder to port over existing Wt 3 code to Wt 4 (although there will be a porting effort) without adding value: e.g. we will not exchange CamelCase for snake_style.

Before you ask: there’s no time-frame yet. At the moment we are gathering ideas and looking at technical constraints (such as our internal C++ Wt to Java JWt tool-chain).

Tags:
24 comments
  • Posted by anonymous
  • 6 years ago
I am not an experienced developer, but I have noticed HTML5 has introduced new form elements (https://www.w3schools.com/html/html_form_elements.asp), which I could not find in your widget gallery, suc as datalist. Should you add them too?
  • Posted by Zingam
  • 8 years ago
I'd like for Wt to be more Qt-like. Why don't you just join the Qt project and use the same source base?
All big platforms have web and desktop apis but Qt and Wt. That I think would be beneficial for all parties.
  • Posted by anonymous
  • 6 years ago
I agree. Adopting the new QML would be great too.
  • Posted by anonymous
  • 8 years ago
Koen, two thumbs up for your Wt 4 reflections!
We're evaluating Wt for our FreeBSD-based embedded systems, using x86-64 platforms now, and adding ARM64 platforms next year. We build and test using both GCC 5.2 and Clang 3.7. Given that my tool chains have full support for C++14 and that I am working on multiple hardware platforms, I would like to see the following in Wt 4:
* Leverage C++14 features and idioms to bring Wt into conformance with modern C++ (I believe we're on the verge of a C++ renaissance and would love to see Wt at the forefront, for performance and maintenance reasons)
* Convert old-style enums to C++11/C++14 strongly typed enums (enum class) with explicitly defined sizes (to help with alignment and portability)
* Require new style casts for all public .h files
* Build with more (all?) compliler warnings enabled, especially -Wsign-conversion
* Drop Boost completely and use std instead (especially std::atomic instead of Boost threads)
Thank you!
Brad
  • Posted by anonymous
  • 8 years ago
I think you should design the API based on standard unique_ptr/shared_ptr smart pointers since it's natural right now.
  • Posted by koen
  • 8 years ago
We've had discussions on this. We believe neither unique_ptr or shared_ptr or appropriate since shared_ptr brings the risk of memory leaks (it's not uncommon to have circular relations between sibling widgets or parents/children) and unique_ptr does not have the bring safety for reference pointers. We do not want to regress in safety compare to the current pointer/WObject hierarchical ownership situation.
  • Posted by anonymous
  • 6 years ago
Hopefully in Wt 5 you guys will have changed your minds about using unique_ptr and will instead be using shared_ptr for your API. My code is littered with std::move(), and as a bonus I'm also saving raw widget pointers that are returned from addWidget because - of course - I have to interact with those widgets.
When a unique_ptr is transferred to the Wt library, I then have to be very careful that my subesquent code - which was originally using a raw pointer - is not trying to use the new unique_ptr. It requires re-arranging my code, whereas a shared_ptr would have left much of my code intact, simply swapping the raw pointer types for a corresponding shared pointer type.
And while I understand that circular references are more of a problem in a library like Wt, it's not impossible to solve. As it is, the work to port to Wt 4 is now on me, not (where it should be) on you guys.
  • Posted by mcharest
  • 8 years ago
I too would like boost to go away. For the same reason as the previous poster, it hurt compile time. Recently I switched our apps from boost::array to std::array, and gained 30 secondes out of a 10 minutes build.
C++11 only in the short term, hum maybe a subset of it. GCC 4.8.3 which many system still have by default ( Ubuntu 14 ) is not fully C++11 compliant.
I would really like some soft of tool, a la Qt Designer.
  • Posted by anonymous
  • 8 years ago
I would love to see boost Signals go away! They are the culprit of slow compilation times.
If you can't do it you might consider using nano-signals
https://github.com/NoAvailableAlias/nano-signal-slot
Take at look at the performance:
http://libsigc.sourceforge.net/benchmark.shtml
Hope to see it soon,
Thank you!
  • Posted by anonymous
  • 8 years ago
I'm a noob here, but back here every now and then because I like the overall architecture and technology.
I would suggest a couple of improvements.
The first is support for headless Wt, which means decoupling the rendering and the backend layers, and being able to present e.g. REST with the same backend. So, the wt widgets system would be just one of the possible presentations after a more structured backend providing e.g. a generic json to be rendered. This is something other platform (one is Drupal 8) is considering, to be able to support fast BigPipes, modern js client frameworks, and plain web services, but embedded systems may benefit as well in e.g. implementation of upnp services or IoT protocols. Furthermore, the same codebase may be presented on web or (with other presentation layers plugged in) as a desktop app. Maybe I miss some Wt internals, but the logic layers seem too much integrated to me, looks like the developer can be one person only rather than decoupled in frontend and backend.
The second improvement that btw may dramatically help with the first, is the introduction of dependency injection. For example, a presentation layer could be injected for local test other than the web server. But again, let's consider embedded applications. Consider an IoT application dealing with hardware. Instead of compiling with different #defines and develop inline stubs for testing purposes, you just inject a stubbing component as a .so respecting the same interface. Injecting c++ classes is much much more easier than using dlopen, they can auto-register themselves as they are loaded up and then used through the defined class definition.
Thank you for reading till here, keep the good job.
Kind regards
  • Posted by anonymous
  • 8 years ago
I'm a fan of QT and also a fan of Wt. Both are good for me.
But as you said, it is old style. So I'm happy that you will make a more modern version of Wt.
Also the idea of using more standard libraries instead of boost is nice.
  • Posted by anonymous
  • 8 years ago
The planned changes for Wt4 all sound very worthwhile. C++11 provides many useful features that make the language more modern and straightforward to use. It is a significant step forward from C++03. Over time, the use of C++11 features may help more users read and contribute library code.
It will be interesting to see the API changes that arise from removing boost::any. Hopefully, the migration of existing user code will be fairly straightforward.
  • Posted by anonymous
  • 8 years ago
I think C++xx is not equal to the Boost library yet. If something works faster however and has no bottlenecks, it is a different matter then :)
  • Posted by anonymous
  • 8 years ago
I'm thrilled to know Wt is planning to be part of what I see as the long-awaited revival of C++.
I'm just an average programmer but for me the changes are all welcome and seem like sensitive decisions.
  • Posted by anonymous
  • 8 years ago
I mean, sensible and logical changes.
  • Posted by anonymous
  • 8 years ago
Wt noob here, I like the library a lot, specially being modelled after Qt which I am quite experienced with. I have google this question before asking it here with no results. Why don´t you simply use Qt? I personally despise Boost, they are great, probably the best c++ libraries out there. But they are just not user friendly, or at least not as friendly as Qt. To be honest I read about Wt a long ago but I just recently started using it because it took me a lot of time to get the experience I needed to start compiling and using it along with boost. For a library to be successfull IMO it has to appeal the masses, and for that you need a hello world that works out of the box... Any way, good work so far and hope you get rid of boost and start being more qt-like (hopefully also with the documentation, I also hate doxygen)... cheers. Juan.
  • Posted by koen
  • 8 years ago
Despite their nice design, Qt and 'modern C++' are kind of opposites. What do you find hard w.r.t. boost in combination with Wt? Although Wt heavily relies on boost, most of the boost usage is for internal affairs (with a few exceptions: signal/slots, boost::any). It will not be feasible to drop boost support completely, because e.g. our internal web server is built on top of boost::asio. But we want to swap to 'std' instead of 'boost' wherever we can.
  • Posted by anonymous
  • 8 years ago
I you have time sir, I will tell you the story of my life.
Let me describe my own experience. I started in this GUI programming world by the necessity of implementing control algorithms in industrial equipment which was limited to C/C++ due to the high cost of Matlab licenses. Then clients asked for GUI's to be able to configure and monitor the algorithms. So I looked at different options, having just the academic experience in C++ (thoery and little practice of OOP, nothing about the compilation, linking procedures, etc). I found first WxWdigets which I gave up, because I couldn't get past gettting a lot of linker errors in the IDE (remember my lack of experience). Then by googling more I found Qt, which I downloaded with the easy installer, added a button and a lineedit with the IDE and VOILA a working hello world gui app !!! Having won my confidence then I started learning more about software developement from the top to the bottom, not viceversa.
How did you started with computers? Did you have to assemble your first computer before you could use it? Unless you are 60-70 years old, I don´t think so. You first got a computer, plug it, press on, and thats it. That's the way it should be, nobody want to compile boost, set enviromental variables, define paths, add linker options before they can even run the hello world.
As I became more experienced and wanted to do more advanced things with Qt I started learning about their qmake build system, make files, compiling, linking, etc etc... right from their docuemntation !!! but what won my heart from beginning was the fact that it just worked out of the box.
I would like to see Wt more used, the bigger the community, the better the library will be. That's why I say it has to work out of th ebox to appeal the masses. I am not the first person to realize this, take Steve Jobs who realized the masses didn't want an Altair kit to assemble themselves, they wanted a computer which would work out the box and let them get right into business, and IMO a library or toolkit should be like this. I am no expert, so take my opinion as it is, a non expert opinion. =)
I hope I can contribute with something, I am working on some tools to use Wt easier for myself, and as soon as I have something working I will put them on github or something for other noobs like me to use.
Again let me congratulate you guys for your awesome job, once you get your head around it, Wt is an excellent library!
  • Posted by anonymous
  • 8 years ago
Adding a Project Wizard for Wt to Qt Creator (QtC) may be good way to expose Wt to more Qt developers. Qt Creator adds a new JSON based infrastructure to add new wizards to Qtc, so that shouldn't be too hard.
What would be even better is to add a Wt plugin that would help adding Wt to a qmake/QBS project in QtC and help/instruct how to obtain Wt and necessary Boost libraries.
Also consider the very new qpm project (https://www.qpm.io/).
  • Posted by anonymous
  • 8 years ago
By the time Wt4 is ready, I think all widely-used compilers will support most, if not all, c++17 features. So dropping c++03 shouldn't be an issue but embedded developers may think differently.
  • Posted by anonymous
  • 8 years ago
Hi there!
Embedded developers, unfortunately, DO think differently. While I would also love to live in a perfect world where all compilers support c++11 and beyond I'm, sometimes, forced to work with compilers who don't even support proper c++03. Heck, even C99 support is not something every vendor gives me.
And I'm not talking about ARM world, since it's mostly gcc based, but about companies like Microchip, Atmel, Cypress and the like. On the other hand, you can't run a POSIX compliant OS on those devices(except uLinux) so maybe this rant has no point.
To the Wt guys:
I just started using your library for a personal server. I must tell you, building it is a PITA. I just ended up using pre-compiled libs from Debian (good thing my server is also Debian). And all of the problems could have solved using proper documentation. At most points I needed to guess what CMake wants me to do.
But overall I just LOVE what you are doing (I'm also a Qt fanboy). Keep up the amazing work!!!
  • Posted by anonymous
  • 8 years ago
Embedded devs will have an issue for sure. Many are limited to older toolchains that still don't have C++11.
  • Posted by anonymous
  • 8 years ago
3.x series may be continued with bug fix releases while 4.x series include both features and bug fixes.
  • Posted by anonymous
  • 8 years ago
That could be an issue indeed. But I would like to hear from a real Wt user that it will be an issue for him, instead of guessing at it.

Contact us for more information
or a personalised quotation