8 ms·
The C juggernaut illustrated (2012)
- mistrial9 4y agothe example about C at Apple Computer is accurate. The MPW group had a tool suite but it was a niche project at the time (mid-80s). Influential engineers had a great pascal compiler and dropped into assembler for the fine points, quite a lot. The environment at DeAnza 3 where TechSupport lived was a place of change for Apple at that time. Within a few years, C was popular as an application language, some drivers for the new Mac II, and lots of community code was generated. edit thinking about it, the resistance to C at the time was for real reasons.. common microcomputer C famously shipped with a minimal language but the I/O and string handling libs made the environment a useful runtime. Interfaces to anything more than that on a microcomputer were adhoc. But many professionals at that time knew about the larger *nix systems, and wanted the kinds of pipes and task management interfaces that they knew. This was the wrong model for the Mac OS, which emphasized graphical user interfaces at every step. There were no terminal windows in the background at all, no pipes and no standardized processes. It was the courage to break away from "grown up" multi-user system, incremental engineering and make a completely mouse-driven interface that made the Mac great. Later when C interfaces to ROM Toolbox calls were built, they were used to support the Mac OS, not drag in tons of technical debt and character-stream kinds of ideas to this new computer.
- mwcremer 4y agoFor what is is worth, K&R and UCSD Pascal were contemporaneous, so it could have gone either way. As it happened, Bill Atkinson convinced Steve Jobs to support Pascal on the Apple ][. And the Apple ][ was the original development environment for the Lisa, which was the original development environment for the Macintosh. https://www.folklore.org/StoryView.py?story=Joining_Apple_Computer https://www.folklore.org/StoryView.py?story=Joining_Apple_Co...
- WalterBright 4y agoUCSD Pascal was too slow to be competitive.
- AnimalMuppet 4y agoWas it Pascal in general that was slow, or just USCD? Was that the p-code system? Or was it a true compiler? Was it slow because it was p-code? I wasn't on UCSD, but I don't recall Pascal being particularly slow compared to C. I never benchmarked them against each other, but it wasn't noticeably slower to my eyeball.
- WalterBright 4y agoIt was slow because the P-system was an interpreter, not native code. Java fixed that problem with the JIT. (Steve Russell created the first JIT for Java, and the result was spectacular.)
- fsckboy 4y agothat's not entirely true, for example, Microsoft Word for the Mac (and PC) was p-code C, because p-code is a lot smaller. I think UCSD pascal was, yes, slow because of p-code, but also pascal is a very limited language compared to C. P-code with pointers is going to be a lot faster than p-code with no pointers.
- mistrial9 4y agothe Apple compilers were good enough, with a lot of ASM.. the other comment is trying to change the subject to Sun things, which is like England vs France topic
- chasil 4y agoIn the DOS world, there were "near" and "far" pointers that would allow access to different memory segments. Even with this extra complexity, C did well. I understand that Microsoft tried to get these into ANSI C, but they were forcefully kiboshed. https://en.m.wikipedia.org/wiki/Far_pointer https://en.m.wikipedia.org/wiki/Far_pointer
- jmclnx 4y agoAround that time we had K&R c, which I liked because no really messing around with prototypes. Were Pascal, IIRC you had to deal with prototypes and variable types and other things. Since then, we have ANCI c, which I got use to prototypes, but I still prefer K&R. At least for now, ANSI has yet to get anal about variable types and memory. I hope that never happens but I fear c is heading in that direction because of what the rust people are doing.
- mgaunard 4y agoDid you not get the memo? C was replaced by C++. Many languages are trying to replace C++ and failing to do so.
- steveklabnik 4y agoJust so you know, K&R style function definitions were removed in C23. https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2841.htm https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2841.htm (90% sure but not 100% sure that’s the actual final link, if I’m wrong happy to be corrected!) Rust is not mentioned as a justification.
- spc476 4y agoThere are times when I work with old C code. Just the other day, I added proper C prototypes to a project, and immediately found several bugs with the code, like "this function is expecting a char **, the variable being passed in is char **, but it the address to the char ** is being passed" type bugs because the programmer wasn't able to keep all the details in their head.
- quelsolaar 4y agoThe "Likeability" of C is very underestimated. Many people think that system code _should_ be written in other language, but people who _want_ to actually write, and maintain system software want to do so in C. A programming language has to be enjoyed, if someone is going to dedicated a significant part of their lives o writing opensource software in it. C is on paper not a safe language, but almost all of the most trusted safety critical software is written in it, so from a Darwinistic point of view it has produced more trusted software. I strongly suspect that a big reason for this is that C is enjoyable enough for maintainers stick around long enough shake out all the issues.
- Gigachad 4y agoThings have changed a lot since 2012. The Asahi Linux devs have said positive things about writing OS code in Rust. They have built a full M1 GPU driver in Rust which says a lot for the future of system code in safer languages.
- galangalalgol 4y agoMisra C is not normal likeable C. And while people have written safety critical code in normal likeable C, that isn't at all common. Ada, more recently spark, and various c++ subsets are all far more common. But yes Misra C is very common. Zig seems likeable, but I haven't tried it yet. And rust is enjoyable now that I'm into it as my daily driver. The complexity is only there if I go looking. Mostly.
- wheelerof4te 4y agoIsn't malloc one of prime reasons that makes C "less likeable"? I would imagine banning the use of malloc would make C easier, not harder to code in.
- convolvatron 4y agowhat would you replace it with? stack allocation almost everywhere and acyclic reference counting when you absolutely have to?
- User23 4y agoThe first "real programming language" I learned was Pascal. This was back in the 90s. Switching to C was like taking off a straight-jacket. I think it's hard to explain how much more freely you were able to code to someone who didn't go through the experience. Pascal was derogatorily referred to as a "Bondage and Discipline Language" by C programmers. Of course I've matured a bit and I see a value in discipline and having the language get in the way of doing error prone things more now, but even so I'd still choose K&R 2nd edition ANSI C over late 80s and early 90s vintage Pascal if I had to pick one today.
- WalterBright 4y agoI never wrote another line of Pascal after Michael Holley lent me his copy of K+R.
- cesaref 4y agoFrom my perspective, there is a certain truth to this. I started out as an assembler programmer in the early 80s, just a kid messing about with the machines of the time (Z80, 6510 based). There was BASIC on various machines, but it was slow and clunky, and you just didn't get enough control or speed to do the things that a kid in the 80s wanted to do (write games!). When I first came across C, it was around the time i'd been writing 68k for the first time, and intel assembler was very confusing, and already had a heap of different models to consider. So, C allowed the majority of stuff to be written once, with calls to library functions written in assembler. All of a sudden, we went from 0% portability to 95% portability. C could be written like assembler, basic types which map directly to registers and memory locations, and so really it was a simple step to write not great C, with obvious benefits. The first non-C language I came across was Fortran, closely followed by Modula-2, and neither of these were in any way as close to what i'd been writing in assembler, and so didn't connect in the same way. I don't think i'm unusual in this regard, transitioning from assembler to C. Of course these days there is a new generation of programmers who haven't that experience, and are happier with higher level abstractions, and so it must look weird to them to see the fascination with C, and it probably has outlived it's expected life - i'm certainly surprised we're not all functional by now for example.
- pyjarrett 4y agoDespite enjoying the terseness of C, with curly braces and short notations, many "normalized" things in C used to trip up math students I would tutor in elementary programming classes. "Why is `=` assignment and not `==`? How can a function not produce a value? Why does `||` mean "or"?, etc. Pascal family languages usually end up much more long winded, but can often be more easily explained to non-programmers than C solutions. I spent a couple years doing down the Ada rabbit hole in open source and was amazed how many elements of the problem domain you express directly with the language, and how you can constrain your program to catch domain-specific issues with the compiler. With the rise of things like ChatGPT, I'm curious if the next revolution for programming languages is focusing on constraints to verify correctness rather than expression of what to do. This might help help an AI model develop code and provide validity checks on the generated solution.
- Ingaz 4y agoExcuse me, but where do you see difference between C and Pascal? Of course: curly braces and BEGIN-END and 'for' is much more elegant but conceptually they are the same. Borland it demonstrated with CBuilder and Delphi. Sometimes I wrote program in both of them.
- andrewmcwatters 4y agoI love C. As far as I can tell, there isn't anyone on the face of the planet trying to build anything like C in order to replace it. Rust isn't it. Rust is decidedly a "C++ replacement," if anything. Go is the closest in terms of philosophy, but Go isn't it either, because its standard implementation is garbage collected, among a number of other concerns. There is almost certainly SOMEONE out there, a random nobody on GitHub or elsewhere actually trying to write something that is as close to C in terms of philosophy and execution but utilizes some modern niceties, but I don't know who they are. If you want to replace C, though, you actually have to get in C's skin, and undulate and move like C does. But here's the kicker: absolutely no major language seems to want to do this, so they're all dead on arrival. No other language has the same ability to interop with other languages. No other language gets nearly as close to writing something that you can have an idea of what the underlying assembly looks like when you write it. No other language seems to care about the surrounding ecosystems C operates in or think about topics like ELF/Portable Executable/Mach-O. Why? Because all of them operate in their own little bubble. No other language wants to expose those details to you. They want you to operate in the world of MyWorldLang. What's "name mangling?" What are "shared libraries?" But you can't displace C if you don't care at all about POSIX or FFIs or assembly output or the host OS, and none of them do. If you operate in the world of VegetableLang, they want you to work with "CarrotLib" and "Tomato constructs," and "VegThreads." And all of this other nonsense that has nothing to do with hardware. And then we end up with all of this garbage software and fewer and fewer opportunities for people to learn how to utilize their hardware, because guess what, there is no abstraction layer that will automagically help you get your records into cache lines. You HAVE to count those bytes yourself somewhere, sometime. C is so powerful and long lasting because people who want to displace C and related languages aren't even in the same ballpark. They're on another planet. In another universe. Apparently working with a CPU or RAM to them is like asking how relevant it is for someone to be able to throw a golf ball into a basketball hoop from the three-pointer line in the fourth quarter of a football game.
- matt_daemon 4y ago> As far as I can tell, there isn't anyone on the face of the planet trying to build anything like C in order to replace it. To the best of my knowledge this is what Zig is trying to do. https://ziglang.org/ https://ziglang.org/
- fmajid 4y agoYep. I learned Pascal in high school, but when I got my first Mac in college and needed to write apps for it, I fumbled with Symantec's Think Pascal for a while and ditched it for Think C in short order, even though I was still learning C at the time (and managed to completely corrupt my hard drive requiring a full reinstall because I used the low-level I/O APIs incorrectly). You can do a lot in Pascal, and Delphi was an outstanding development environment for Windows app, but C is just so much more powerful.
- Ingaz 4y agoFor me it was the other way: I learned programming in C and I loved and that's it's "the bestest" But my first work was in Delphi. I've grown a lot as a programmer exploring VCL, professional tools but I still thought that C and C++ are superior. My second work was in C. I was happy. But then .. I started to see that not everything so beatyful. It was like meeting with a girl you had a crush as teenager but now .. she's just normal
- oconnor663 4y agoWhat I'm hearing is, if we'd had Hacker News in the late 80's, the RIIC people would been really annoying :)
- kasajian 4y agoIf you had to pick only one language, I'd pick C++ because I can always write C in C++.
- fsckboy 4y agothis is a reasonable historical point buried in some nonsense: >all sorts of people in the 1980s wanted a low level programming language, C was around, and so they seized on it. Any similar language would have done; it's just that C was lucky enough to be the one that came out on top, partly because of network effects. any similar language would have done? there were no other similar languages for the low level programmers who wanted one, none, zero. So the "network effect" of C was that it had all the users in it because it was the only option. There were some predecessors and pretenders to the throne--PL/I, BLISS, B, BCPL... pascal? forth? nah, c'mon--but they were not as good as C. C was small, and C had pointers that would increment by sizeof(type): indispensable. The sudden need for a low level language for a lot of programmers at the same time was the birth of the microprocessor personal computer. These were new architctures, and there were no standard operating systems for them yet (there was competition for them, and the ones that emerged were bare bones) and programmers needed to write apps. Lotus 1-2-3 "won" by being written in assembly, there was still room for that choice. Those other languages (mentioned above) existed on other architectures but not on these new microprocessors, and if you were going to start/port from scratch, you weren't going to reach for those, some were too big (PL/I), some were already archaic or tied to narrow architectures (BLISS was all DEC and DEC was very busy trying to pretend that microprocessors needed to be shoehorned into the minicomputer architecture), and none had any network effect to speak of in this adjacent community. If you were graduating with a CS degree at that time, you barely wanted to work on primitive microprocessors, they didn't have all the fancy CS features you were used to in school, the tech at that time had a much more (but by no means exclusive) self-taught and trade school by the seat of pants type engineering vibe. C also had wonderfully unspecified behaviors to allow flexibility to the definition by the implementation on particular architectures (did your ISA detect 2s complement overflow? was your architecture 2's complement? if you need that, figure it out, if you don't, don't waste the cycles) and that was incredibly useful and incredibly efficient. (the people who went to the school-of-prissy-compiling who are throwing that all away now are polluting the world, spewing suffocating carbon dioxide more than a bitcoin miner using their optimizations. there's nothing wrong with what compiler writers want, they want features equally as cool are as cool as C's undefined behaviors (not really C's, the defined behaviors of various architectures), but you can implement these new features without stomping all over features that other people use)