views:

267

answers:

7

I'm a teacher(instructor) of CS in the university. The course is based on Cormen and Knuth and students program algorithms in C++. But sometimes it is good to show how an algorithm works or just a result of task through GUI. Also in my opinion it's very imporant to be able to write full programs. They will have courses concerning GUI but a three years, later, in fact, before graduatuion. I think that they should be able to write simple GUI applications earlier. So I want to teach them it.

How do you think, what is more useful for them to learn: programming GUI with QT or writing GUI in C# and calling unmanaged C++ library?

Update.

For developing C++ applications students use MS Visual studio, so C# is already installed. But QT AFAIK also can be integrated into VS.

I have following pros of C# (some were suggested there in answers):

  • The need to make an additional layer. It's more work, but it forces to explicitly specify contract between GUI and processing data. The border between GUI and algorithms becomes very clear.
  • It's more popular among employers. At list, in Russia where we live. It's rather common to write performance-critical algorithms in C++ and PInvoke it from well-looking C# application/ASP.Net website. Maybe it is not so widespread in the world but in Russia Windows is very popular, especially in companies and corporations due to some reasons, so most of b2b applications are Windows applications.
  • Rapid development. It's much quicker to code in .Net then in C++ due to meny reasons.

And the con is that it's a new language with own specific for students. And the mess with invoking calls to library.

+1  A: 

Qt -- P/Invoke to use a C++ library from C# adds a whole 'nother layer of nonsense you don't want to even think about. If you were going to use .NET, it might be worth considering using C++/CLI, which linking managed and native code much easier.

Jerry Coffin
I don't want using C++/CLI to avoid ms-specific syntax in C++ and confusion when later writing native C++ application. There C# is better because it clearly distinguishes from C++. Additional layer has also a positive meaning - to make a clear border between GUI and algorithms/processing data. And to specify contracts explicitly.
flashnik
IMO, C# isn't clearly enough distinguished from C++ to serve much purpose, and P/Invoke doesn't emphasize a contract in any meaningful way -- anything you'd want to teach about DbC (or anything similar) gets lost.
Jerry Coffin
+12  A: 

It is better to familiarize students with Qt, as Qt is actually C++. C# is a completely different beast, and if you use C#, you will very likely get your students confused about what things are Microsoft- or C#-specific vs. what is actually defined in the ISO C++ standard, whereas this will be more obvious with just C++. Moreover, Qt and C++ are portable, so your students who are using Mac OS X or Linux will thank you for choosing a cross-platform framework (Qt also works on Windows); whereas, if you use C#, you will force your students to use Windows (yes, there is Mono, but it doesn't work nearly as well as Qt does across platforms).

You might also be interested in using my C++ Project Template which provides sufficient infrastructure for devleoping a Qt GUI application in C++ using CMake, and has been tested and verified to work under Mac OS X and Ubuntu Linux (and, if I get feedback on Windows, I will ensure it works there too). The template includes code that brings up a "Hello World" GUI in Qt when run with the "--gui" commandline option.

Michael Aaron Safyan
Someone asked what problems I had with Mono, so, here goes... I am using Mac OS X 10.6 Snow Leopard. I had lots of difficulty getting Mono to work, and ultimately gave up on it. For OS X users, there is also the confusion as to whether it is better to install Mono using the DMG or using MacPorts. And, on top of that, it is even larger than the Qt SDK (and the Qt SDK is pretty big). At least with Qt, there is the option to install only the QtCore and QtGUI frameworks (if one uses the Qt Framework instead of the QtSDK package).
Michael Aaron Safyan
Side note: why would you even consider MacPorts, if there's official Mono distrib from Novell for Mac OS X? :-)
Franci Penov
@Franci, I generally install things using MacPorts, because if I want to install anything that depends on Mono using MacPorts, MacPorts will install its own copy of Mono, anwyay, so might as well install it once using MacPorts. Also, a benefit of using MacPorts is that it is easier to update installed software, and there is no need to worry about dependencies, as MacPorts automatically fetches and installs the dependencies. That said, there are certainly instances where using MacPorts instead of the DMG is a bad idea... Mono, Qt, and MySQL being examples where one should avoid MacPorts.
Michael Aaron Safyan
In my case all the students use Windows. At least by now. @Michael, thank you for your offer to use your project, I'll download it and try.
flashnik
To add to Michael's anti-mono notes, Mono seems to provide a terrible user experience to non-Windows users. I use KeePass with Mono on Linux, and it looks like someone crammed a really poor forgery of the Windows XP UI into Linux, rather than using native theme settings. On the other hand, it uses some of my theme settings, so for example, I get white menus on gray text. Perhaps this is a KeePass problem and not a Mono problem, but it makes me very suspicious of using Mono for cross-platform GUI development. Example: http://twitpic.com/198c8f
notJim
+5  A: 

