Live data from Hacker News

Rust and QML: a timely example

vandenoever.info

1–10 of 22 posts

Re: Rust and QML: a timely example

#2
Is it just me or it feels way too ugly? Multiple opaque layers of abstraction plus Rust kind of feels shoehorned when it's called from C++. Something tells me it's terribly difficult to write, debug and deploy. I don't exactly see the benefit of adding Rust here.

Re: Rust and QML: a timely example

#4
post #2

Is it just me or it feels way too ugly? Multiple opaque layers of abstraction plus Rust kind of feels shoehorned when it's called from C++. Something tells me it's terribly difficult to write, debug and deploy. I don't exactly see the benefit of adding Rust here.

> I don't exactly see the benefit of adding Rust here.

From that perspective, there isn't any. Dyed-in-the-wool "QT app-devs", if there is such a category (KDE devs?) already have access to Rust libraries, in the same way they have access to most stuff in weird compiled languages: you wrap the library in a C ABI and call that. It's a well-understood process in QT land.

I think this project is more an effort to give Rust projects access to a native graphics toolkit (that happens to be QT) for adding a GUI to a previously CLI application. I could see, for example, the Parity Ethereum client (written in Rust) getting a native system-tray/notification-area widget written in QT.

Re: Rust and QML: a timely example

#5
post #2

Is it just me or it feels way too ugly? Multiple opaque layers of abstraction plus Rust kind of feels shoehorned when it's called from C++. Something tells me it's terribly difficult to write, debug and deploy. I don't exactly see the benefit of adding Rust here.

i think the benefit is more for Rust users who find they need to make a GUI. There aren’t many good options right now so this will probably be welcome.

Re: Rust and QML: a timely example

#6
post #4
post #2

Is it just me or it feels way too ugly? Multiple opaque layers of abstraction plus Rust kind of feels shoehorned when it's called from C++. Something tells me it's terribly difficult to write, debug and deploy. I don't exactly see the benefit of adding Rust here.

> I don't exactly see the benefit of adding Rust here. From that perspective, there isn't any. Dyed-in-the-wool "QT app-devs", if there is such a category (KDE devs?) already have access to Rust libraries, in the same way they have access to most stuff in weird compiled languages: you wrap the library in a C ABI and call that. It's a well-understood process in QT land. I think this project is more an effort to give R…

There's a distinction between a Qt project calling Rust code via a C ABI versus a Rust program bootstrapping Qt.

The author hand-edits a C++ file, autogenerated by CMake. In that sense it still needs a C++ compiler as part of a build step.

A binding relying only on Rust and QML might replace the C++ boilerplate with a Rust equivalent.

Re: Rust and QML: a timely example

#7
post #2

Is it just me or it feels way too ugly? Multiple opaque layers of abstraction plus Rust kind of feels shoehorned when it's called from C++. Something tells me it's terribly difficult to write, debug and deploy. I don't exactly see the benefit of adding Rust here.

C++ and Rust are very different. A direct binding is near impossible. This project takes a pragmatic approach: the GUI part is QML/Qt and the logic part is Rust. The separation is quite strict. The demo application showcases more of the features than the blog does. Notably, the mapping between the Qt data models and the Rust code is something that makes development effective. This will be emphasized in the upcoming FOSDEM presentation.

https://fosdem.org/2018/schedule/event/rust_qt_binding_gener...

Re: Rust and QML: a timely example

#8
post #6
post #4

Earlier quoted context omitted.

> I don't exactly see the benefit of adding Rust here. From that perspective, there isn't any. Dyed-in-the-wool "QT app-devs", if there is such a category (KDE devs?) already have access to Rust libraries, in the same way they have access to most stuff in weird compiled languages: you wrap the library in a C ABI and call that. It's a well-understood process in QT land. I think this project is more an effort to give R…

There's a distinction between a Qt project calling Rust code via a C ABI versus a Rust program bootstrapping Qt. The author hand-edits a C++ file, autogenerated by CMake. In that sense it still needs a C++ compiler as part of a build step. A binding relying only on Rust and QML might replace the C++ boilerplate with a Rust equivalent.

The binding generator generates a binding from a JSON file. That gives C++ and Rust code. Additionally, a default Rust implementation is generated for convenience where the programmer fills in the application logic.

At no point is there a need to edit a generated C++ file. Any other build tool with C++ support could be used instead of CMake. What it should do is call rust_qt_binding_generator when the binding description changes.

The table in this blog shows what files are generated: https://www.vandenoever.info/blog/2017/09/04/rust_qt_binding...

Re: Rust and QML: a timely example

#9

Auto generated traits? Yuck. I understand the trade offs and why this makes sense. But it hearkens back to some of extremely ugly parts of older Java frameworks.

Most time on the project is spent on making a sensible binding at all. The ergonomics could definitely be improved. Rust has powerful macros that could make it simpler to use these bindings. My development time is finite.

Re: Rust and QML: a timely example

#10
post #8
post #6

Earlier quoted context omitted.

There's a distinction between a Qt project calling Rust code via a C ABI versus a Rust program bootstrapping Qt. The author hand-edits a C++ file, autogenerated by CMake. In that sense it still needs a C++ compiler as part of a build step. A binding relying only on Rust and QML might replace the C++ boilerplate with a Rust equivalent.

The binding generator generates a binding from a JSON file. That gives C++ and Rust code. Additionally, a default Rust implementation is generated for convenience where the programmer fills in the application logic. At no point is there a need to edit a generated C++ file. Any other build tool with C++ support could be used instead of CMake. What it should do is call rust_qt_binding_generator when the binding descrip…

> At no point is there a need to edit a generated C++ file

Well then maybe your example should reflect that, where a change is made in the C++ file replacing 'Simple' with 'Time'

Post reply on HN