How to create a program in C and use Java/C#GUI?

Asked

Viewed 3,445 times

11

I’m studying graphic interface in C, and I realized it’s very complex and tiring.

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

  • 1

    You can accept an answer if it solved your problem. You can vote on every post on the site as well. Did any help you more? Something needs to be improved?

2 answers

10

There’s a way, but it doesn’t usually make up.

What is usually done is to create the application in a higher level language, such as Java and C#, and with access to frameworks more "easy" and only resort to C when it needs maximum performance or access some resource that is not available in these languages. It’s just common for people to realize that they don’t need C for anything in almost every application.

You can try going the way of doing the application in C and calling Java or C# when you need it, but it’s very complicated and it doesn’t pay off. As far as I know, no one’s tried, because there’s no upside to this.

These languages run in a controlled environment that brings difficulties to be invoked. These environments take care of the execution, which is the opposite of what is done in C. In general an application with GUI is based on the interaction with the user. He is a framework that appropriates the execution, you do not have the option of not using the framework. You gonna use C to call it? What for? I think you imagine that the functions of C and C# (for example) will naturally talk as if it were the same thing. This does not happen. The memory models, data structure organization and call form of the algorithms are absurdly different with huge complications for C to call. The application will not transit one and the other easily. It will only be more or (well) easier to call simple C functions from C# which is a language that has been thought to interact well with C in this sense (calling something external to C#).

Even when you do something in Java or C# and will call a function in C, it is not so simple, especially in Java. So you avoid it until it’s really necessary.

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. Almost always this is unnecessary, need to 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 can afford the disadvantages, which does not seem to be the case.

If the comparison were 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 making the GUI in the highest-level language and only delegating a few critical functions to performance prevails.

Anyway I consider wrong the statement that making GUI in C is complex and tiring. But I will not go into detail because it is opinion. Of course it is a little 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 it’s the worst of both worlds.

C is rarely used for "common" applications. Even C++ is adopted sparingly. It needs a reason to justify its adoption. The use of Java or C# has its drawbacks there, but if it can be used in the project, it would hardly be better to use C together, except in something very punctual, and look there.

As Luiz Vieira says in the comment below, it is generally better to write everything in one language, even if there is already a legacy. Trying to make 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 well modular. Which confirms the difficulty of doing the opposite. Java and C# libraries were not made in a modular way, there is a dependency between the parts that borders the insane.

  • I agree with almost everything in your reply, except "No one has tried, because there is no advantage in this". To say that no one has tried is (well) difficult, and the most useful discussion should be in the second part of that sentence. In fact, it can be useful in the case of legacy C systems, which the developer just wants to port the interaction. But again I agree with you that in this case it would probably be more advantageous to rewrite all the main code in C# or Java and access important legacy algorithms maintained in C (of course, assuming it was originally well organized and separate rs).

  • 1

    Yeah, I’m gonna get a better one.

  • Thanks! But, even so, already won my +1. Good answer. :)

5

If the application will be only for Windows it is easier to do in Visual Basic, for example, because the . NET Framework is quite complete will provide everything you need to make a commercial application. It’s an example, but I don’t know if it’s your case.

Anyway, I agree with Maniero, because I had started programming in C myself, but now that I’ve really started getting into the field and meeting people who code professionally, I’ve found that only people who know how to code in C use it only in very specific cases, so much so that my teacher recommended that at least at first I learn some language. NET because here in my region there is no market for C programmer.

  • I also know programming in java and c# I wanted to learn structured languages so I’m learning C But thanks For the help...

  • C is a language very close to low-level languages such as assembly eventually the job is much more.

  • This statement is very strong: "I have found that rarely does anyone use C for any kind of thing." In the context of most commercial applications this is true, but C (and C++) are widely used languages. Remember that in computing one must always contextualize. There is no worst or best language. There is language (or set of language) that best suits a given problem.

  • @Cantoni, yes, I agree with you, maybe I haven’t phrased very well what I meant, which is actually that now that I live with and know several programmers, I found that even those who know how to program in C give preference to high-level languages and under their influence I decided to learn C#, and I confess that I am enjoying it much more, C# is much more objective and easy to program...

  • @Ezequielbarbosa, but remains the fact that you are putting C in a specific context of commercial applications (information systems). For these cases, languages like C#, Java, VB.NET, Python are without a shadow of doubt more appropriate than C. In other words, I believe that this comparison should not exist. About learning Java or . NET too early, I have my hangovers. Computer courses should expose the student in the first periods to only C and C++, since they give the foundation necessary to understand concepts such as pointers, memory management, etc.

  • @Ezequielbarbosa, you’ve heard of Qt Framework, it’s great to create graphics systems using C++

Show 1 more comment

Browser other questions tagged

You are not signed in. Login or sign up in order to post.