Wt – C++ Web Toolkit
webtoolkit.eu
webtoolkit.eu
Wt felt very polished and worked exactly as I expected.
You can do all that with CGI scripts or whatever, but if you already have a bunch of C++ running on the server it isn't nuts to use Wt to build your CRUDy admin interface.
There is Qt for Web Assembly. https://www.qt.io/qt-examples-for-webassembly
And WebGL streaming https://www.qt.io/blog/2018/11/23/qt-quick-webgl-release-512...
WT is doing all the logic server side so the client ends up being lighter weight and will work on more devices, and with better performance.
So unless there is a mindset change, that will keep happening.
Not just govs, but just about all large orgs serving web apps have accessibility requirements.
Assuming that there is a court willing to hear it, probably by the time it reaches the first audience there is a new website in place.
ui.div()("toolbar")([&]() {
ui.button()("edit")("selected", editing)("click", [&](emscripten::val target) {
editing = !editing;
});
});
This works by having `.div()` etc. return an `Elem` type whose constructor opens an HTML element and destructor closes it, with various overloads of `operator()` letting you set attributes, bind events or add child elements.Here's a video of some results with C++ and CSS: https://twitter.com/snikhilesh/status/1279913032471031809
I should do a writeup about this soon...
The error messages produced by g++ for anything template related are a really difficult hurdle to overcome as a beginner. I am sure once you mastered it, it does make sense -- but right now it's a source of frustration for me.
For the time being, any library writer can improve their own error messages using a mix of constexpr if, static_assert and enable_if.
Also, to clarify on the original point, in this case it doesn't require that much template trickery. Most attributes could be handled as `.foo(Foos::BAR_1)` to set HTML attribute `foo="bar_1"` for example and have things still be 'type safe' on the C++ side. I just pass strings through right now to have a catch-all API, then I could go back on it after some real use and see what styles come in practice.
The only template it happens to use right now is the usual `template<typename F>` with `F &&f` to let you pass an inlineable lambda. I could use `static_assert` as you say, with `std::is_invocable_v`, and offer a nicer error message when that doesn't match.
In general though I wonder how much the new 'concepts' stuff can help.
But yeah this is the closest I've come to having a UI DSL in a language with deterministic resource management and access to direct byte data layout for your structures. The main other alternative seems to be Rust and IME I've had a harder time with its error messages but I think it's also bc. I happen to have experience with 'old' C++. If I was starting fresh it'd be different.
It's basically what the JS that gets generated from React JSX is like, and also like immediate mode UI APIs that get used for game tooling a lot: https://github.com/ocornut/imgui
2013 https://news.ycombinator.com/item?id=5997034
My use case for Wt at the time as "I know C++ well and I don't want to learn anything else." I don't think I'll ever have a better use case for it and I don't think that one was very good to begin with.
The best use case I can imagine is something like "We have a lot of existing C++ code which we need to turn into a web app." But even then, why does the C++ code need to manage the DOM? It almost certainly doesn't.
<asp:textbox text="hello world" runat=server />
In particular to that runat=server part?So widget gets rendered to HTML on server side with events sent to it from client? That may work for logical events like click but not for mousemove (too expensive) ...
My employer still struggles to this day finding good recent grads remotely interested in C++. In contrast, Java and Javascript skills are easy to find in the market.
Edit: Added "Libre"
That excludes it from my use, but I believe that license is what is implied by 'Libre' generally.
I'm thinking something like MIT or BSD licenses. Not sure if there's a term for this, "permissive" license maybe.
They are the reason it can be hard to hire qualified C++ programmers elsewhere. You compete for the rest who find Wall Street and monopolists both morally repugnant.
Essentially, in 2020, the highest paying software companies in the world all are heavily invested in modern C++. Knowing modern C++ is the biggest advantage you can have in the market. But you won't know that from reading the HN comments section.
Wt is basically Qt for the web. I've used a lot of UI toolkits across many languages, and Qt with modern-ish C++ is fairly productive, doubly so if you're slapping something together for an existing C++ codebase you have.
None in C++ yet, but Java & Go.
Integrating the UI tightly with the backend has a lot of advantages and I strongly prefer working in a sane language to both template engines and JSON APIs.
I can recommend the "app server" POCOPRO https://pocoproject.org/pocopro.html
1. It doesn't scale, or if you're rich - it's annoying to scale. 2. It interferes with the client/user's ability (albeit theoretical) to decide how they want to present the information 3. It seems to go against what are, or used to be, the principles of the web: Interlinked, clear-text, markup which the client renders as it sees fit.
This is also spitting out HTML...
So:
1. It does scale and it's easy to scale. In fact, one of the use cases of Wt is massive applications (e. g. Facebook apps) 2. No, it does no interfere with client's ability to decide how they want to present the information. What Wt does is the same thing any other web toolkit is doing: gracefully degradation, fallback, etc depending on your browser, browser version, and whether you have JavaScript enabled or not 3. How is Wt's output not interlinked, clear-text, markup which the client renders?
It seems you only know Angular, React and other client-side toolkits. The server-side approach has been (an is still) working for decades, do not disregard it.
Wt is different to templating. It's server side rendering and the widgets communication is transparent, based on slots and receivers in the server side.
If you came from java it has similarities to Vaadin.
It has more goodies, websockets, DB...
Wt can be compiled to its own webserver (which you would use directy if on an embedded device oruse behind a reverse-proxy for other cases), or you can compile it to a FastCGI module you can run with Apache.
Very poor marketing imo. After reading all this I have even less clue what it is supposed to do.
"Qt, but for web applications" would be a short and basically accurate descriptor. You slot together widgets in C++ and it works out how to lay them out and connect actions taken by the user to your event-handling code, which lives on the server.
The PDF thing is for rendering reports to PDF, instead of HTML. Not useful unless you're in a corporate sort of space, but when you want a PDF report you do want something like that. The DB thing is an ORM that makes basic CRUD operations on your database easier.
a) Modern C++ is amazing. b) The highest paying software jobs require C++.
When NVidia, Microsoft, Oracle, Apple and Google put other native languages on their toolbox I will consider them for production code.