[HN Gopher] Wt - C++ Web Toolkit ___________________________________________________________________ Wt - C++ Web Toolkit Author : gtirloni Score : 123 points Date : 2020-07-12 17:00 UTC (5 hours ago) (HTM) web link (www.webtoolkit.eu) (TXT) w3m dump (www.webtoolkit.eu) | mjs33 wrote: | Is this just CGI? | c-smile wrote: | Am I right that this is close to ASP.NET thing | <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) ... | doteka wrote: | While certainly impressive, the Hello World example in their | documentation is in no way preferable to writing JavaScript. | cbsmith wrote: | I always liked Wt. I haven't used it in quite a while. What's it | like these days? | nikki93 wrote: | With 'modern C++' you can make APIs way nicer than the Java-like | API going on here. Lambdas really help, along with RAII which has | already been around. I have an API going where the following | syntax creates a div with a 'toolbar' class and a toggle button | with the 'edit' class and updates the DOM (C++ running in WASM, | using IncrementalDOM for the DOM access): | 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... | jordigh wrote: | So what do the compiler errors look like when you mess this up? | Say, you use the wrong argument passing for one of the lambdas. | cocoa19 wrote: | It's hard to compete with Open Source Libre libraries and lower | C++ interest in new developers, not to mention developing in C++ | is harder than many other languages. | | 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" | rch wrote: | > Wt is licensed under the GNU GPL Version 2 | | That excludes it from my use, but I believe that license is | what is implied by 'Libre' generally. | cocoa19 wrote: | I think you are right, what I wanted to say is free for | commercial uses without restrictions like LGPL's dynamic | linking requirement. | | I'm thinking something like MIT or BSD licenses. Not sure if | there's a term for this, "permissive" license maybe. | mehrzad wrote: | I am a recent grad interested in C++ but from my perspective, | very few employers want to hire recent grads for C++. | jonwalch wrote: | Investment banks and trading shops are always looking for new | grads for C++. | wojtczyk wrote: | Agreed. Also, robotics & controls | einpoklum wrote: | Sure, if you have an anti-social bent and want to profit | almost directly from usury, arbitrage and speculation. | ncmncm wrote: | They can afford to demand competence, and they need it. But | they don't always get it. | | 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. | beached_whale wrote: | I would say programming is really difficult and it is | hard to find competent(pick an arbitrary line in the | sand) for any skill let alone programming. Pick a field, | and the web is stuffed full of people with battle stories | of cleaning up after other people. This is actually a | point or two against C++ as the breadth of it is so | large. The trick, as in any practice, is to find | motivated people willing to learn that are not stubborn | in their set ways. | vikinghckr wrote: | Google and Facebook -- two of the biggest software companies | are incredibly C++ focused -- especially in backend/infra. To | a lesser extent Microsoft and Amazon are the same. And as | others mentioned, trading farms love C++ too. | | 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. | [deleted] | doliveira wrote: | That's nice to hear! I need some C++ projects to show, then | zelly wrote: | C++ people don't do CRUD webshit. C++ is for compilers, HFT, | machine learning, browsers, search engines, robotics. When C++ | touches "the web" it's in the form of something like Envoy or | HAProxy, not exactly application layer. For CRUD webshit, there | are literally hundreds of options out there that largely | automate the entire process (Rails/Django/Spring). There is no | reason to use C++ for it not just because of the timesink but | because the lack of safety makes it an aggressively bad idea. | You would get all kinds of "I thought that wasn't a problem in | the 21st century anymore" type of problems. | fbmac wrote: | That's the illusion that got me into C. Reality I found is, | where I live at least, C is for legacy code and code that | runs in very bad hardware. | zelly wrote: | What illusion are you talking about? | guruz wrote: | It's all possible :-) | | I can recommend the "app server" POCOPRO | https://pocoproject.org/pocopro.html | smt1 wrote: | People do need to write UIs in C++ though (sometimes as | frontends for some of the purposes you mentioned), and Qt is | probably the most used UI toolkit for C++. | | 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. | roywiggins wrote: | This is the exact use-case where I've used Wt. Existing C++ | codebase, needs an admin interface, needs to be accessible | over the corporate intranet. Wt is perfect for that. | codr7 wrote: | I've written several applications using this approach | lately, administrative systems. | | 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. | giancarlostoro wrote: | You are better served using D and Vibe.d or other D web | frameworks if you really want a compiled web stack. Also the | other obvious choice is Go and probably Rust but I havent | found a web framework for Rust that doesnt annoy me to no end | yet. | stjo wrote: | Making a front end library/framework/toolkit without screenshots | and example code should be made punishable by law. | ssutch3 wrote: | https://www.webtoolkit.eu/widgets | Jaxan wrote: | There is a link to the gallery. That suffices, right? | beached_whale wrote: | The whole site is run on it, and your working examples are | there just had to click on documentation | https://www.webtoolkit.eu/wt/documentation | einpoklum wrote: | So, Wt is about having the server do a bunch of computational | work for rendering the UI. Now, I'm not a web developer, so I may | be talking nonsense, but I don't see how that's reasonable: | | 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. | marta_morena_25 wrote: | I find it irritating that even after reading their front-page and | the "How you can use WT" I still have no clue what it is supposed | to be. Is this an embedded browser? Is it a C++ app GUI that | allows you to use HTML like construction? Is it an emscripten | application? How can it work without JS enabled? Is it compiled | into pure WebASM? What the heck do they mean by connection? What | connection? What does have PDF and DB to do with all that? Etc. | | Very poor marketing imo. After reading all this I have even less | clue what it is supposed to do. | roywiggins wrote: | It works without JavaScript because it can render everything | server-side. If the user has JavaScript it uses websockets or | Ajax to fetch updates from the server, but if it doesn't have | those it can just reload the whole page like you would with a | CGI application. | | "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. | hellofunk wrote: | Oh strange, I completely assumed from the start that it was | referring to front end C++ using Webassembly, similar to how | some rust libraries do it. Never occurred to me this is | server side. | chrismorgan wrote: | Wt comes from many years before WebAssembly. | marta_morena_25 wrote: | Yeah it dawned on me the moment I hit sent... That this is | probably something like ASP.NET for C++. Probably some people | still need that :). Legit use case, just I think they need to | work a lot on their messaging. | shayas wrote: | Why some people can't liberate themselves from C++? | mister_hn wrote: | Because the alternatives aren't better | PaulDavisThe1st wrote: | Because we're already free. | znpy wrote: | Best comment | vikinghckr wrote: | Because: | | a) Modern C++ is amazing. b) The highest paying software jobs | require C++. | imafish wrote: | a) it really isn't. b) yes, COBOL developers are also highly | paid. does not make the language amazing. | vikinghckr wrote: | a) It really is. b) I didn't say point (a) is why modern | C++ is amazing. But it is one of the motivations for | learning modern C++. | varbhat wrote: | What's the real advantage of using this over HTML template | rendering? | roywiggins wrote: | You don't have to write JavaScript, and it generates a page | that acts like an SPA and does all the AJAXy stuff for you in | the background. So you can just say "I want a button that does | this server action on click" and it manages all the | communication between the browser and the back end. It even | gracefully degrades to full page reloads if the user doesn't | have JavaScript turned on. | rsecora wrote: | I will try to be brief and go to the point. | | 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... | Jeaye wrote: | I tried using Wt for a site almost a decade ago, it seems. The | layout managers would make the site so terribly jittery that it | could cause motion sickness. | | 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. | jokoon wrote: | Wait, is this using http/html, or something else? I'm not sure I | understand the "web" part in this. | nephanth wrote: | It is. But it is abstracting over | http/HTML/JavaScript/rpc(ajax) with c++ classes | afranchuk wrote: | I used Wt about a year ago for an application at work. I was able | to write a GUI program that could be accessed at a web address or | with a native Qt application, and Wt was equivalent enough (API- | wise) that I was able to template between the two. Really neat | actually. There was one place where the GUI was defined and you | could choose whether you wanted web, native, or both! Only | stumbling block was when I needed some opengl (webgl), but with a | fairly minimal abstraction I was and to get that working in both | two. | | Wt felt very polished and worked exactly as I expected. | guruz wrote: | A propos Qt. | | 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... | esprehn wrote: | Unfortunately the Qt demos all take 8-10 seconds to load on a | phone for me and several of them fail with out of memory even | on high end devices like a Pixel 4 XL. Certainly I'd expect a | Pizza Ordering app to work on mobile (and to not show a flash | style loading spinner for 10 seconds). | | 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. | mwcampbell wrote: | The Qt port for WebAssembly still has zero accessibility | support, e.g. for blind people with screen readers. Assuming | Wt is using standard HTML form controls, it shouldn't get in | the way of accessibility. Of course, the app developer still | needs to follow good accessibility practices, such as | labeling images and not conveying information through color | alone. | InfiniteRand wrote: | A lot of the comments question the use case but I think your | story captures the ideal use case, a hybrid C++ / web app where | you want to or need to share some of the functionality between | web / c++ sides | roywiggins wrote: | It's not a bad way to build a web interface for a C++ | application that needs to be configured over an intranet. It | makes tying "click on a button on a web site" to "run an | administrator action on my application" very easy, and you | can use your Qt muscle memory to lay out a simple admin | interface with relatively little mucking about. | | 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. | beached_whale wrote: | In addition, I have used the templating in the library and it | works really well. Let the UI/UX people do their thing and | get the best performing back end. | einpoklum wrote: | But for a modern-C++ developer, Qt is so outdated... it's based | on what the language was like 20 years ago. I would really | rather not be limited to writing UI that way. | briandilley wrote: | painful | dang wrote: | If curious see also | | 2013 https://news.ycombinator.com/item?id=5997034 | | 2010 https://news.ycombinator.com/item?id=1098282 | | 2009 https://news.ycombinator.com/item?id=886900 ___________________________________________________________________ (page generated 2020-07-12 23:00 UTC)