Hi,

I noticed many programmers accuse C++ as very hard language for GUI and very good language for the code.

Is there any way to integrate 2 languages, C++ and any other language which is easy to make GUI with?

Thanks.

Recommended Answers

All 5 Replies

Under dot net, it is very easy to mix languages (C++, F#, C#, VB).
Others are also available.

I have not done any GUI programming outside of MFC or dot net, so I cannot answer for other operating systems or platforms.

google for "mixed language programming" and you will find quite a bit about that topic. Its easier to mix C with other languages than it is c++, but it can be done. C++ will probably need some C wrapper functions in order to mix them with other languages because of the way c++ compilers mangle function names.

I did this in .NET - needed to communicate on a low level with a bit of hardware and it just wasnt possible in C#, so I used Managed C++ and then use that as a library in your C# interface or whatever.

Member Avatar for MonsieurPointer

Take a look at Qt (http://qt.nokia.com/products/); with it, you create GUIs in C++ with (relative) ease. It even comes with its own IDE.

For GUI programming, it is pretty much as easy to do it in C++ as with any other language, it is not a matter of the language but of the GUI library (or package) that you use. For a long time, under Windows, main-stream GUI programming was with MFC which was terrible in whatever language you used, but it was even worse in C++. This had the consequence that a lot of programmers used to write GUIs in VB and wrap all the important code inside DLLs written in C++ or C (because VB is terrible for anything except really simple stuff, like the code behind most GUIs). However, there are other GUI packages, like Qt (Nokia) and VCL/CLX (Borland), which are really easy to use in C++ (even for a while, Borland's VCL was called "the VB-killer" because it made programming GUIs in C++ even easier than in VB, which would have made VB entirely irrelevant at that time, it survived only due to inertia).

Today, the picture of GUI programming has leaped forward (or back) due to the .NET platform. Essentially, the new GUI system that Microsoft is trying to impose on the world pretty much rules out the use of pure C++ programming (because .NET requires a managed environment with reference semantics, which is deeply incompatible with C++). So, you have to use one of MS's proprietary language (VB.NET, C#, F#, J#, C++/CLI) to use .NET. Another, non-MS, viable option is Delphi which works also for .NET and is not as terrible as the other .NET languages. They can all be mixed with C++, mostly through wrapping inside DLLs just like in the old days when people were forced to use VB and C++ together.

In the non-Microsoft arena, things are much better. Lots of great GUI tools exist, and most of them are natively in C++. Qt is the leading figure without a doubt (development is easy, and very convenient tools are available). On a purely technical point-of-view, the VCL is probably still the best, but not free and not very popular either.

As for inter-operability between languages, for the most part you have to wrap your code inside C interface functions within DLLs (or .so objects in *nix). One exception however, Python is a high-level interpreted language that binds very well with C++, for instance, with the Boost.Python library. This is a very popular combo: C for the really low-level stuff, C++ for most of the complex software, and Python code to put a few high-level objects together and run the programs. Python is also a very popular language for GUI programming.

In any case, it is always good to isolate most of the complex software and algorithmic code inside some separate library (like a DLL or .so). So, you should do that regardless of what language you use for the GUI. Generally, mixing GUI code with library code as one big thing is a pretty bad idea. The GUI should just be a thin front-end to your code, just cosmetics.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.