5 ms·
C was well-designed for its time, but "extremely" well-designed is a stretch given the much better designs that came immediately before (ALGOL 60 and 68, Pascal
by smitherfield 10y ago
C was well-designed for its time, but "extremely" well-designed is a stretch given the much better designs that came immediately before (ALGOL 60 and 68, Pascal, Scheme) or after (Ada, Modula, ML) it. C was optimized to be fast to implement (and won out for that reason — "worse is better," and because UNIX was the first usable OS written in a high-level language), not for the best practices in safety or even performance, even as understood at the time.
- Sir_Cmpwn 10y agoI'm not talking about pre-ANSI C. Compare C89 to those languages and, in my opinion, C comes out on top.
- smitherfield 10y agoI'd really disagree. All those languages are both safer and more expressive (if more verbose in the case of those with Pascal-like syntax) than any version of C, and, except in the case of ML, Scheme and ALGOL 68 with the optional garbage collection, there's no reason they couldn't be as fast or faster than C. Their main fault was simply in being too ahead of their time: too difficult or impossible to implement well on a PDP-11. (I deleted the part about FORTRAN 77; seems I was confusing it with F90, which is the version that first allowed identifiers longer than 6 characters, dynamic memory allocation and user-defined types).
- Sir_Cmpwn 10y agoBut they fill a different niche. C is about being close to the hardware and using minimal abstractions.
- pjmlp 10y agoThere isn't a single C feature that I wouldn't be able to use in say Modula-2.
- cwyers 10y agoThere are cases where you need to be close to the hardware -- the kernel, graphics drivers, low-latency graphics and audio. Why does using a URL to retrieve a file over the network require being close to the hardware?
- pjmlp 10y agoC89 lacks ton of safety features and support for large scale development already present in those languages. I can gladly enumerate them.
- cwyers 10y agoI'd happily read that.
- pjmlp 10y agoA small list: - Type safe enumerations - Proper strings with bounds checking - Proper arrays with bounds checking - No implicit decay of arrays into pointers - Type safe pointers - Explicit casts for subverting the type system - Bounds checking must be explicitly disabled - Var parameters instead of pointers for out parameters - Real modules with type encapsulation - Type safe function pointers - Language support for concurrency - Open arrays for variable length parameters - Exceptions All of this available in 1978. By no means anything exceptional, Niklaus Wirth inspired himself on the programming language Mesa, used by Xerox PARC to create the Pilot OS and the Star workstation, as Xerox wanted to move away from BCPL in 1977. Also many of these features were already available in Algol.