D, Rust, and GTK+ [was How programmers transition between languages]

Russel Winder russel at winder.org.uk
Sun Jan 28 16:08:06 UTC 2018


On Fri, 2018-01-26 at 20:31 +0000, John Gabriele via Digitalmars-d
wrote:
> […]
> 
> With Rust's extra complexity (over D) of ownership/borrowing, 
> lifetimes, and no GC, although we may currently see a push for 
> more Rust in Gnome for system-level code, I think D may beat it 
> for writing *applications*.

Being in the middle of rewriting a C++/GTK+ application in both Rust
and D, both have pluses and minuses.

Documentation, and examples, for both D and Rust, are woefully
inadequate, but Rust is getting better quite rapidly because it has
something of a dedicated workforce. 

The D and Rust architecture models are surprisingly similar in terms of
mental model, however Rust's current lack of inheritance really is a
pain: currently D wins on this hands down.  The gtk-rs people are
looking to solve this by exposing the internal inheritance mechanism to
the aPI users.

Rust/Cargo win hands down over D/Dub. This is a problem with Dub. One
that seems unlikely to be addressed. This means using SCons and Meson
for D code, which works surprisingly well, and yet has some huge
problems.

D appears to be clumsier than Rust for error handling. I think this may
be that the monad-based approach is working better for me just now. Of
course there are irritants with the monads approach.

(Side bar: The Rust and D bindings are generated from the GTK gir files
which is great, but the C++ API is hand crafted which leads to lots of
inconsistencies with the underlying C API.)

> I'm planning on learning more D, then trying out GtkD to see how 
> it compares with Python + PyGObject for some little apps.

Where Python and PyGobject (based on gir files) wins is you stop having
to faff around with all the compile time types: the dynamic typing of
Python has many huge benefits for writing GTK+ applications compared to
C++, D, Rust. 

For my application, I am using GStreamer. The GStreamer core team are
backing Rust since it is the only language they trust with regard to
managing memory. Clearly C is totally inadequate but if you code is in
C you allow Stockholm Syndrome. C++ is also inadequate but more due to
the pointer types being add ons and not really checked. Rust is clearly
far superior to C++ in this respect, at the risk of the borrow checker
sometimes being impossible to satisfy. The GStreamer people refuse to
accept the existence of a garbage collector. On the other hand there is
GStreamerD, but the problem is you have to deduce or infer how to use
the D binding from the C API. And there is no work other than Mike
Wey's in the GtkD suite (*). 

If the D community think D is a Rust beater for GTK+ applications then
get involved with keeping the GtkD binding up to date, do not assume
Mike will do all the work.



(*) Huge vote of thanks to Mike for continuing to keep the GtkD suite
up to date.

-- 
Russel.
===========================================
Dr Russel Winder      t: +44 20 7585 2200
41 Buckmaster Road    m: +44 7770 465 077
London SW11 1EN, UK   w: www.russel.org.uk
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20180128/5d5bb87d/attachment.sig>


More information about the Digitalmars-d mailing list