5 ms·
The C-- Language Specification (2005) [pdf]
- tyingq 8y agoShort overview of "C--" : https://www.cs.tufts.edu/~nr/c--/index.html https://www.cs.tufts.edu/~nr/c--/index.html
- blacksqr 8y agoCode at: https://github.com/nrnrnr/qc-- https://github.com/nrnrnr/qc--
- vmchale 8y agoVery neat, thank you!
- afraca 8y agoA prominent project where I have encountered this is GHC, the Haskell compiler. The route there goes: Haskell --> Core --> STG --> C-- (It then goes to one of: - Machine code generation - into C for feeding to gcc - into LLVM's intermediate representation. )
- faissaloo 8y agoWould converting C-- to C/LLVM IR be redundant?
- kryptiskt 8y agoIt's true that they are mostly on the same level but it's way easier to compile C-- to LLVM IR or C than to write three separate STG->(Imperative code) stages.
- YorkshireSeason 8y agoFor those who are not Haskell experts, Core is a small lambda-calculus with case (pattern matching), let and coercions, see [1] for details. STG stands for Spineless-Tagless G-machine and is a refinement of the older G-machine. The G-machine (short for Graph-Reduction Machine) is for the lazy (call-by-need) evaluation of functional programs in supercombinator form [4]. Instead of interpreting supercombinators as rewrite rules, they were compiled into sequential code with special instructions for graph manipulation. See [2]. For a general overview of GHC's architecture, see [3]. [1] A. Tolmach, T. Chevalier and the GHC Team, An External Representation for the GHC Core Language (For GHC 6.10). https://downloads.haskell.org/~ghc/6.12.2/docs/core.pdf https://downloads.haskell.org/~ghc/6.12.2/docs/core.pdf [2] S. Peyton Jones, Implementing lazy functional languages on stock hardware: the Spineless Tagless G-machine. https://www.microsoft.com/en-us/research/wp-content/uploads/1992/04/spineless-tagless-gmachine.pdf https://www.microsoft.com/en-us/research/wp-content/uploads/... [3] S. Marlow, S. Peyton-Jones, The Glasgow Haskell Compiler. https://www.aosabook.org/en/ghc.html https://www.aosabook.org/en/ghc.html [4] https://wiki.haskell.org/Super_combinator https://wiki.haskell.org/Super_combinator
- dragonbonheur 8y agoThe other project named C-- http://c--sphinx.narod.ru/indexe.htm http://c--sphinx.narod.ru/indexe.htm
- ginko 8y agoAt least that one actually defines a decrement operator.
- vgoh1 8y agoI used this in the mid- to late-90's on my 80386 (which was very much out of date at the time, but was all I had). I was very new to computing at the time, and the only other languages that I had under my belt were QuickBASIC and 80386 assembler, so I can't comment on if it were a "good" language or not. After less than a year, I ended up abandoning it, preferring to use QuickBASIC for high level, and machine language for low, not feeling like I needed the intermediate C--.
- ThePadawan 8y agoIIRC EiffelStudio compiled Eiffel to C-- as an intermediary stage, but I haven't used it since university and struggle to find information about that online.
- _pmf_ 8y agoSlightly off topic: did you do any projects using Eiffel, and if yes, what were the benefits / unique features?
- ThePadawan 8y agoI did not use it past university.
- carterschonwald 8y agoThere’s an alternative timeline where c— was better marketed / promulgated as a backend tool kit for optimizing compilers and everyone use c— instead. That’s not to say llvm isn’t great, but some of the design choices it has make it a lot of work to do funky stuff ! And c— is a bit easier to write low level rts snippets in. I do think the ghc c— flavor is super nice to write in these days.
- metalliqaz 8y agoSometime in the 90's I downloaded a programming language called "C--" that was basically assembly with some loop control structures and functions. I'm assuming this completely unrelated. Edit: ah, looks like dragonbonheur found and linked it already in this thread!
- sprinx 8y agoThat was Sprinkx C-- Great Compiller with IDE in late 90's http://c--sphinx.narod.ru/indexe.htm http://c--sphinx.narod.ru/indexe.htm
- gnulinux 8y agoDoes compiling to C-- have any benefits compared to compiling equivalent C code (maybe a subset of C)? My guess would be modern C compilers, powered by decades of R&D and programming, would be able to optimize just as well and possibly better. EDIT: One advantage that comes to my mind is that compiling to C-- will give slightly more power to deal with stack. E.g. implementing exceptions, continuations etc would be simpler. This is possible in C using inline assembly.
- vmchale 8y ago>My guess would be modern C compilers, powered by decades of R&D and programming, would be able to optimize just as well and possibly better. GHC often produces more efficient code than the LLVM backend.
- ufo 8y agoAnother thing it helps with is garbage collection. If you compile down to C it also requires stack trickery.
- rwhaling 8y agoOne benefit that is repeatedly mentioned in the papers is the ability to do tail-call optimization, which is more or less impossible with compile-to-c interpretations, and mandatory for functional languages.
- vmchale 8y agoIs GHC the only project that uses this?
- ufo 8y agoAre there any projects other than GHC which still use C--? I had heard that it was unfortunately kind of dead these days.
- tempodox 8y agoThis looks like a precursor of LLVM IR.
- inspector-g 8y agoInteresting! I've been writing a lot of C/C++ for over a decade, but had never heard of C-- before. So, I went to the website[1] linked in the PDF to learn more, but sadly it appears the domain has been taken over and now just displays a small collection of badly written articles about Windows. [1] http://cminusminus.org http://cminusminus.org
- DonHopkins 8y agoGeneralizing Overloading for C++2000: Bjarne Stroustrup, AT&T Labs, Florham Park, NJ, USA. Abstract: This paper outlines the proposal for generalizing the overloading rules for Standard C++ that is expected to become part of the next revision of the standard. The focus is on general ideas rather than technical details (which can be found in AT&T Labs Technical Report no. 42, April 1,1998). http://www.stroustrup.com/whitespace98.pdf http://www.stroustrup.com/whitespace98.pdf
- DonHopkins 8y agoC++++-= “C++++-= is the new language that is a little more than C++ and a lot less.” -Bill Joy In this talk from 1991, Bill Joy predicts a new hypothetical language that he calls “C++++-=”, which adds some things to C++, and takes away some other things. https://medium.com/@donhopkins/bill-joys-law-2-year-1984-million-instructions-per-second-3a8c92165cfe https://medium.com/@donhopkins/bill-joys-law-2-year-1984-mil...
- evincarofautumn 8y agoI would love to use it for my compiler backend…if I could find any maintained standalone implementations of it.