Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does gcc support Java and not C# [closed]

Tags:

c#

gcc

I've seen this question and I'm wondering if there is any technical reason to justify the fact that gcc offers support for Java but not for C#. If I understand, Java is an interpreted language too. If Mono offers a C# compiler and an implementation of the CIL, why wouldn't it be possible to create a gcc c# compiler that would convert C# to IL and then compile it statically ?

like image 742
tobiak777 Avatar asked Sep 27 '14 19:09

tobiak777


People also ask

Does GCC work with C?

GCC is an integrated distribution of compilers for several major programming languages. These languages currently include C, C++, Objective-C, Objective-C++, Java, Fortran, and Ada.

Does GCC support C#?

I've seen this question and I'm wondering if there is any technical reason to justify the fact that gcc offers support for Java but not for C#. If I understand, Java is an interpreted language too.

Is GCC compiler only for C?

Supported languages As of May 2021, the recent 11.1 release of GCC includes front ends for C ( gcc ), C++ ( g++ ), Objective-C, Fortran ( gfortran ), Ada (GNAT), Go ( gccgo ) and D ( gdc , since 9.1) programming languages, with the OpenMP and OpenACC parallel language extensions being supported since GCC 5.1.

Does Java use GCC?

Introduction. GCJ stands for the GNU Compiler for the Java Programming Language. Within GCC, it comprises the Java programming language front-end (gcc/java), a runtime library (libjava) and other helper libraries (boehm-gc, libffi and zlib).


2 Answers

Because you haven't submitted a patch to add C# support.

like image 184
Ben Voigt Avatar answered Sep 27 '22 22:09

Ben Voigt


If a compiler tool chain doesn't support a particular language, it's often because there isn't enough interest for that language in the time being. So, not a technical reason per se - just that they don't want to waste their developers' time on that, for now.

There is no particular technical reason why C# can't theoretically be implemented as a statically compiled language. In practice, however, generics is one of the core strengths of C# but unfortunately, due to the way generics work in this particular language, any efficient implementation of them generally benefits a lot from the presence of a JIT compiler. When you define a generic type in C#, you can efficiently get a piece of machine code for all its concrete types where the type arguments are classes and one piece of machine code for each of the used struct types. However, when you attempt to create a new concrete type across another binary, then your most likely ally in creating the new piece of machine code required for those type arguments is a JIT compiler.

If you're interested in creating statically-linked programs in C# however (and not specifically in gcc), then Mono does offer a tool (called mkbundle, I think) that allows you to create completely standalone binaries from C# code.

like image 41
Theodoros Chatzigiannakis Avatar answered Sep 27 '22 23:09

Theodoros Chatzigiannakis