Live data from Hacker News

C meeting is over. C23 added:

twitter.com

341–350 of 363 posts

Re: C meeting is over. C23 added:

#342
post #314
post #246

Earlier quoted context omitted.

There a couple of open source C compilers TCC, SDCC, tendra, chibicc, ACK, LCC, PCC, etc. and also many commercial ones. It is true that GCC is not written in C anymore, but it is easy to see that the code is still relatively close. I am also myself writing a C compiler in C at the moment and there is no problem at all.

How many of those are actually shipping software into production? Quite curious about which commercial C compilers, written in C, are being sold, keeping those companies in business. Every year thousands of CS students write toy C compilers.

It will be hard to agree with you what "production" even means. I have written and shipped at least one compiler/interpreter (written in plain C). The language wasn't an issue at all. (This compiler doesn't have any meaningful optimizations, but I don't see why that should change the game).

GCC and Clang aren't "sold" either, nor is MSVC really.

I have never contributed to GCC, but as a fact I have visited plenty of files from its source code, and so far haven't encountered any meaningful use of C++ that couldn't easily be rewritten in plain C. The overwhelming majority of the code would probably compile as C without changes.

I'm sure that there are far more meaningful "problems" with the architecture of a compiler written in C that are not the implementation language. For example, GCC is a pain to build (IIRC when I tried many years ago, I gave up).

Re: C meeting is over. C23 added:

#343
post #322
post #312

Earlier quoted context omitted.

Portable by definition means it cannot capture every specific detail of every architecture out there.

By definition there isn't such thing as portable Assembly.

Not by definition, but by practice as generating assembly is usually done to optimize performance. Languages restricted to generate a common feature set between isomorphic ISAs and bijectively associated assembly languages are at a performance disadvantage compared to the full ISA specific assembly.

Re: C meeting is over. C23 added:

#344
post #325

Earlier quoted context omitted.

Who, except for people too young to know better, saw value in C but not in Algol? The Bell Labs folks obviously thought enough of Algol such that C is a descendant in the family of Algol-like languages. Algol was widely used in Europe whereas in the U.S. we made do with Fortran, Cobol, and, I think to a lesser extent, PL/I, although the latter had many Algol-like features at the time. (And Fortran evolved to have man…

I have nothing against Algol. Turbo Pascal was my first language (i agree with you about Turbo C). I loved it at the time. But C is different. The same way Lisp is different. It is just one of those languages which have a very simple core idea which is also very powerful at the same time. Lisp has the code-data duality (everything is a list) going for it and C has everything is pointer to a block of memory and that's…

No, everything is not a pointer in C; C is based on value types that are passed around by copy (with the exception of arrays and functions). An variable of a given type designates a piece of storage which contains that value, rather than a pointer to it.

C is not significantly different from Algol or Pascal. The difference between C and Algol is a lot smaller than between either of those and Lisp or ML.

What's missing in some Algol-like languages compared to C is the loose pointer arithmetic, and possibly type punning via pointer conversions. Those features allow C programmers to do things like write their own memory allocator, which is incredibly useful in embedded systems. A C project can produce a self-contained image that boots on bare metal, with minimum assembly language. Or on almost bare metal, where there is a boot loader program that provides no services to the C program other than jumping to its entry point and maybe some console printing routines or something.

Re: C meeting is over. C23 added:

#345
post #273

Earlier quoted context omitted.

>due to C not having good expressive/abstracting powers I disagree, if anything, C's scantness forces you to abstract things much properly, unless you plan to write pages of boilerplate code here and there.

With all due respect - how do you write a string library in C then? Char* is not one.

An appropriate data type (you could use structs maybe) and methods for the common operations, concat, length, etc...

It's not as trivial "string s" like in other languages, but it's also not that big of a deal. Also, you make sure it works properly and you just use it anywhere you want.

Re: C meeting is over. C23 added:

#346

Another nice convenience: a new #elifdef preprocessor directive to replace longhand #elif defined() . https://en.cppreference.com/w/c/23

Oomph. There seem to be more meaningful changes in C23. I sure hope they wouldn't consider a new standard for such trivialities alone. There's cost to those changes. Compilers will naturally need to be updated, but other tools, e.g. static code checkers and documentation, e.g. MISRA-C, too.

Re: C meeting is over. C23 added:

#347
post #317

Earlier quoted context omitted.

C has had a true Boolean type for over 20 years now, since C99. This time around they're merely dumping the backwards-compatible _Bool/_True/_False syntax + keyword-like #defines in , and replacing it all with proper keywords. That said, it would be nice if C caught up with Algol 68 , seeing how that's the one many of the concepts (and the corresponding keywords) are taken from. Let's start with first-class functions…

That was a kludge.

How?

Re: C meeting is over. C23 added:

#348
post #312

Earlier quoted context omitted.

Portable by definition means it cannot capture every specific detail of every architecture out there.

The carry flag is not a specific architectural detail; it is part of the output from the prime example of a basic electronic circuit that is the digital adder.

It is an architectural detail. MIPS for example doesn't have a carry flag. You have to do the exact same procedure in assembly on MIPS you have described in your previous comment when doing multiple word addition.

Re: C meeting is over. C23 added:

#349
post #325

Earlier quoted context omitted.

I have nothing against Algol. Turbo Pascal was my first language (i agree with you about Turbo C). I loved it at the time. But C is different. The same way Lisp is different. It is just one of those languages which have a very simple core idea which is also very powerful at the same time. Lisp has the code-data duality (everything is a list) going for it and C has everything is pointer to a block of memory and that's…

No, everything is not a pointer in C; C is based on value types that are passed around by copy (with the exception of arrays and functions). An variable of a given type designates a piece of storage which contains that value, rather than a pointer to it. C is not significantly different from Algol or Pascal. The difference between C and Algol is a lot smaller than between either of those and Lisp or ML. What's missin…

You have completely misunderstood my comment about why C stands out. I though it was obvious from the example I gave, what I meant, when I said everything is a pointer to something?

As an embedded developer in previous life, I can assure you C is not special because it can run on bare metal. Many other languages can too.

Re: C meeting is over. C23 added:

#350
post #318

Earlier quoted context omitted.

The UNIX authors didn't choose C; they made it, specifically to make UNIX. And, much like the original UNIX itself, it was a hack - because they were trying to make do within the limits of their hardware. So, some of the syntax is the way it is because it was simpler to parse, for example. And some of the semantics was originally "because PDP does that". As for why C has staying power, that's solely a function of its…

You're hung up on words. I know they made it. It was based of Ken Thomson's B. They chose it, when they could have taken some other existing language. I see great beauty and simplicity in C the same way I see it e.g. in Lisp or Javascript for that matter. I dabbled in Modula-2 and it does not offer the same feeling in my opinion. The core features of C are very powerful and simple at the same time, which is the reaso…

The core features of Modula-2 are largely the same as C + modules, but with more consistent syntax and fewer footguns (like no unsafe implicit pointer conversions), so I don't see how C can objectively possess "great beauty and simplicity" in comparison. Unless you're referring specifically to the syntax?

B was also written as a hack - it was basically a minimal subset of BCPL small enough to fit in the memory of the machines they were working with. B is elegant in a sense that it's a very simple language for a word-oriented architecture - but that's exactly the part that they had to get rid of for C to target byte-oriented ones. Coincidentally, it's also one of the sources of weirdness in C syntax (e.g. implicit int and K&R prototypes are all legacy of B).

Post reply on HN