C Minus Minus
en.wikipedia.org
en.wikipedia.org
> 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.
It's not?
Welcome to C-- (2008) - https://news.ycombinator.com/item?id=30006215 - Jan 2022 (23 comments)
The C-- Language Specification (2005) [pdf] - https://news.ycombinator.com/item?id=19429522 - March 2019 (27 comments)
C--: A Portable Assembly Language - https://news.ycombinator.com/item?id=17966114 - Sept 2018 (1 comment)
C-- - https://news.ycombinator.com/item?id=6621679 - Oct 2013 (72 comments)
Pretty sure there have been other threads. Anyone?
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.
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.
The idea has also been expanded to modeling heaps for aiding reasoning about field loads and stores.
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.
C-- - Initial release: 1997
> 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.
https://downloads.haskell.org/~ghc/7.8.3/docs/html/users_gui...
That said, it might be that it was trying to be a standard rather than a single blessed implementation that accounts for that difference.
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?
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?
>Any sufficiently complicated C or Fortran program contains an ad hoc, informally-specified, bug-ridden, slow implementation of half of Common Lisp
Wouldn't any language frontend for gcc count? Last I checked that includes Ada, Fortran, and others.
1: Forth. I've seen Forth on things that I didn't even realize were computers. Since an interpreter can run in a few hundred bytes of ROM, that's not too surprising.
2: Rust. Rust can run on 8/16 bit micros, client side web (WASM), and on iOS, along with all of the more conventional and easier targets. Probably the only popular universal language for 2022 targets, although there are Rust competitors like Zig that may falsify that statement.
And in a nice coincidence, both languages are fun.
There is almost no platform java can't run on. Rust is a bit esoteric, but it can run anywhere you have a working libc.
I don’t think that’s true. Doesn’t Rust only run on platforms that LLVM supports?
I doubt Java is available on some of the smallest computers C can run on, like many microcontrollers or legacy platforms.
But of course, a 32KB RAM minimum would be too much for some legacy systems. Still, Java is actually far more flexible than most people would think.
(Also, at its heart the JVM is just a Forth-like stack based interpreter, and I would guess that loading and parsing a .class file is more complicated than the interpreter itself!)
Full C is also not available everywhere, specially 8 bit and 16 bit computers where it is mostly a pseudo macro assembler.
Edit: an important difference between them is that C implementers take the standard very seriously, while Forth is culturally resistant to standardization, Chuck Moore being on record as having considered it a bad idea, and disliking the resulting ANSI Forth language.
If the goal is to compile "the same code everywhere", well, good luck doing that with C, but with enough #ifdefs it can be done. The Forth approach is to have a personal base layer of words, which one either adapts or implements for a given system, and target the rest of one's code at that dictionary.
> Free Pascal is a mature, versatile, open source Pascal compiler. It can target many processor architectures: Intel x86 (16 and 32 bit), AMD64/x86-64, PowerPC, PowerPC64, SPARC, SPARC64, ARM, AArch64, MIPS, Motorola 68k, AVR, and the JVM. Supported operating systems include Windows (16/32/64 bit, CE, and native NT), Linux, Mac OS X/iOS/iPhoneSimulator/Darwin, FreeBSD and other BSD flavors, DOS (16 bit, or 32 bit DPMI), OS/2, AIX, Android, Haiku, Nintendo GBA/DS/Wii, AmigaOS, MorphOS, AROS, Atari TOS, and various embedded platforms. Additionally, support for RISC-V (32/64), Xtensa, and Z80 architectures, and for the LLVM compiler infrastructure is available in the development version. Additionally, the Free Pascal team maintains a transpiler for pascal to Javascript called pas2js.
The number of platforms Pascal is available looks impressive! Can you mention some of the others like that? You say there are various options. What are those?
Lots of activity and talk to try to push Rust into being a stronger alternative too. There are also the other newer C alternative languages and languages that compile to C (Nim, Vlang...), that can be directed towards this purpose. Speaking of Vlang, there is now a project for it to compile to Pascal, as one of its backends (in addition to C and WASM).
So... Pascal, Ada, Java, Go (including TinyGo), Rust (future), and others mentioned (future/transpile to C)...
Don't get me wrong, C dominates. But, depending on what is being done, its not the only language that has to be used or it can be written in something else that transpiles to it.
When I clicked on the link this is what I expected the article to be about.
(Reads the page.)
"Oooh. Interesting."
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...
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://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)
>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.