View mode: basic / threaded / horizontal-split · Log in · Help
May 08, 2010
Can D be cute? (Qt)
A week or two ago I started a thread suggesting that JavaScript might be 
an interesting "VM" for D to target for web apps.  A thriving discussion 
ensured and it was a delight to read the opinions posted by many on this 
newsgroup.

The idea came out of a frustration I had with having to develop a rather 
complex application using browser-only technology, JavaScript being 
somewhat awkward to deal with the task at hand.  In the process of 
pondering the scalability of the programming task I looked to many 
different ways of circumventing programming plain old JavaScript and 
considered such things as Haxe, Cappuccino (Objective-J) and SproutCore. 
 Then it occurred to me everything I liked about D and had this fairy 
wish that D might be ideal for client side programming down to JS.

Since then, my client has gone completely off web apps for this 
particular Linux-embedded hand-held mobile device and has mandated that 
the apps will now be written as desktop apps in Qt.

Qt, as many of you will know, is a C++ GUI framework produced by 
formerly TrollTech and now acquired by Nokia for $xxx million (60 or 
160M I read somewhere).  So Nokia pays megabucks for a GUI framework 
that is C++ at its core.  Questions are, why is Qt worth so much to 
Nokia, why is Qt so damn popular on the Linux platform and what is the 
secret of Qt's success given that it is basically a C++ framework 
wrapped in some "meta-object compiler"?

Having now been exposed to Qt for a few weeks and beginning to 
understand its architecture of "signals and slots" and a pre-processor 
that compiles down to C++, I am now wondering whether D is powerful 
enough to achieve the same sorts of things that Qt seems to be doing.

If I understand correctly, Qt brings a degree of "reflection capability" 
to C++ amongst other things.  Qt does a tremendous job of circumventing 
the gaps in plain old C++ to achieve great goodness for GUI development 
by way of its meta-object compiler.

May I ask if others on this NG are across Qt and D might be capable of 
slotting into some of this market for cross-platform GUI development.

As always, discussions such as these can go anywhere and everywhere on 
DigitalMars D NG, and that's much of the joy in staying with this NG if 
only as a bystander at times.

Cheers and best regards to all,

Justin Johansson
May 08, 2010
Re: Can D be cute? (Qt)
Justin Johansson wrote:

> 
> May I ask if others on this NG are across Qt and D might be capable of
> slotting into some of this market for cross-platform GUI development.
> 

That would be QtD: http://www.dsource.org/projects/qtd

Guillaume
May 08, 2010
Re: Can D be cute? (Qt)
Guillaume B. wrote:
> Justin Johansson wrote:
> 
>> May I ask if others on this NG are across Qt and D might be capable of
>> slotting into some of this market for cross-platform GUI development.
>>
> 
>  That would be QtD: http://www.dsource.org/projects/qtd
> 
>  Guillaume

Hey thanks for the quick reply, Guillaume.

I understand from the project brief though that QtD is a "binding" to Qt.

"QtD is a D binding to the Qt application and UI framework."

Whilst QtD looks like a cool project, my question was really about 
whether D could achieve the same sorts of things that Qt does with its 
meta-object compiler.

In other words, and calling a spade a spade, Qt is a "hack" to make C++ 
more pleasant for GUI.  Would it be possible for D to achieve natively 
the same sorts that Qt does via preprocessing to C++.

Cheers

Justin Johansson
May 08, 2010
Re: Can D be cute? (Qt)
Justin Johansson:
> Whilst QtD looks like a cool project, my question was really about 
> whether D could achieve the same sorts of things that Qt does with its 
> meta-object compiler.
> 
> In other words, and calling a spade a spade, Qt is a "hack" to make C++ 
> more pleasant for GUI.  Would it be possible for D to achieve natively 
> the same sorts that Qt does via preprocessing to C++.

I suggest you to explain what such things are, and to give some examples too.

