tags:

views:

217

answers:

4

This is sort of a strange question, but oh well.

I feel like writing a (rich) text editor mainly to be used for note-taking, in either C or C++, using most probably GTK or Qt for the UI.

The problem is that I can't really decide what to use. I know both C and C++, C a little better. I've never used Qt but I'm completely fine with learning, and I have some experience with GTK.

Is there any particular combination you would give preference to and why? In particular, do you think there is any advantage to using C++, or will C do just fine?

Thanks a lot!

+1  A: 

C++ is probably, better suited for RAD (Rapid Application Development) than C. This is because of its additional features such as classes and objects. C I think would just handicap you because, you do not have some stuff like classes and objects.

Usually, OO languages are suited for GUIs and what not whereas, languages like C are for low-level driver stuff where efficiency is of great importance (even though its a little debatable).

thyrgle
At the same time, it usually takes as minimum as 5 years to become an experienced C++ expert. Qt, at least what is was a couple of years ago, almost has nothing to do with C++ and looks like C with classes. Not to mention the re-invention of std::(w)string, STL containers and algorithms.
Vlad Lazarenko
@Vlad: I strongly disagree on the 5 years -- maybe one or two years. But @thyrgle: You can use OO design in C -- it's just not supported by the language. Too many people concentrate on OO as a process, rather than as a design philosophy. I don't dislike this answer enough to downvote it, but I think it has serious problems.
Billy ONeal
@Billy I'm still learning C++ after nearly 20 years.
Pete Kirkham
@Pete: We're all still learning all the time. Doesn't matter what language, there are always going to be new things out there to learn. But I don't think it takes 5 years to obtain competence in the language. (I myself have only about 2.5 years real C++ experience, yet it is my favorite language and I've answered enough questions here to get the gold badge thingy for it....)
Billy ONeal
+4  A: 

I'm writing an editor myself, and I too have choose C++ and Qt.

The reasons for this:

  • C++ is CPU- and memory-efficient. I hate slow text editors with a passion.
  • Supporting libraries are almost always written in C or C++, so I can interface nicely with them (and extend them if needed).
  • Qt is a great, well supported, cross-platform/-system GUI library, and it contains a lot of generally useful base classes/algorithms. It makes C++ actually fun to use.
demonkoryu
@"Gtk and Qt" -- typo, it was first something like "the choices I am considering are Gtk and Qt", replaced it with "or" to make more sense.
houbysoft
Most "slow" text editors only slow down with big files, and then the key to good performance is not being memory efficient, but being able to work on a subset of the file at a time. This has probably three stages: (1) selectively rendering only visible content -- rendered bitmaps use a huge amount of memory, (2) manipulating small chunks without having to e.g. move half the file around to insert one character, (3) not even having the whole file in memory at once. As an approximation, these will be sorely needed as your file size moves past 10MB / 100MB / 1000 MB respectively.
Ben Voigt
Qt is designed to be used with C++. Focus on learning object-orientation and this little project could be useful for your career.
Bruce
I completely agree with Ben Voigt, take the slowest language that you can think of, and follow his advice, and compare that with the naïve editor implementation in your fastest language of choice and the first will out perform the second in all but the most basic cases, and even there, there will be no user noticeable difference (grant me the cost of launching a virtual machine if you decide to go for a language that requires it)
David Rodríguez - dribeas
Will go with C++/Qt, thanks for your answer.
houbysoft
+2  A: 

Personally, I would go for C++/Qt.

The reason for my bias is that unlike GTK, Qt is not only a UI toolkit, but provides a lot of other features like networking, database access, xml parsing... which could benefit you a lot. And all that with a consistent API.

The main fault of Qt is that it is a replacement for standard C++ library in a sense that it has its own list, string, map, hash... classes. Those have much nicer API than STL and are (IMO) much more pleasant to work with, but if you learn C++ this way, it will be much more difficult to return to standard C++ if you ever need to.

If you want a gentle introduction to OOP with C++ and Qt, see this book (free to download): http://cartan.cas.suffolk.edu/oopdocbook/

Ivan
Thanks for the link, looks very useful.
houbysoft
It seems to be a reigning misconception here on SO that GTK does _not_ provide a framework for application development, with containers, key-value stuff, etc. I can assure you that it does.
ptomato
@ptomato As far as I see (not counting GLib, GObject..., but only GTK) it doesn't.To quote the site: "GTK+ is a library for creating graphical user interfaces. It works on many UNIX-like platforms, Windows, and on framebuffer devices."
Ivan
@Ivan, GTK can't be used without GLib and GObject. They may be split up into separate modules, but the whole thing is most certainly one application development framework. So, you can't really not count GLib.
ptomato
A: 

C++ is a better C. C++ can do whatever C can do and in addition supports object-oriented and generic-programming design paradigms. 'SUPPORT' here means the language itself and the facilities around it provide ease, pleasure and productivity for the programmer to achieve these design goals. Go for C++ and you won't regret.

If you choose Qt, you must also choose C++ because Qt is a C++ library. If you are programming a rich text editor, I don't know how much it's left for you to do on top of Qt's text editor which well supports rich text. You probably only need to concentrate on adding domain-specific features of your interest.

Alex Y.
You can use Qt with other languages than C++. Look here: http://qt.nokia.com/products/programming-language-support/
demonkoryu