Rewriting Qt in Rust
-
@Chris-Kawa I am just seeing what people will say about my idea. I was thinking that the Qt developers have lots of experience regarding GUIs and if they create a pure Rust GUI library, it will be a very good one.
Maybe an independent project can be created alongside Qt, like you said, a fork. The existing promising Rust GUI libs such as Iced have very poor documentation.
-
@Pete-Carter The Rust community would certainly benefit from such a port, but you can't talk about it like it's a flip of a switch that would give you Rust Qt next week.
It's a very large library. You could talk about bindings (I think there are some projects that attempt that), but even that is a lot of work (see Pyside for example) and simple bindings give you absolutely no benefit, because you're still just calling the code written in original language.
Maybe my imagination is limited, but rewriting entire Qt to Rust I just can't see happening. It's too much work with next to no benefit. One or two language features here and there that help with productivity a bit is a non-argument to me when we're talking in the scales of the effort and manpower that is required.
-
@Chris-Kawa I agree with everything you said, except the part "It's too much work with next to no benefit."
My knowledge in C++ is poor BTW.
Now in 2023, you cannot keep using a language invented in 1985. Lots of things have changed since then. Also C++ is a buggy language and that costed a lot of money due to the faulty design. So i think in terms of security, using Rust will eliminate any possible memory bugs. You feel confident writing code in Rust and you are sure you will never make mistakes cuz the compiler prevents you from doing so.
Rust was made in the first place to solve the existing problems in C++.
Not to mention the amazing official package manager Cargo and the full tool-chain that comes with Rust.
Here are some projects that started using Rust for its many benefits:
https://blog.torproject.org/announcing-arti/
https://blog.cloudflare.com/how-we-built-pingora-the-proxy-that-connects-cloudflare-to-the-internet/
https://doc.redox-os.org/book/ch01-06-why-rust.htmlSo all i am suggesting is for Qt developers to use their experience in creating a parallel Rust GUI library or contribute in an existing one. I think the Rust ecosystem will grow and dominate no matter what, but having experienced GUI developers helping will make it grow much faster.
-
@Pete-Carter said in Rewriting Qt in Rust:
using a language invented in 1985.
Ok, then try to compile Qt with a compiler from 1985...
If you want a Gui written in Rust then start with it.
-
@Pete-Carter said:
Now in 2023, you cannot keep using a language invented in 1985
I can, I do and I don't see it changing any time soon.
Lots of things have changed since then
Including the C++ language. The original "C with classes" and C++23 are very different languages you know.
C++ is a buggy language
That's quite a bold statement. You sure it goes well with "My knowledge in C++ is poor BTW"?
You feel confident writing code in Rust
I feel very confident writing C++ code. I would write terrible Rust code and it would be full of bugs.
you are sure you will never make mistakes
Bwahaha. Sorry, that's funny :) Sure, keep telling that to yourself. I'm sure bug-trackers of Rust projects are all completely empty :)
full tool-chain that comes with Rust
You seem to be living in a bubble, so sorry for bursting it. Try to write and deploy a AAA game for a Sony console using all of its advanced APIs in Rust and its full tool-chain. I dare you :)
So all i am suggesting is for Qt developers to use their experience in creating a parallel Rust GUI library
That's quite a different thing from rewriting Qt in Rust.
Sure, if someone has the expertise in Rust to write a GUI library, also large amounts of time and incentive to do so, by all means. Sounds like a cool project to work on. -
@Chris-Kawa Chris is right. C++ is a much different language now than 1985. And current Qt has not used full features of new C++.
-
Look, I don't want this topic to turn into another language war, because it leads to nowhere. I'm not trying to diss Rust.
I understand Rust needs a good GUI library. That's clear. Cross platform UI is a big challenge for any language, because it's an enormous undertaking and requires a lot of expertise. I also understand that the roots of Rust are in compute and that there's not enough UI experts in that community to start such a project, so they're looking to interest C++ (and other languages) programmers, that have decades of experience. That's all fine. Crosspollination is beneficial to everyone and learning and using multiple languages is just personal growth.
But here's the deal - Rust, Carbon and all these other communities seem to have some sort of savior complex and that's honestly annoying. Whenever I see them entering a discussion with C++ crowd it goes something like "Your language is awful and needs to die. I'm here to save you from it. Come join the right cause" with expectation that they'll be greeted as messiahs and thanked for it. It's like the pointless political discussions - trying to "win" by calling the other side stupid as your leading argument.
C++ professionals don't need saving. They are doing fine and half the world is running on technology they know well. They're fine, really. C++ doesn't need to die either. It's evolving, it has wide spread support, lots of tools and ecosystems. It's doing fine.
It's ok to try to attract people to Rust. I've looked at it, written some hello world examples and it looks interesting. But in my work it's just a curiosity. It's nowhere near being in a state where I could transition to it even partially, or have any incentive to put in the enormous amount of work it would require. Despite of what the "get-rich-quick" crowd would like you to believe not all the tech is just blockchains, servers and clouds. There are a lot of C++ based industries Rust has not even a foot in the door and it won't anytime soon. Maybe in a decade or couple when it catches up to C++ ecosystems in those areas, sure, who knows. But by that time it's gonna have the same amount of baggage as that thing it tries to replace.
I'm just saying "Rust good because C++ bad" is very much a Rust crowd echo chamber mantra. For me personally it works like a red cape on a bull. Rust is an interesting emerging language with long way to go. That's it. Would be fun to engage with it if not for the presumptuous crowd it sometimes attracts.
-
-
Of course i am not trying to tell everyone to ditch C++ and only use Rust, this is impossible due to the huge amount of C++ code used in the industry. Yes there are others who think that any language other than Rust is trash, i am not one of those.
-
What i am trying to do here is to spread the idea of "Build Back Better". This will happen by checking for existing problems and solve them in the best possible way. Patching a language to keep it breathing for longer is good but it may not be the solution. For instance, you will have to give up on many improvements to keep backward compatibility.
-
I don't think anyone will disagree that Rust has solved nearly most of C++ problems, and that Rust as a language and tooling is much better overall than C++, anyone who used both languages for a while will clearly notice that. I have used both languages and experienced the great difference in security, compiler messages and ease of use, although I have not dived deep in C++. That's why Rust has been the most loved language for 6 years now according to stack overflow surveys. And the percentage of love is increasing every year.
- Its absolutely correct that the ecosystem of Rust is nowhere near C++. This is cuz C++ has been living for much longer. So i see that the best thing to do is to keep working with C++ while improving the Rust ecosystem to make it mature ASAP.
-
-
@Pete-Carter said:
What i am trying to do here is to spread the idea of "Build Back Better".
Build back from what? I'm not a US citizen, but I believe this term referred to post-pandemic recovery plan. C++ didn't have any world shattering event that requires us to recover from. Since 2011 standard it's been steadily improving and generally doing pretty well. The amount of tooling that got developed for it in that time is also significant. New platforms, libraries, IDEs, toolchains, package managers, sanitizers, profilers and much much more. The ecosystem is richer than ever and it's not stopping.
Patching a language to keep it breathing for longer is good but it may not be the solution
See, you keep talking about C++ like it's some sort of wounded animal that needs to be put out of its misery. It's not. It's doing fine and evolving at quite a rapid pace.
I don't think anyone will disagree that Rust has solved nearly most of C++ problems
Ha, there's your bubble thinking again. I think there's quite a number of people that would disagree :) For isolated example my two biggest problems with C++ are compilation times and dependency management. I don't know Rust well, but from what I read the first one is also a big problem in Rust, so switching does nothing for me. As for second - it's true that Rust has well integrated package manager, but so what if it has easy packages but doesn't have packages I need? And guess what - C++ people are not sleeping. There are couple of C++ package managers that start to gain momentum. Sure, there's not a perfect one yet, but as an example - I've been using vcpkg for the last two years or so and I am pretty confident that with the pace they're improving it's gonna be a solved problem in just a few years. If not by that one then by another. When that happens I'm good. I really don't need Rust. I might play around with it but I don't need it. Obviously I'm just a single person and needs of others vary, but come on, "solved nearly most of C++ problems"? I won't believe you're that naive.
That's why Rust has been the most loved language for 6 years now according to stack overflow surveys
Wow, 5746 people like Rust on SO. Cool. I'm very happy for that miniscule fraction of population.
So i see that the best thing to do is to keep working with C++ while improving the Rust ecosystem to make it mature ASAP
That's the thing - not everyone is as convinced as you that C++ needs Rust. C++ is doing fine and doesn't need Rust to mature fast. It's cool for that community if it does, but personally I'm good either way. I don't check "is Rust good yet" website every day when I wake up. I don't think about it much at all and I'd wager I'm not the only one.
-
First of all, Qt is huge and most people will think of different things when talking about porting Qt (to Rust or anything else). I use QWidgets to compile for Windows, Linux, and macOS. Others mostly see the use of QML. Some think of Android and iOS when talking about Qt (because it can do that as well). Qt has also long been drifting away into automotive. Besides the pure GUI part of Qt there are many other modules like monetization, etc. Qt also is a full framework with classes for networking and file i/o.
From today's perspective it would be quite stupid to develop a library which does everything in the same way as Qt. Qt solved a lot of problems back in a time when there wasn't a good (enough) standard library. With version 6 Qt is moving closer to the STL. I would hope that the creators of Rust were smart enough that string, container, file and network classes are good enough that they don't need a Qt-port replacement.
It would be nice if Qt were to reinvent itself in C++. Today we got smart pointers. This could easily replace Qt's memory management solution using parenting. Common advice in modern C++ is to (almost) never use
new
which doesn't work with Qt. One of my main gripes with Qt is that all GUI programming must be funneled through a single thread (explicitly). This was fine back in the days when Qt was invented and computes only had a single core. In theory it would be easy to have a dedicated GUI thread running in the background and the programmer does not have to care to make GUI calls within that thread. Certainly, for performance reasons one should think this through for an optimal solution. I'm also annoyed that layout calculations are only done once the widget is shown. Even more annoying is using multiple monitors with different resolutions. I would hope that a modern UI kit would handle this properly in the background. I am even certain that it should be possible to make widget partly overlapping two screens having the right resolution/scaling on each of the two monitors. C++ also needs to evolve in a way that we can get rid ofmoc
. Hopefully, Rust has a solution for this already in place.Don't get me wrong: Qt is currently the best toolkit out there for the kind of software I write, but it is far from perfect or modern. Writing a GUI toolkit for Rust is a good idea and you can certainly borrow and learn from Qt. But, for a modern GUI toolkit you should certainly not port Qt to Rust. Design a new toolkit with modern ideas and modern solutions for modern problems.
-
I don't have any use for rust in the first place, so I see no value in it. IMHO, rust is another solution in search of a problem. Idle hands are deadly hands and when smart kids are bored they wreak havoc that has bad long term consequences.
Rust solves no problems for me. it just does things differently...the new cool way...
-
@Kent-Dorfman (Disclaimer: I haven't used Rust.) I do think that Rust solves one problem (from what I've heard): By default you don't have a problem with dangling pointers. Can anyone confirm that this main claim of Rust holds up? You can still explicitly write unsafe sections where you are allowed to shoot yourself into the foot. Probably a bad thing is that you can't use any C libraries if you want to stay on the safe side of the fence exclusively. That would be a major problem.
As long as this is the only problem that Rust solves, I agree that it is not worth switching. It has become very easy to write "safe" code in C++. I haven't had any problems with dangling pointers in new C++ code in years. As long as you use modern C++ and modern approaches (no non-owning raw pointers) you are quite safe. So, the only difference between C++ and Rust is that Rust is more explicit about this because it drops backwards compatibility. For C++, however, it comes back to programming style. Once modern C++ becomes a habit you will automatically avoid this kind of problem. Yes, C++ allows you to shoot yourself into the foot (as does Rust, but it makes it harder). If your habit tells you to keep the gun in the safe, accidents don't happen (unless you get out the gun).
Is there any other problem Rust solves compared to C++?
-
@SimonSchroeder As far as performance goes, Rust is both fast and memory-efficient: this is what I read.
-
@JoeCFD Rust, like C++, is a systems level language, so they are as fast and memory efficient as the user can make them to be. It doesn't have any inherent overhead like virtual machine, interpreter or garbage collected languages. I'd guess any differences with C++ would come down to compiler maturity, which I'd expect to be more or less converging by now. The backend is often shared anyway and sure, one or the other will come up wits some optimization in the frontend, but that's usually something that gets ported to other languages with time too. It's not like compiler guys are sleeping or not sharing.
Rust, learning from the past and not weighted down by legacy code, has better defaults than C++ e.g. move instead of copy by default, immutability by default and some memory management concepts like ownership or borrowing. Those are embedded in the language, where in C++ they've been added with time often in form of traits, new constructs or standard library additions. The value of Rust depends on how good or poor C++ you write, and can vary from game changing to insignificant.
IMO the memory problems in C++ come down mostly to poorly educated programmers that we see more and more. From what I observe the ChatGPT generation can shoot themselves in the foot even with a pillow, so if your company has this problem then switching to Rust might be beneficial (if you can actually manage to switch), but the more experienced professionals you have the faster cost/value perspective of switching is diminishing.
-
@Chris-Kawa Memory problems in C++ can be handled much better now than before. It may not a big deal anymore. Have not tried Rust and not sure how faster it is, for example in a sparse matrix solver.
-
in computer engineering there has been this never ending push to reduce the programmer alchemists to the importance of assembly line workers. I got into programming 40+ years ago because I wanted to be artsy and creative, not implement someones OCD directions for minimum wage.
college graduates aren't smart enough to understand the full software stack from physical hardware to business concept then obviously the system is flawed because that gives those who do understand it too much power. I have no use for languages that obfuscate the steps of abstraction from algorithm to electronic switch. If someone understands systems then they can effecitvely and safely program in C or C++ on those systems. Rust seems an attempt to cheapen the art.
-
@Kent-Dorfman said in Rewriting Qt in Rust:
there has been this never ending push to reduce the programmer alchemists to the importance of assembly line workers
Well, of course...why do you think they invented COBOL?
Historically, programmers have been known for being:
- necessary for IT (once IS) departments to function
- expensive/very expensive
- irreverent, sometimes to the point of flaky
Not a combination that endears one to the suits. It's only natural that people would try to obviate this. That they fail most of the time is a historical artifice, and won't keep them from trying.
-
This recent blog post made me think of this discussion :)
-
@Chris-Kawa You have some good points. Can you elaborate on the following:
Lets suppose we give the Rustaceans (pronounced as Rust-Asians) what they want and say that Rust is much better than C++ (23) for the sake of this post.
- Qt uses C++, not-free
- Slint uses Rust, free
- Flutter, free
Why should someone in 2023 still choose Qt with C++ in case of desktop and/or embedded devices over the others mentioned above?
You also said: "Qt also is a full framework with classes for networking and file i/o". However, in case of Linux there are enough C libraries that work on their own hence Qt classes for networking and file i/o aren't necessary.
Finally, one argument that Rustaceans state is that C++ has been trying to solve things by adding other things which complicates everything. What is your take on this?
Not choosing sides, as you are a very experienced programmer which can't be easily found nowadays I want to know your take on this.
-
Lets suppose we give the Rustaceans (pronounced as Rust-Asians) what they want and say that Rust is much better than C++ (23) for the sake of this post
Lets suppose sky turns red tomorrow... what's the point in questions like these? It's not happening soon and I'm really more interested in discussing real world problems and scenarios than hypotheticals. Maybe in couple of years (more like a decade) we can revisit the problem, but currently it's a pipe dream of the Rust people.
Qt uses C++, not-free
Huh? Qt is free, GPL or LGPL. That's how I've been using it for nearly 15 years.
Why should someone in 2023 still choose Qt with C++ in case of desktop and/or embedded devices over the others mentioned above?
I don't think anyone "should". I think they "can" consider it and it "might" turn out to be the best solution for them. It might not. I'm not gatekeeping anyone from making their own choices. Someone might already know C++ and/or Qt, so why switch and pay for the pain of re-learning everything from scratch for little to no benefit? Take me for example - I've been using C++ for most of my life at this point. I've been using Qt since 2008. I know they're not perfect, but I know most of the imperfections that affect me and have years of experience dealing with them. They rarely even bother me at this point and I barely register them when they come up. It's like marriage - sure you can switch for the new hotness, but is that really a long term win? ;) How much time and effort would it take me now to get to know Rust, Slint or any of the other to the same degree? What can I do in them that I can't in the technology I already know? What guarantee do I have that their imperfections wouldn't cause me more trouble than the ones I already know how to deal with? A bit of a sprinkle here and there, so I can join the cultists chanting over syntax? That's not nearly enough to even consider this. Sure, I take a look at them out of curiosity every now and then. I might write some toy program for personal use, but there's no value in seriously switching for me. More of a loss actually, because time and energy is something I have less and less with years.
hence Qt classes for networking and file i/o aren't necessary
Every operating system has a basic set of libraries that are building blocks for higher level libraries. With above mindset you don't need any non-OS provided libraries. Same for UI, be it Qt, Slint or Flutter. There are native APIs for UI after all. The point of all of those libraries is convenience layer over the usually low level and complicated native APIs. If you ever wrote
QWidget widget; widget.show();
and then tried to do equivalent in native API you will know the value of it. Same goes for networking, I/O or any other module. Not to mention the cross-platform nature of Qt.
I'm a low level guy, and sometimes seeing what Qt does underneath pains me, but it's usually a lot better anyway than what other frameworks do, like spinning up a web browser, javascript engine and taking up 1GB of RAM just to show a button on the screeen. So what if the API is written in a language with a bit easier syntax? Ugh... it's like they hate the idea of a battery lasting more than an hour, but I digress.Finally, one argument that Rustaceans state is that C++ has been trying to solve things by adding other things which complicates everything. What is your take on this?
It's complicated. C++ is a language on which a large chunk of the world's technology is built. It would be irresponsible to break compatibility for the sake of fixing little inconveniences that got into it over the years. Rust and other younger languages don't have that big of a legacy they need to care about. Most users of those are enthusiasts that don't mind rewriting large chunks of their software when the language changes something. This is prohibitively not true for most of the existing C++ code. So the reasonable approach is to improve the language by adding better facilities than breaking the old ones. Sure, this approach has caveats, making the overall language bigger and more complicated, but there's really no perfect solution to the legacy code issue in general.
Again, I'm not against new languages. I'm against fanboying/fangirling over them, mostly because of how annoying it is. Rust is not perfect and it bothers me when people try to paint it as such. These new things have their benefits, but also their downsides, like every technology. Legacy is a problem of C++ right now. Lack of reach, maturity and stability are just some of Rust's that I know of, even being a complete noob in it. I won't tell people which problem set to choose, but I would like to see more reason and consideration in people picking their solutions, instead of jumping on the new shiny, like a cat on a laser dot. Pick a hammer for a nail and an umbrella for rain. There's no omnitool (not counting the one from Mass Effect).