Bye,
bearophile
May 08, 2010
Re: Can D be cute? (Qt)
bearophile wrote:
> Justin Johansson:
>> Whilst QtD looks like a cool project, my question was really about 
>> whether D could achieve the same sorts of things that Qt does with its 
>> meta-object compiler.
>>
>> In other words, and calling a spade a spade, Qt is a "hack" to make C++ 
>> more pleasant for GUI.  Would it be possible for D to achieve natively 
>> the same sorts that Qt does via preprocessing to C++.
> 
> I suggest you to explain what such things are, and to give some examples too.
> 
> Bye,
> bearophile

Okay, perhaps not everybody here is across Qt.

Programming in Qt is almost C++ bu not exactly C++ as Qt uses a 
preprocessor to translate "enhanced C++" into "vanilla C++".

Here is an example that demonstrates that "Qt C++" is not "vanilla C++".

In Qt, one adorns class declarations with things that are not valid C++.

So in a class declaration you can say

class MyWidget
{
public:
	// regular C++ stuff, attributes and methods

public slots:
	// method declarations for intercepting event signals
};

You will observe that "public slots" is not valid C++.  Qt's meta-object 
compiler does a preprocessing of the MyWidget class so that methods 
declared under the "public slots:" scope are subject to some kind of 
reflection or introspection that enables events (signals) to be delegate 
to the respective methods.

In doing so, according to my naive understanding, the Qt MOC 
(meta-object compiler) compiles the MyWidget class retaining knowledge 
of compile time analysis of the MyWidget class methods which are 
designated as slots.

So this is some kind of black magic that the MOC does to Qt source code 
in order to make event routing easier.  The concepts of reflection come 
to mind here.  In a way the MOC processor must be keeping a lot of the 
static analysis of classes around in similar fashion that Java does.

Accordingly it is fair to ask why does Qt do this?  Obviously Qt 
designers do not feel that vanilla C++ is adequate for cutting GUI apps 
which is why they resort to a preprocessor.

Now I was thinking about why is C++ deficient for Qt to go to such 
resorts.  And if vanilla C++ is deficient for GUI programming, and given 
that D is viewed by many as a "better C++", then can D do natively what 
Qt has to do with a preprocessor?

I'm not an expert on Qt or its MOC (only 2 weeks into it).  Perhaps 
others on this NG might cotton on to what I'm trying to express and 
chime in.

Does the simple example above help explain what I'm on about?

Cheers

Justin Johanssom
May 08, 2010
Re: Can D be cute? (Qt)
Justin Johansson:
> You will observe that "public slots" is not valid C++.  Qt's meta-object 
> compiler does a preprocessing of the MyWidget class so that methods 
> declared under the "public slots:" scope are subject to some kind of 
> reflection or introspection that enables events (signals) to be delegate 
> to the respective methods.

More info about QT signals and slots:
http://doc.trolltech.com/4.6/signalsandslots.html

But if you look for a solution integrated in the D2/D3 language, then JavaFX bind and triggers seem nice (this stuff is useful for GUIs):
http://java.sun.com/javafx/1/tutorials/core/dataBinding/

Bye,
bearophile
May 08, 2010
Re: Can D be cute? (Qt)
bearophile wrote:
> Justin Johansson:
>> You will observe that "public slots" is not valid C++.  Qt's meta-object 
>> compiler does a preprocessing of the MyWidget class so that methods 
>> declared under the "public slots:" scope are subject to some kind of 
>> reflection or introspection that enables events (signals) to be delegate 
>> to the respective methods.
> 
> More info about QT signals and slots:
> http://doc.trolltech.com/4.6/signalsandslots.html
> 
> But if you look for a solution integrated in the D2/D3 language, then JavaFX bind and triggers seem nice (this stuff is useful for GUIs):
> http://java.sun.com/javafx/1/tutorials/core/dataBinding/
> 
> Bye,
> bearophile

Okay, I think we are on the same wavelength now.

So how far removed is a solution integrated into D2/D3?

JJ
May 08, 2010
Re: Can D be cute? (Qt)
Justin Johansson:
> So how far removed is a solution integrated into D2/D3?

I don't think D2 will change for this. For D3 there is a bit more probability, but as I have said those features are mostly for GUI programming, and so far D doesn't look designed to help GUI creation.

