Live data from Hacker News

C Minus Minus

en.wikipedia.org

31–40 of 75 posts

Re: C Minus Minus

#31
post #23

I 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 im…

Forth is available for more platforms than C, and like C, it is usually but not always a compiled language. Because Forth always has an interpreter, and a powerful one, it's more obvious that Forth doesn't have to compile to run, but again, true of C as well: https://gitlab.com/zsaleeba/picoc exists, and it isn't the only one.

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.

Re: C Minus Minus

#32
post #23

I 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 im…

> Which programming language other than C is available for most platforms? 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.

> 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?

Re: C Minus Minus

#33

One 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…

Modern architectures have different register banks for the two, but that's irrelevant, C-- is not register-centric.

The 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.

Re: C Minus Minus

#34
this 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...

Re: C Minus Minus

#35
post #9

Slightly 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…

LET 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.

Re: C Minus Minus

#36
post #20

From 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 describe…

LLVM - Initial release: 2003

C-- - Initial release: 1997

Re: C Minus Minus

#37
There’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.

Re: C Minus Minus

#38

One 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…

They 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 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.

Re: C Minus Minus

#39
post #23

I 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 im…

> Which programming language other than C is available for most platforms? 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.

Java requires a certain amount of memory and CPU power (if nothing else because it's a garbage collected language).

I doubt Java is available on some of the smallest computers C can run on, like many microcontrollers or legacy platforms.

Re: C Minus Minus

#40
post #36
post #20

From 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 describe…

LLVM - Initial release: 2003 C-- - Initial release: 1997

That 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.
Post reply on HN