GoQt
github.com
github.com
I dream of seeing a day in ten years or so where everyone expects right once run everywhere native look and feel applications out of Qt, a toolkit that provides you mechanism to access the full power of your target devices without having to lock yourself into whatever vendors SDK is and thus forcing you to rewrite the same program 5 times for 5 different target devices.
Its not there yet - just the other week I was arguing with someone on reddit about the usability of Qt on mobile and conceded it lacks a prebaked gesture support library to easily just do a two finger swipe rather than having to use the multitoucharea type to specify how two finger motion works - but it is getting so very close.
Someone made me aware that they are now in yet another reboot for mobile support.
Using C++ with standard libraries like Boost plus platform specific language is less effort than re-writing QML for each platform, which still doesn't feel native, while having anyway the work to wrap platform API ourselves.
Thankfully Qt just announced that their commercial-only components will be added to the open source version soon, including the QML-to-C++ compiler.
I haven't had an opportunity to try it myself but they claim it improves startup times significantly.
You'll want to use a splash screen implemented with minimal UI code (no widgets of any kind yet, just an image with a background). While showing the splash screen, load dynamically a minimal main UI and some critical services -- only the parts that will affect the initial view.
Then hide the splash screen. You'll have a small bit of time after the UI becomes visible and before the user will actually use it. You'll want to use this time to load the rest of your services and preload more UI components to avoid the creation lag on UI thread later on.
I've done this kind of three-stage loading on Android without technical users even realizing it's not a native app. Would I do it again? Not really if platform native code is an option. There are too many details one has to handle when imitating platform visuals and interaction.
Likewise, QML is just plainly useless on the desktop, and much slower to booth. Unfortunately, the performance regression in Qt5 is there also if you don't use it, and that shouldn't be.
Qt5 being slower than Qt4 is the main reason I've been moving slowly towards copperspice (http://www.copperspice.com/) for newer projects. The fact that moc is no longer necessary removes also the main paint point of qt.
Forgive me for not knowing, since I've never used Qt Widgets before. I'm writing a desktop app with QML and it's fast and smooth thanks to the OpenGL acceleration.
For example, since I work in visualization, I often tie data widgets to the GL canvas in order to provide realtime feedback. I also use Qt5 in order to provide keyboard accelerators. With QT5 the rendering latency grew so high that I couldn't provide realtime feedback anymore, and I had to batch requests (and finally reverted to Qt4).
Incidentally Qt5 widgets can be used in a GL context directly, but are way too slow to render and manage events to be used consistently at 60 fps (they're not designed for that, so their scope in this sense is not as broad as it can really be). It's actually faster to give them their own GL context in order not to interfere with your pipeline, which kinds-of defeat the point.
I've also found that the additional JS glue doesn't provide any benefit unless you go entirely QML.
What exactly is each 'widget' when you say there are 100+ widgets? Each overall feature, or each Item within the feature?
In my photo editor I have a histogram of how many photos you've taken each day: http://i.imgur.com/7yAYsP9.png
The histogram is actually a ListView, and each delegate is actually not just the bar for each date, but also the background color, the highlight color for the current date, and the date text that's above each bar. Using model updating, it responds nearly instantly even though there are a thousand days in the view, and the source data is a big ol' SQLite query with C++ postprocessing.
I don't know if that's helpful to you, though. Would that count as one widget in your parlance?
ListViews are optimized for display of lists, obviously, so they generally instantiate only visible elements in the view, and delegates do not even undergo geometry negotiation so they're a bit lighter than a regular widget.
Still, if you do visualization or animation, the UI must respond within 1ms in order not to be noticeable, and that's very hard to attain with Qt5.
I doubt people using QML on mobile devices really understand the issue either, since when mobile developers speak of "animations" they generally mean some random transition of the UI itself. Often, the operation is not even performed in the background, but rather simply sequenced (so that the animation appears to be smooth, but the actual delay is completely absorbed by the user). In these scenarios, times up to 250ms/300ms might still be felt "instantaneous" as they're shorter than the transition. For me, it's outrageous.
I'm just curious of how much force multiplier you can get writing the menus with QML and the game with Qt3d.
Also why on earth do they tout being built with autotools as a feature?!
* It's quite incomplete. There are a lot of things you just can't do in it. For example try doing a widget of the kind you'd use for compilation output in an IDE. There is a multiline text editor widget, but the only efficient operation is appending text - you can't remove the first line for example.
* If you decide you will write your own QML widget (e.g. for the compilation output), you find that there is no way to render text! The scene graph text nodes are still private.
* You have to use Javascript (ugh)
* There's quite a lot of friction converting C++ types to Javascript and vice versa. Especially with lists and arrays. For example when you access a C++ array from Javascript it has to copy the whole array into a native Javascript array, and then modifications are lost.
* The scope of files and IDs is quite messy - parents can refer to their children's IDs, so there is no concept of data encapsulation. To be honest I still haven't totally worked out the rules, but they're a mess in any case.
* Dynamically creating dialogs and UI elements is a bit of a mess. The "standard" way to have dialogs is (more or less) to create all dialogs the program needs at startup and hide them all until needed. Obviously that doesn't scale well for things like tooltips. Creating them dynamically is rather painful (especially when there are no examples for how to do it!)
QML is definitely a nice idea, but I think they need to give it a third try, and probably not use Javascript.
Additionally, it only JUST got a TreeView (Qt 5.5 I believe) and a lot of additional widgets you would need to implement a regular desktop app are just missing.
Does QT's class hierarchy map cleanly to Go? Is it just interfaces everywhere?
(I'm not trying to start a language war, just genuinely curious.)
That was kind of a ramble, but thats the gist of it.
https://en.wikipedia.org/wiki/Name_mangling#How_different_co...
As to the very interesting question of how it's handled here, it looks like part of the project (the "qtdrv" folder) is a shared library written in C++ that includes Qt, wraps the desired functionality, and exports it as C-style symbols (with extern "C"). This is a pretty standard way of circumventing the name mangling problem.
What I find interesting is that everything appears to be wrapped into a single exported function "qtdrv". Might be a wrapping technique that I'm not aware of, or maybe I'm completely misreading the source. I'm actually quite interested in knowing how the wrapping code was generated, having projects where the same kind of C++ wrapping is required.
It appears that GoQt has this giant pile of wrappers around C++ types, casting pointers back and forth:
https://raw.githubusercontent.com/visualfc/goqt/master/qtdrv...
I would have expected this to require an `extern "C"` declaration. I'm sort of surprised it doesn't, but maybe the common C++ ABIs match the C ones if only C types are passed to and from the function?
(Also, is this file auto-generated?)
[it] would not suffice to guarantee C++ compiler
interoperability and it might even create a false
impression that interoperability is possible and
safe when it isn't.Take a look at the Itanium C++ ABI, the de facto standard on GNU/Linux etc. for a sense of the scale of the problem: https://mentorembedded.github.io/cxx-abi/abi.html
And that doesn't even standardize the layout of the actual types in std::* themselves, just the typesystem. That just gives you enough information to correctly access someone else's implementation of std::string; you still need to have that precise implementation around at compile time. There is, however, a proposal to standardize the layout of std: https://isocpp.org/files/papers/n4028.pdf
To be fair, you have the exact same problem when trying to call into e.g. Rust from e.g. C. Rust's typesystem is complex and its libstd is involved and not stabilized, so the easiest way is, again, to route through C types instead of trying to access Rust's String type in C.
That's interesting, thanks.
Although people like to bash C++, there isn't any programming language with an ABI as part of the language standard, not even C.
The C ABI that so many people adhere to, only exists in OS written either in C or C++ (via extern "C").
By the historical accident that all commercial major OSes are mostly written in C, developers that aren't language lawyers tend to think C ABI is somehow defined in some standard.
In OSes that weren't written C, with C compilers available, like OS/400, VMS, Lillith, Lisp Machines, Oberon, the ABI being used isn't the C one.
However, within a given platform, the ABI tends to be small, clear, and well-documented. It's not documented in the C language standard, but there is documentation for it, from whoever defines the platform.
I thought I had mentioned this in another comment, but to be clear, I'm not trying to "bash C++"; plenty of other type systems and standard libraries have the same issue (including Go, Rust, Python, etc.). I'm just relaying the fact that, on the platforms where Go and Rust support FFI, they do so by implementing the C ABI, which is a stable ABI defined in the platform documentation, and the C++ ABI tends not to be well-defined or stable and is also much more complex to implement. This isn't a criticism of C++, just a fact. (And there are good things about this; for instance, C++'s type system is so much more useful than C's.)
Calling into C++ is generally a big problem in any programming language though, and for most, you have to write a C wrapper.
You can perfectly write a C++ library and expose a C-safe subset. I've done so many times.
The problem arises if you need to expose objects (with virtual methods), which C obviously doesn't have as the ffi is basically restricted to plain functions and record types.
Of course, moving can cause problems for Go pointers in C land, but keeping Go pointers beyond a cgo function call will be prohibited in Go 1.6:
Maybe https://www.appveyor.com/ would work out for you? It's free for OSS projects.
And, in the modern world of big computers (desktops and laptops), it is not all that big of a deal (I don't actually know, but I would guess it's on the order of a few MB, maybe in the tens of MBs), and from what I can tell a lot of applications are already built statically for distribution to Windows and Mac OS X.
I do think changes in how shared libraries are shipped or managed may help. I've had ideas for ages around using cryptographic hashes but have no time to experiment with such things.
This bit me on the ass when Apple forced a libstdc++ update on OS X 10.3 with a new ABI, permanently breaking all C++ compilation on my Mac. Compiling C++ programs for 10.3 was still possible, but you needed a 10.4 machine, the latest Xcode, and compatibility libraries to do it.
I had similar problems on Linux and Solaris because of that transition. My own fault (actually my employer's) for assuming binary compatibility when it was never promised.
The ABI between g++ transitions is also platform and architecture dependent. Mac was PowerPC back then. Sun used Sparc. Not everything is always x86, even on Linux.
I still would characterize it a fairly stable ABI, not something that "can always break", especially compared with other vendors that break the library ABI every release.
[1] A new libstdc++ C++11 ABI was added in GCC 5.x but it is optional even in C++11 mode.
I agree with you on "big computers" to an extent. I just bought a temporary [1] laptop. It's beefy enough, but only has 2GB of RAM and 32GB of relatively slow flash storage [2].
Mobile broadband prices have been falling in Australia but it's still at the point where I have to thing before downloading anything >5MB.
[1]: http://www.pendo.com.au/pendopad/pendopads-windows-8/pendo11... (I didn't pay RRP)
[2]: Okay, okay, it's still eMMC, but it feels slow.
And people make fun about Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch in Wales.
http://doc.qt.io/qt-5/licensing.html
I see nothing in that list that seems different or that would prevent one from building commercial products on Qt without licensing fees.
As a result, some issues arise, such as code that is stuck on GPLv2 (e.g. removed the upgrade clause like the Linux kernel) may be incompatible with LGPLv3.
This blog tries to explain some of the issues. http://nmav.gnutls.org/2013/03/the-perils-of-lgplv3.html
To make a car analogy, if the tires are made under LGPLv3, you got to tell them what kind of rubber it is made of and permit car owners to change the tire without the car saying "unapproved parts used, so I will refuse to start now until you have bought approved tires from an official car dealer". Every car made before 2000 managed to do this without even thinking about it.
FSF consider GPLv2 to be incompatible with this deal from a US-legal view, which is the same view that claim "further restrictions" only covers restrictions made from software licenses.
[1]: https://www.gnu.org/licenses/gpl-faq.html#gpl-compat-matrix