12 ms·
C Minus Minus
- jjslocum3 4y agoWhen Java came out, before it stabilized, it was often jokingly called C--.
- DonHopkins 4y agoBefore Java, Bill Joy proposed "C++++-=": https://donhopkins.medium.com/bill-joys-law-2-year-1984-million-instructions-per-second-3a8c92165cfe https://donhopkins.medium.com/bill-joys-law-2-year-1984-mill... >Bill Joy’s Law: 2^(Year-1984) Million Instructions per Second >The peak computer speed doubles each year and thus is given by a simple function of time. Specifically, S = 2^(Year-1984), in which S is the peak computer speed attained during each year, expressed in MIPS. -Wikipedia, Joy’s law (computing) https://en.wikipedia.org/wiki/Joy%27s_law_(computing) https://en.wikipedia.org/wiki/Joy%27s_law_(computing) >C++++-= >“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. >[...] The MIRVing of the Alto user interface into multiple new metaphors means that we are moving into very unfamiliar ground. Everybody should get a Macintosh and understand what’s special about it. We still have a long way to go.
- Rathseg 4y agoMy coworkers used to joke that we used C++ but wrote C--. I never knew the Java joke or that someone made it into an actual standalone language.
- kgeist 4y agoI'm familiar with a different C-- developed by Peter Cellik which appeared before the language in the article (1997). But the article has no mention of it. The discussion page of the article does mention there used to be many languages called C-- with similar ideas and the article only talks about a specific one
- zephyrfalcon 4y agoYou probably mean Sphinx C--: https://bkhome.org/archive/goosee/cmm/ https://bkhome.org/archive/goosee/cmm/
- dang 4y agoRelated: Welcome to C-- (2008) - https://news.ycombinator.com/item?id=30006215 https://news.ycombinator.com/item?id=30006215 - Jan 2022 (23 comments) The C-- Language Specification (2005) [pdf] - https://news.ycombinator.com/item?id=19429522 https://news.ycombinator.com/item?id=19429522 - March 2019 (27 comments) C--: A Portable Assembly Language - https://news.ycombinator.com/item?id=17966114 https://news.ycombinator.com/item?id=17966114 - Sept 2018 (1 comment) C-- - https://news.ycombinator.com/item?id=6621679 https://news.ycombinator.com/item?id=6621679 - Oct 2013 (72 comments) Pretty sure there have been other threads. Anyone?
- mhd 4y agoThe problem with things like this is that "compile to C" isn't really just done for ease of implementation, but for sheer portability - individual C compilers are widespread, and the totality of them are basically ubiquitous. The Quick C-- compiler mentioned in the article only supported x86. So the only way I would see something like this work, is as a frontend for an existing compiler. LLVM itself makes this kinda superfluous there, so that leaves gcc?
- deleted 4y ago[deleted]
- unhammer 4y agohttps://takenobu-hs.github.io/downloads/haskell_ghc_illustrated.pdf#page=8 https://takenobu-hs.github.io/downloads/haskell_ghc_illustra... shows how it (well, the Cmm fork) is used to compile Haskell code with GHC
- mhd 4y agoGHCs Cmm is an interesting beast. It changed a bit from C-- and it doesn't seem to be "sold" outside of the Haskell market, but it does feature basically the best of all worlds: A native generator targeting most current platforms, a LLVM backend (resulting in basically the same platforms, but maybe with different performance characteristics), and even a compile-to-C option.
- TazeTSchnitzel 4y agoOne of the criticisms I have heard of C-- is that it doesn't distinguish between integer and floating-point data in the type system. There are some architectures where that wouldn't be a problem, but most modern CPUs have completely separate integer and floating-point data paths, with a performance penalty for shuffling data between them. Generating good code on these systems from C-- source requires more effort than it should.
- mgaunard 4y agoModern architectures have different register banks for the two, but that's irrelevant, C-- is not register-centric.
- noobermin 4y agoIsn't the point of C-- to be an IR, easily compileable to assembly on the target?
- chrisseaton 4y agoNo the other way around - easily emittable, letting the backend in turn do the heavy lifting to lower it.
- TazeTSchnitzel 4y agoThe backend can of course try to guess what type of register data should live in, but it's not always going to make the right decisions if it doesn't have type information to work with.
- mgaunard 4y agoType information is not what conveys that information, it's the operations used on the data that matters.
- roelschroeven 4y agoThey have a reason for doing things that way, which they state in the specification (in the PDF at https://www.cs.tufts.edu/~nr/c--/extern/man2.pdf https://www.cs.tufts.edu/~nr/c--/extern/man2.pdf it's in figure 2 on page 10). I'm not knowledgeable enough in compilers and computer architecture to decide if it's a good reason. As far as I understand it, their reasoning is that implementations can easily enough figure out how the data is used to decide in which registers to put the data; distinguishing between integers and floats in the type system would be too restrictive, since they want to support architectures with more types of registers than the classic two.
- paganel 4y agoSlightly related to this, this article made me check Simon Peyton Jones's wiki page [1], where I saw this: > Jones has played a vital role in the development of new Microsoft Excel features since 2003, when he published a paper on user-defined functions.[19] In 2021, anonymous functions and let expressions were made available in the Office 365 version of Excel as a beta feature.[20] Truly, there were (possibly still are) a lot of smart people working on Excel, as the years go by I'm starting to think of it as one of the most interesting pieces of software ever written. [1] https://en.wikipedia.org/wiki/Simon_Peyton_Jones https://en.wikipedia.org/wiki/Simon_Peyton_Jones
- eru 4y agoHe semi-joked that Excel is the world's most popular functional programming language.
- operator-name 4y agoLET has been a huge game changer, and when used it can greatly improve the readability of excel functions. Ranged based functions and LAMBDA are also great additions, but to a bit of a lesser extent as they're more complex and thus less popular.
- mgaunard 4y agoSo now any wikipedia page is now worthy of a hackernews post?
- simonh 4y agoTo see how silly that comment is, compare to: "So now any web page is now worthy of a hacker news post?" The answer to both comments is the same, and is in the HN guidelines.
- billpg 4y ago"Ah, it'll be a joke programming language. Someone probably made a joke about C++ and then someone with too much time on their hands actually wrote an implementation of the language." (Reads the page.) "Oooh. Interesting."
- codeflo 4y agoFrom an engineering point of view, it’s interesting they chose to implement their own intermediate language, as opposed to just sticking to LLVM IR and “outsourcing” the problem of code generation. I actually researched this some time ago, and was a bit surprised to learn that modern GHC’s intermediate representation seems to differ from what the C-- paper describes quite substantially, in ways that are only described in the source code. They’re still using the same name though. One observation is that GHC has been somewhat slow to adopt new CPU targets (M1, WebAssembly). I wonder if the reliance on C-- played a role in that.
- FartyMcFarter 4y agoThis project pre-dates LLVM.
- distcs 4y agoLLVM - Initial release: 2003 C-- - Initial release: 1997
- codeflo 4y agoThat by itself only explains the initial decision. It’s still interesting that they’ve stuck to it for 20 years after LLVM’s release. Lots of technical details of GHC changed during that time, it’s not like the architecture is set in stone.
- distcs 4y agoThe point I was replying to was: > it’s interesting they chose to implement their own intermediate language, as opposed to just sticking to LLVM IR and “outsourcing” the problem of code generation I was not replying to: > It’s still interesting that they’ve stuck to it for 20 years after LLVM’s release. Changing the backend from their own IL to LLVM IR several years later is not exactly a "just sticking to LLVM IR" story. Knowing that C-- predates LLVM explains why they chose to implement their own IL.
- nequo 4y agoGHC has supported both Cmm and LLVM as backends for a while: https://downloads.haskell.org/~ghc/7.8.3/docs/html/users_guide/code-generators.html https://downloads.haskell.org/~ghc/7.8.3/docs/html/users_gui...
- jlouis 4y agoThe API cut ended up being in a different place with LLVM and WebAssembly. But the core idea still stands, and has been a hot potato for many years. In some ways, things are better now since there are fewer architectures than in the 90'es, so you don't have to support that many backends. On the other, things are worse because the amount of work you have to sink into a backend is non-trivial and ever growing. One particular key aspect is that languages which have strong functional features tend to mismatch with typical imperative backends. This has been true for LLVM. It is unfortunate, because in reality, most IRs are essentially best described as small functional languages: they make state passing explicit, as it exposes better optimization analysis. SSA-form is functional programming in disguise.
- WalterBright 4y agoYeah, not too many people write a back end these days.
- kasajian 4y agowhat's SSA-form?
- UncleMeat 4y agoAn IR form where each variable is assigned to exactly once. It makes reasoning about a lot of local properties cleaner since you know that the value of a register is set by its single def site. The idea has also been expanded to modeling heaps for aiding reasoning about field loads and stores.
- distcs 4y agoI asked this on Ask HN sometime back but did not get a lot of responses. So asking it here because it might be of interest to people reading and commenting on this artile here. Which programming language other than C is available for most platforms? It is well known that some C compiler implementation is available for almost every computable platform. I am looking for another programming language that has compiler implementations available on a large number of platforms. It must compile source code into native machine code. It doesn't have to match C in ubiquity. It can be less popular than C. But are there any programming languages out there that are available on a large number of platforms?
- SQueeeeeL 4y agoThis is not a direct answer for compiled languages, but Greenspun's tenth rule feels relevant here: >Any sufficiently complicated C or Fortran program contains an ad hoc, informally-specified, bug-ridden, slow implementation of half of Common Lisp
- naasking 4y ago> Which programming language other than C is available for most platforms? Wouldn't any language frontend for gcc count? Last I checked that includes Ada, Fortran, and others.
- 4y ago
- sylware 4y agothis version of c-- does not address some of the bloat and shortcomings of the C syntax: should have no integer promotion, no implicit casts (except for literals like rust? and void* ofc namely), have runtime/compile-time casts, idem for "constants", no horrible typedef/enum/_generic/etc, only sized type (my heart is split between uw/u16,sdw s32, etc), variable arguments of preprocessor macros definitively defined, only one loop statement loop{}, no switch...
- krylon 4y agoIt's not really meant as a competitor to C, and AFAIU, it's meant as a target for a compiler front/middle end, not as a language to write code in manually. Unless you're hacking GHC itself, you're rather unlikely to touch it.
- downvotetruth 4y agoC does not have implicit casts
- chlorion 4y agoC most certainly does have implicit casts, and they are everywhere. Simple example: // malloc returns *void, but C casts it to *char char *p = malloc(10); There are tons of implicit casts when working with integers of different sizes, another example: // subtraction of ints of different signedness // C casts signed int 10 to an unsigned int assert(2U - 10 == 4294967288); Arrays decay into pointers which is another implicit cast, I don't think an example is needed though. Anyways these are just a few common examples, there are tons more and many of them are pretty subtle and error prone. https://en.cppreference.com/w/c/language/conversion https://en.cppreference.com/w/c/language/conversion
- deleted 4y ago[deleted]
- carterschonwald 4y agoThere’s a parallel universe where c minus minus occupied the same role that llvm rose to take. That said, it might be that it was trying to be a standard rather than a single blessed implementation that accounts for that difference.
- msgilligan 4y agoC—- was the joking name for the subset of C we had to implement for my Compilers course in college (1990s, UCSC). I’ve assumed that other courses at other colleges did this, too. When I clicked on the link this is what I expected the article to be about.
- ipqk 4y agoYeah same. There was a basic prerequisite that everyone know the basics of C, but there was no expectation of assembly knowledge. So we'd write a compiler to compile the code down to reduced form of C that basically mimics assembly, and then use gcc to compile that.
- acc_297 4y agomy compiler course called it mini-C