Re: Would it be possible that gtk implementation in C++

On Fri, Aug 08, 2014 at 10:06:28AM +0800, 黄羽众 wrote:
Thank you for point out predecessors' question!

I read the question and get some points, but I thinks the situtations change a lot and I am not ask the 
same question.

1. I am not ask for why GTK choose to implement in C, I know it have some historical reason. I want to make 
a proposal that gtk could be re-written with c++ just as GCC does. I want to discuss with you whether it is 
a good idea.

It's of course possible from an academic perspective, even though as a
lot of people have already said it would not be very practical. My
suggestion is that anyone who wants to go forward with this makes a fork
and works on it, with no expectations that it would ever be merged back.
Take the opportunity to break the ABI and make a new great GTK+ inspired
toolkit. If it's good then people will adopt it.

2. Situations change a lot. Back to the time GTK was born, C++ is also very primitive so the developers 
would rather implement an object-system by hand. But nowadays C++ is stable and have many cool features 
especially in C++11 and the in-coming C++14. C++'s object-system is becoming more and more complete and add 
many useful features in GUI development such as exception, multi-threads and so on. I think due to the same 
reason did GCC turn to C++.

C is not updated as rapidly as C++ but it is modernized occasionally.
Support for multi threading is for example an optional part of C11.
This doesn't really matter too much for GTK+ though since it uses Glib.

3. Now, from the view of app developers, who are very likely learned C/C++/Java in classes, and learn 
Python/JS/PHP/Nodejs after class. And very probably have experiences coding with QT, HTML5, Android. They 
can't be more familiar with OOP and C++. But when they turn to GTK, they have to expand one line in C++ 
into three or more lines in C. This will threaten many developers. Although there are gtkmm available, but 
gtkmm didn't gain enough official support and recommend as GTK, and much fewer reference, help, support 
available. The official recommand is gtk in c rather than gtkmm in c++, so many devlopers read some 
tutorials and feel threatened and leave. What's worse, gtkmm didn't wrapper all of the gtk featurese. In 
some complex cases, developers have to use the low level gobj pointer to get things done.

If the impression that developers get is that they have to use C or that
they are strongly recommended to use C; then that sounds like a problem
with the documentation.

Now is in 2014, It can't be more normal to develop GUI application with OOP style. I think it's time to 

GTK+ is already object oriented, and good GTK+ applications are often
that as well even when they are written in C. You don't need support for
object orientation in the language in order to use object orientated

GTK could be rewritten in C++, and what's more important, GTK should officially recommend to develop apps 
in C++, which can't be more familiar to GUI developers.

The GTK+ project web site already says on its first page that while the
toolkit itself is written in C it also supports a wide range of other
languages. That's fairly official to me.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]