58

After learning a bit of how LLVM work I'm really excited about how portable low-level code can be generated and how modular this 'thing' is built.

But I discovered today the existence of C-- that seems to share some concepts with LLVM.

So I'm looking for some information helping me understand the main differences between these two projects... and why both exist.

For me LLVM looks a bit like the ultimate Swiss Army knife for compiler infrastructure, and C-- looks far less advanced.

Keith Thompson
  • 254,901
  • 44
  • 429
  • 631
Alois Cochard
  • 9,812
  • 2
  • 29
  • 30
  • 7
    apparently, you can' have `-` in a tag. cminusminus it is. – aaronasterling Oct 08 '10 at 14:29
  • I don't know about quality of implementation, but LLVM seems to have a lot more action on it's mailing lists. – Bill Lynch Oct 08 '10 at 14:31
  • using 'mm' is a common way to express minus minus. i believe it's used as a joke for many c++ bindings, such as glibmm. 'glib--'. i don't imagine newcomers are going to know to search for cmm tho. – Matt Joiner Oct 08 '10 at 14:32
  • @matt also, [cmm](http://hackage.haskell.org/trac/ghc/wiki/Commentary/Compiler/CmmType) already exists as a completely different language than [c--](http://www.cminusminus.org/). – Thomas M. DuBuisson Oct 11 '10 at 16:10
  • I just added a c-minus-minus tag (already used by two other questions. – Keith Thompson Nov 13 '11 at 00:53
  • 1
    @ThomasM.DuBuisson: why do you say "completely different"? From your first link: "Cmm is the GHC implementation of the C-- language." Although I don't know if this was true when you wrote your comment 20 months ago. – dubiousjim Jun 02 '12 at 06:42
  • @dubiousjim I don't know, maybe because I believed it? At any rate, Cmm isn't C-- - the paragraph you quote goes on to mention there are significant differences. – Thomas M. DuBuisson Jun 02 '12 at 14:32

1 Answers1

54

They differ in how expressive the low level machine type system is.

The LLVM machine is pretty expressive. The C-- machine on the other hand, puts a lot of responsibility on the language front end. Quoting from the C-- FAQ: "simply, C-- has no high-level types---it does not even distinguish floating-point variables from integer variables. This model gives the front end total control of representation and type system"

Also visually they look a lot different. C-- looks a lot like C, LLVM looks a lot like assembler.

Pragmatically, LLVM has a lot more momentum right now. It has a JIT compiler, Apple is using it for 3D pipeline things and people are using it to connect to GCC and all sorts of weird and wonderful things. Someone called it "almost absurdly easy to work with".

On the other hand C-- is much smaller and probably easier to entirely comprehend. (I imagine a normal person with some dedication can fully understand all aspects of it.)

Prof. Falken
  • 24,226
  • 19
  • 100
  • 173
  • 1
    So, if I understand correctly the main difference is the abstraction level of the intermediate representation used by theses compiler. thanks ! – Alois Cochard Oct 08 '10 at 15:44
  • 6
    @Alois Cochard, that is how it seemed to me. I am no compiler expert, I just play one on Stack Overflow. :-) – Prof. Falken Oct 08 '10 at 20:12