views:

619

answers:

5

I have once heard a saying,we could live without linux,but we definitely could not live without gcc.It seems there is only one c compiler in the Linux world.Is there any alternatives to gcc and does programmers under AIX/HPUX/Solaris use gcc to develop programs?

thanks.

+4  A: 

There's certainly at least one alternative to gcc on Linux: clang is a C-compiler (and related dialects, although as far as I can see, the C frontend is much more mature than the other dialects) utilising LLVM. Apple supports the development of LLVM & friends, I think; it's useful for their Grand Central Dispatch/OpenCL stuff, IIRC.

RAOF
A: 

Sun Studio 12 is now available as a free download for Linux (X86 flavors, at least) and all Solaris variants. I don't know how the X86/Linux version of the compiler compares, but the Sparc/Solaris version of the compiler is capable of producing significantly more optimized code than GCC, and the debugger is far more powerful than GDB. The downside is that you get stuck with a sluggish Java based GUI for the debugger.

Russell Newquist
A: 

In terms of C compilers, I wouldn't be able to do without gcc. But C isn't the only game in town. I quite often put together fast little applications in Python and slightly more complicated desktop ones in Java (the Sun one, not gcj).

I wouldn't choose your language for an application. It's a far better option to choose your application then do it in a language that suits. If C is all you know then use it. But I find the huge library of data structures and algorithms in Java (and Python) to be invaluable at cranking out code fast.

I don't know much about HPUX or Solaris but, even on AIX, I prefer to use gcc in preference to xlC, the IBM compiler.

paxdiablo
+3  A: 

Intel has a "non-commercial" C++ compiler here. Make sure you read the license faq here it does come with strings attached.

Here is a list that might be of some help.

Anand
+2  A: 

If you are looking for a lightweight and fast C compiler TinyCC (see also Wikipedia) is definitely worth a look.

There are some downsides, though. It only performs very few optimizations and the latest stable version only supports the x86 architecture although there is already experimental x86_64 support in the development branch.

For now, I would probably stick with GCC for any serious programs considering these flaws of TinyCC.

The only use-case where TCC could come in really handy nowadays is to use it as an interpreter for C code. I have not measured the performance but I can imagine that a small "script" in C can smootly compete with Bash code (in terms of parsing and execution speed).

The developers even succeeded in interpreting a Linux 2.4 kernel in realtime and boot it right away! There is an ISO image floating around which just works perfectly in Qemu.

As GCC is based on code that dates back several decades ago when there was not much knowledge on code structuring, appropriate use of design patterns etc., the GCC developers are maintaining a rusty and error-prone basis. Unfortunately the code is mess and there is no alternative to a complete rewrite. That probably also the reason why the developers of LLVM also came up with Clang and started from ground-up. In the long-term I really hope that there is going to be a proper replacement for GCC which does everything conceptually right from the beginning. Clang sounds like a worthy replacement although I am not completely comfortable with their choice of using C++ but that is another topic. :)