Hacker News new | ask | show | jobs
by timbit42 1547 days ago
C was not well-designed. In fact I would say it was poorly-designed It is weakly typed with a fair bit of undefined behavior. Many people praise Dennis Ritchie for creating C, but I don't. Ken Thompson did a great job on designing Unix and UTF-8 though. To me, Ken is the real hero of these two.
2 comments

C was designed to the constraints of the time and place of its creation, and was a thoroughgoing success within those bounds.

It is our fault that we use it beyond.

C came out in 1972, but we had Pascal in 1970 which is strongly typed and doesn't have undefined behavior. Pascal wasn't perfect and did have a few issues with use in writing operating systems but Modula-2 and it's descendants were really good. The early versions of the Macintosh System were written in Pascal and used assembly to handle the low level bits Pascal was missing. With Rust we're finally getting back to safe programming. I'm hoping to see other existing and new languages with more safety.
Apollo Aegis, a system that was inspired, like Unix, by Multics, and was better than Unices of the time, was coded in Apollo Pascal. You could identify the difference between Standard Pascal and an actually useful Pascal by looking at Apollo Pascal extensions.

Pascal had null pointers and manual allocation, so was not really any safer than, anyway, C90. Of course C pre-90 lacked even function prototype declarations.

I heard C called the JavaScript of the 1970s once in that it's a mediocre language that got really popular by tagging along with other platforms.
It certainly tagged along with Unix but with 16-bit systems like the IBM PC, Macintosh, Atari ST and Amiga, it began to take over. We had safe languages like Pascal and Modula-2 at that point but computers weren't networked back then and programmers cared more about saving a few CPU cycles than having more stable programs. Today we know how dangerous C is for online security. Sure, safe code can be written in C but it's a lot more work for the programmer than using a language that is designed to be safe. It's good to see Rust come along and I'm hopeful to see safety being added to existing and new languages.