How to create a C program and use graphical Java / C # interface?

11

I'm studying graphical interface in C, and I realized it's very complex and tiring.

So I wanted to know if there is a way to create a C program and use a graphical interface in Java or C #. With frameworks or not ...

    
asked by anonymous 07.09.2015 / 20:26

2 answers

10

There's even how, but it does not usually compensate.

What you usually do is build the application in a higher-level language, such as Java and C #, and have access to the easier frameworks and only resort to C when you need the performance or access some feature that is not available in these languages. But it's common for people to realize that they do not need C at all in almost every application.

You can try to go the way of doing the C application and calling Java or C # when you need it, but it's quite complicated and does not make up for it. As far as I know, no one tried, not least because there is no advantage to it.

These languages run in a controlled environment that causes difficulties to be invoked. These environments take care of execution, which is the opposite of what is done in C. In general an application with GUI has as its base the interaction with the user. It is a framework that appropriates execution, you do not have the option of not using the framework . Are you going to use C to call this? For what? I think you imagine that the C and C # functions (for example) will naturally talk as if it were the same thing. This does not happen. The memory models, organization of the data structures and form of call of the algorithms are absurdly different with enormous complications for the C call. The application will not easily transition between the two. It will only be more or less easy to call simple C functions from C # which is a language that was thought to interact well with C in this sense (call something external to C #).

Even when doing something in Java or C # and will call a function in C is not something so simple, especially in Java. So avoid it until it really is needed.

Another way would be to make a client-server architecture using a GUI executable in the language you want and the server written in C. This is almost always unnecessary. Must have a real reason for the server to be written in C. C has some unique advantages but also has several disadvantages for any application. Only use if you need these unique advantages and you can afford the disadvantages, which does not seem to be the case.

If the comparison was with other languages you might even start to see some advantage. The difference of Python for example and C is brutal. Even there, the scheme of doing the GUI in the highest level language and only delegating a few critical functions for performance prevails.

Anyway I find it wrong to say that doing GUI in C is complex and tiring. But I will not go into detail because it is opinion. Of course it's a bit more complex, but in C everything is more complex. Do not want complexity use another language.

And there's still the middle ground of using C ++, probably with Qt. Some will say it's the best of both worlds. Others will say that it is the worst of both worlds.

C is rarely used for "common" applications. Even C ++ is adopted with parsimony. You must have a reason for your adoption. The use of Java or C # has its drawbacks, but if it can be used in the project, it would hardly be better to use C together, except for something very timely, and look there.

As Luiz Vieira says in the comment below, it is usually best to write everything in one language, even if there is already a legacy. Trying to do the GUI in another language and trying to integrate with the legacy C code will only work if it has been well written, thought to work in a very modular way. Which confirms the difficulty of doing the opposite. The Java and C # libraries were not done in a modular way, there is a dependency between the parties that border on the insane.

    
07.09.2015 / 20:37
5

If the application is going to be only for windows it is easier to do in Visual Basic, for example, because the .NET framework is quite complete, it will provide everything you need to make a commercial application. It's an example, but I do not know if that's the case.

Anyway, I agree with the bigown, because I myself had started programming in C, but now that I started really entering the area and meeting people who program professionally, I discovered that only those who know how to program in C use it only in very specific cases, so much that my teacher recommended that at least at the beginning I learned some .NET language because here in my region there is no market for C programmer.

    
07.09.2015 / 20:45