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.
C meeting is over. C23 added:
341–350 of 363 posts
Re: C meeting is over. C23 added:
#342Earlier 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.
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:
#343Earlier 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.
Re: C meeting is over. C23 added:
#344Earlier 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…
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:
#345Earlier 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.
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:
#346Another nice convenience: a new #elifdef preprocessor directive to replace longhand #elif defined() . https://en.cppreference.com/w/c/23
Re: C meeting is over. C23 added:
#347Earlier 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.
Re: C meeting is over. C23 added:
#348Earlier 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.
Re: C meeting is over. C23 added:
#349Earlier 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…
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:
#350Earlier 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…
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).