I would recommend Qt simply because it is C++, and not C#.

Interfacing between C++ and C# can be messy, and in my opinion would distract students from the object of the exercise (the algorithms, as you said).

Peter Alexander
+1  A: 

I would use C# for the GUI stuff.

There are way more C# jobs out there than C++ using Qt, so why not prepare them for what they are most likely to encounter after they graduate?

One problem I have seen with academia quite often is not teaching what is used in the real world. Sure, all that other stuff is cool, and I personally like it. Experience of real world use after school would be my priority though.

Also, I don't think asking a bunch of programmers is generally the best source of advice on this subject. I would look at what technologies most companies are hiring for in your location, very likely for most desktop GUI stuff it will be .NET or Java.

Dana Holt
I disagree. The students will have to worry too much about handling un-managed code rather than focusing on developing the GUI.
snicker
@snicker - If they were writing some kind of enterprise level app I would agree, but for the complexity they are doing I think it would be fine.
Dana Holt
There's actually a lot of jobs requiring Qt popping up, so it's not all that esoteric.
Peter Alexander
Let's be real here, compared to .NET Qt is a statistical outlier.
Dana Holt
A: 

Here's a wild idea, (re)write the algorithm in C# for the GUI app. This serves too purposes, 1) it neatly sidesteps the whole mucking with P/Invoke, C++/CLI or COM just to draw some pretty pictures and 2) unlike using Qt it gives you the opportunity to emphasize the distinctions between an algorithm, a program and a programming language.

Logan Capaldo
No, it's unacceptable to write algorithms in C#. C/C++ is good for computations/algorithms while .Net is good for rapid and safe development.
flashnik
You must be using a very strange definition of "algorithm" if it is unacceptable to write them in C#. That or there's a lot of "unacceptable" C# code out there in the world. You can certainly implement every algorithm in CLRS in C#. Heck, most algorithms are described in pseudo-code! I'm a little disturbed that this is the attitude taken by a CS instructor.
Logan Capaldo
@Logan, I meant that it is unacceptable from the point of course structure. The main aim of a 2-year course is to teach them writing effective algorithms in C++. Of course they can be rewritten in C#. But in C# they'll be less effective (e.g. measured CPU usage) because of safety of C#.
flashnik
+1  A: 

writing GUI in C# and calling unmanaged C++ library because VS is a good starting IDE and .NET is the most comprehensive set of libraries available. This assumes your students have access to Windows computers. If they are on linux, QT would be the way to go.

Iggy
We use VS even for C++ programming so it's not a problem :)
flashnik
A: 

I don't think it makes any sense to start creating C++/C# unmanaged/managed hybrid applications here.

For teaching it will certainly be easier if the students don't have to learn a new programming language for the Gui. Also interfacing between managed and unmanaged code and the different types in the different languages will complicate things unnecessarily. Much time and effort will be wasted on these topics, not helping anybody to learn the algorithms that are the topic of the course.

Also for "real life" usefulness I think it's clear that only very few projects will use a C++/C# hybrid. If you do your GUI in C# you will also do the logic behind it in that language. I don't see what would be gained from creating the GUI of a C++ application in C#.

sth