If you care about GUIs in D then I suggest you to do what I have done with unit testing: to use what the language offers you for some months (or some years, as in my case), and to use other languages with better GUI integration/usage too to learn from them, and then to distil what you have learnt in a list of what you think is both important and harder to do with the standard D2 language, trying to keep things as simple to implement as possible. After you have discussed such list with other people you can then use it to write an enhancement request :-) And that will be the starting point. Designing things is a lot of work.

Bye,
bearophile
May 08, 2010
Re: Can D be cute? (Qt)
Justin Johansson wrote:

...
> Qt, as many of you will know, is a C++ GUI framework produced by
> formerly TrollTech and now acquired by Nokia for $xxx million (60 or
> 160M I read somewhere).  So Nokia pays megabucks for a GUI framework
> that is C++ at its core.  Questions are, why is Qt worth so much to
> Nokia, why is Qt so damn popular on the Linux platform and what is the
> secret of Qt's success given that it is basically a C++ framework
> wrapped in some "meta-object compiler"?

1: Nokia is going to use Qt for everything, most importantly Symbian and 
Meego. 

2: It's attractive not only because it is so huge, well designed and 
supported, but also because it performs, is cross-platform and looks good 
everywhere (as opposed to Java and gtk)

3: The C++ and meta-object compiler are not the core of it's success, but 
rather the combination of:
- well-designed
- HUGE coherent framework
- good cross-platform capability
- both open source and commercial
- used by KDE, sponsored by Nokia

> Having now been exposed to Qt for a few weeks and beginning to
> understand its architecture of "signals and slots" and a pre-processor
> that compiles down to C++, I am now wondering whether D is powerful
> enough to achieve the same sorts of things that Qt seems to be doing.
> 
> If I understand correctly, Qt brings a degree of "reflection capability"
> to C++ amongst other things.  Qt does a tremendous job of circumventing
> the gaps in plain old C++ to achieve great goodness for GUI development
> by way of its meta-object compiler.

I think it is no problem, since basically it's a framework that uses runtime 
reflection coupled with an event system. This shouldn't be hard to achieve 
(or beat) in D.

> May I ask if others on this NG are across Qt and D might be capable of
> slotting into some of this market for cross-platform GUI development.

Languages wise: surely, why not? The thousands of man-years a hypothetical D 
toolkit is behind Qt plus starting from 0% marketshare poses a slightly 
bigger problem though :) Not to mention D doesn't even have compilers on all 
the platforms Qt runs on. 

> As always, discussions such as these can go anywhere and everywhere on
> DigitalMars D NG, and that's much of the joy in staying with this NG if
> only as a bystander at times.
> 
> Cheers and best regards to all,
> 
> Justin Johansson
May 08, 2010
Re: Can D be cute? (Qt)
bearophile Wrote:

> Justin Johansson:
> > So how far removed is a solution integrated into D2/D3?
> 
> I don't think D2 will change for this. For D3 there is a bit more probability, but as I have said those features are mostly for GUI programming, and so far D doesn't look designed to help GUI creation.
> 
> If you care about GUIs in D then I suggest you to do what I have done with unit testing: to use what the language offers you for some months (or some years, as in my case), and to use other languages with better GUI integration/usage too to learn from them, and then to distil what you have learnt in a list of what you think is both important and harder to do with the standard D2 language, trying to keep things as simple to implement as possible. After you have discussed such list with other people you can then use it to write an enhancement request :-) And that will be the starting point. Designing things is a lot of work.
> 
> Bye,
> bearophile

I'm in the middle of reading the PyQt book, and I really appreciate how easy it is to implement GUI design & behavior in Qt using Python. I have yet to try mixing Python with D, but it should be possible. Personally, I would leave all the GUI stuff to Python, and most of the data manipulation (where speed is crucial) to C/D.

It's probably best to pick the best language for a particular job. Unless the coder is stuck using only one language, for whatever reason it may be.
« First   ‹ Prev
1 2 3 4
Top | Discussion index | About this forum | D home