News for hackers. Stuff that matters.
Re:C Isn't a Language by AnimalMuppet on Thursday February 05, 2026 @10:25PM (#46908699)
Repeating a previous comment of mine (https://news.ycombinator.com/item?id=32784959) about an article in Byte Magazine (August 1983) on the C programming language:

From page 52:

> Operating systems have to deal with some very unusual objects and events: interrupts; memory maps; apparent locations in memory that really represent devices, hardware traps and faults; and I/O controllers. It is unlikely that even a low-level model can adequately support all of these notions or new ones that come along in the future. So a key idea in C is that the language model be flexible; with escape hatches to allow the programmer to do the right thing, even if the language designer didn't think of it first.

This. This is the difference between C and Pascal. This is why C won and Pascal lost - because Pascal prohibited everything but what Wirth thought should be allowed, and Wirth had far too limited a vision of what people might need to do. Ritchie, in contrast, knew he wasn't smart enough to play that game, so he didn't try. As a result, in practice C was considerably more usable than Pascal. The closer you were to the metal, the greater C's advantage. And in those days, you were often pretty close to the metal...

Later, on page 60:

> Much of the C model relies on the programmer always being right, so the task of the language is to make it easy what is necessary... The converse model, which is the basis of Pascal and Ada, is that the programmer is often wrong, so the language should make it hard to say anything incorrect... Finally, the large amount of freedom provided in the language means that you can make truly spectacular errors, far exceeding the relatively trivial difficulties you encounter misusing, say, BASIC.

Also true. And it is true that the "Pascal model" of the programmer has quite a bit of truth to it. But programmers collectively chose freedom over restrictions, even restrictions that were intended to be for their own good.

Re:C Isn't a Language by pjmlp on Friday February 06, 2026 @04:00AM (#46910595)
The irony is that all wannabe C and C++ replacements are exactly the "Pascal model" brought back into the 21st century, go figure.

"A consequence of this principle is that every occurrence of every subscript of every subscripted variable was on every occasion checked at run time against both the upper and the lower declared bounds of the array. Many years later we asked our customers whether they wished us to provide an option to switch off these checks in the interests of efficiency on production runs. Unanimously, they urged us not to they already knew how frequently subscript errors occur on production runs where failure to detect them could be disastrous. I note with fear and horror that even in 1980 language designers and users have not learned this lesson. In any respectable branch of engineering, failure to observe such elementary precautions would have long been against the law."

-- C.A.R Hoare's "The 1980 ACM Turing Award Lecture"

Re:C Isn't a Language by phicoh on Friday February 06, 2026 @05:21AM (#46911133)
The thing for me at least is that when I looked at Pascal, MODULA-2, Ada, if you had complex data structures which had to allocate and deallocate memory, then those language would not help at all. They would allow you to make pointer mistakes. Pascal and MODULA-2 were also very restrictive in various area (no generics). Ada is better in that respect, but Ada compilers were rare.

In my opinion it is only Rust that offers a language without runtime system requirement and fixes essentially all of the problems of C.

Re:C Isn't a Language by pjmlp on Friday February 06, 2026 @06:13AM (#46911493)
First of all C did not had any generics, so same playing field.

C has a runtime, even if tiny. That is what calls into main(), handles floating point arithmetic when none is available, functions that run before and after main(), nowadays also does threading.

Heap memory handling in Pascal, Modula-2, Ada, is much safer than C, first of all no need to do math to calculate the right size, arenas are available on the standard library, dinamic allocation can also be managed by the compiler if desired (Ada), pointers are safe as they by default must be used with existing data, however if one really wants to do pointer arithmetic it is available.

The only issue that they have in regards to C, is the use-after-free, but that apparently isn't an issue for folks moving away from C into Zig, wich is basically Modula-2 with some C syntax flavour.

Re:C Isn't a Language by phicoh on Friday February 06, 2026 @06:42AM (#46911699)
C uses pointer casts all over the place to fake generics. If you don't have that (in Pascal or MODULA-2) then life becomes very unpleasant.

There is a quite a bit of C code that makes creative use of the size of allocations. For example linked lists with a variable sized payload. Again one of the things that would prevent a C programmer from switching to Pascal.

I don't expect the Zig user base to become larger than the Rust user base any time soon. But we have to wait and see, Zig is quite young.

Re:C Isn't a Language by pjmlp on Friday February 06, 2026 @08:00AM (#46912292)
Same tricks are possible in Modula-2, Pascal, Ada, if fake generics count.

Creative use of the size of allocations are also possible in those languages, the BIG difference is that they aren't the default way everything gets done.

Re:C Isn't a Language by thezipcreator on Tuesday February 10, 2026 @04:41AM (#46957379)
> C uses pointer casts all over the place to fake generics.

by "C" do you mean users of C? because most of the C code I write I don't use those sorts of techniques; instead I just use the preprocessor to make scuffed generics.[1] Unless you mean in libc itself, where I don't recall any use of pointer casts like that? If I'm missing something, please enlighten me.

[1] see my (probably terrible) dynamic array implementation, for example: https://git.sr.ht/~thezipcreator/xstd/tree/main/item/src/xst...

Re:C Isn't a Language by AnimalMuppet on Friday February 06, 2026 @10:47AM (#46914259)
In Pascal (not the original Pascal standard, but, say, Turbo Pascal), could you allocate a variable-sized array of something, and still have index protection when using it?

(I know quite well that C couldn't. Even a C++ vector may or may not, depending on which access method you use.)

Re:C Isn't a Language by Gibbon1 on Saturday February 07, 2026 @05:00AM (#46922640)
I've started describing what C does is breaking the third wall. Which in theater sis when the actors acknowledge they're in a play.

C totally accepts breaking the third wall. And Pascal doesn't.

Problem with C currently is the language is controlled by people that think programming languages should be like Pascal.

Re:C Isn't a Language by estebank on Saturday February 07, 2026 @11:14AM (#46924950)
That would be the fourth wall

     ________
    |        |
    | actors |
    |        |
     audience
Re:C Isn't a Language by AnimalMuppet on Saturday February 07, 2026 @01:52PM (#46926425)
It would. It's still an interesting description of the difference between C and Pascal, though.