12 ms·
A History of C Compilers – Part 1: Performance, Portability and Freedom
- PikelEmi 2y agoThe mentioned Byte Magazine: https://archive.org/details/byte-magazine-1983-08/page/n13/mode/1up https://archive.org/details/byte-magazine-1983-08/page/n13/m...
- stevekemp 2y agoI've recently been working on a CP/M emulator, and having a lot of fun working with the Aztec C compiler referenced in the list. It's strange to go back to old-school function definitions: main(argc, argv) int argc; char *argv[]; { But a C compiler in only 40k, assembler in 20K, and linker in another 20K is a whole world of tiny software compared to what we use right now.
- pjmlp 2y agoAround 2000 the HP-UX 10 aC compiler that we had available, still wasn't fully ANSI/ISO C89 compliant for function declarations, talk about taking its time.
- nineteen999 2y agoThe Hi-Tech C compiler for CP/M works quite well also, and generates pretty compact code. sdcc can be used to cross-compile for CP/M from a modern PC, if you provide a crt0.rel and libc. I rolled my own and was able to port a few useful programs and utilities with it.
- anthk 2y agoYou might like this: https://t3x.org/t3x/0/index.html https://t3x.org/t3x/0/index.html Pascal like language, compiles at Unix and to DOS and CP/M, it can be run under CP/M too. It can compile both binaries and bytecode. I ran a faithful Ladder port natively under a GNU Unix 386, it's really good: https://t3x.org/t3x/0/programs.html https://t3x.org/t3x/0/programs.html
- nineteen999 2y agoI took a look at T3X a while back, it looked really interesting. Thanks for reminding me. My greatest claim to fame was embedding a Z80 emulator in Unreal Engine, extending it with TCP/IP and VT100 emulation, and being able to connect to BBS's on the internet, and run Rogue, Zork and Wordstar along with most other Z80 CP/M software: https://i.imgur.com/aSc9VGL.png https://i.imgur.com/aSc9VGL.png https://i.imgur.com/dd0Nzo2.png https://i.imgur.com/dd0Nzo2.png https://i.imgur.com/Usjd4Vk.png https://i.imgur.com/Usjd4Vk.png https://i.imgur.com/Y5aIjCi.png https://i.imgur.com/Y5aIjCi.png https://i.imgur.com/rIY1he8.png https://i.imgur.com/rIY1he8.png (yes I know color CP437/ANSI graphics was not a thing on 8080/Z80 CP/M. But it was not difficult to make it work and it looks pretty in Unreal).
- stevekemp 2y agoI haven't gotten round to trying the Hi-Tech compiler yet, primarily because it won't run under my emulator. I just added a couple of missing syscalls but the only output I see is "Out of memory". (Removing the "-v" flag causes it to generate some submit files, with $$$ suffix, but I don't yet support those in my CCP.) I'll try it on real hardware next week and if it works there I guess that'll be another fun bug to hunt down!
- nineteen999 2y agoI didn't bother with emulating CP/M itself, just the Z80 CPU+RAM and disk interface, which I made compatible with Udo Munk's z80pack. I was able to use the stock z80pack BIOS/BDOS so I didn't have any issue getting it to run. You are going deep!
- stevekemp 2y agoYeah I'm doing things the hard way, for sure! But the project grew little by little, and I'm enjoying the process. (And it has to be said one of the reasons I'm interested is because I have a Z80-based single-board computer which runs CP/M natively which helps for testing things.)
- kragen 2y agohave you tried bds c? it's fully free software now, runs under cp/m, and is reputed to be much nicer than aztec c, so i'm curious to hear your point of view fwiw i suspect implementing only ansi c function headers and declarations would result in a slightly smaller c compiler than implementing only the k&r style ones
- stevekemp 2y agoI downloaded it thanks to your comment, from this site: http://www.cpm.z80.de/develop.htm http://www.cpm.z80.de/develop.htm Worked first time to create a simple "Hello World" program, but many of the included examples fail to compile for me, with random errors: RM.C: 20: String too long (or missing quote) CP.C: 56: Curly-braces mismatched somewhere in this definition I'll have to explore more thoroughly later, but thanks for the prod!
- kragen 2y agohmm, that's disappointing! are there in fact missing quotes and mismatched curly braces in those files? i wonder if you got a corrupted copy of the compiler
- stevekemp 2y agoThe code looks good, there seems to be some surprises with files that use "#include <stdio.h>" or similar. The include-lines are the ones the errors refer to - but since those files come with the compiler distribution I'd have expected their contents to be well-formed. I removed the includes from a few files, changed FILEs to ints, and added "#define EOF -1", etc, which let some more simple code compile & link. But it felt like those changes shouldn't have been necessary. I guess the good news is the compiler ran without me having to add any new CP/M syscalls/bdos functions to my emulator - unlike hisoft which required that I implement "T_GET" (Get date and time) and a couple of other functions I'd been missing such as F_SIZE (For getting a file size).
- kragen 2y ago
- fuzztester 2y agoTurbo Pascal 3.x - under 40K, w/ basic text editor built-in. But could only create .COM files, not .EXEs. Lightning-fast DX.
- kragen 2y agothere's no such thing as a .exe file
- cowboylowrez 2y agono, I've seen them, they exist.
- kragen 2y agoyou can't run them on cp/m
- cowboylowrez 2y agoTIL! so if I wanted to save an exe to cpm, would "3x3" as a file extension work instead? are there other prohibitted file name extensions?
- kragen 2y agooh, you can store them on a cp/m disk, you just can't run them under cp/m
- fuzztester 2y agoOf course there was, and is.
- kragen 2y agonope, totally not a thing in cp/m, sorry
- fuzztester 2y ago>It's strange to go back to old-school function definitions: Ha ha, yes. The first edition of The C Programming Language book by Kernighan & Ritchie (the book popularly called just K&R) used those definitions. The second edition (the ANSI C one) used the latter kind of definition, the ANSI kind, with both function arguments and return values having (mandatory?) types. I remember I used to religiously use the latter kind from as soon as the C compilers I used, supported them.
- MaxBarraclough 2y ago> According to Michael Tiemann: > > I wrote GNU C++ in the fall of 1987, making it the first native-code C++ compiler in the world. I thought Walter Bright's Zortech C++ compiler held that honour, but apparently [0] that was released 1988. [0] http://www.edm2.com/index.php/Zortech_C%2B%2B http://www.edm2.com/index.php/Zortech_C%2B%2B
- WalterBright 2y agoTiemann's compiler was in beta, ZTC++ was released as a commercial product.
- kragen 2y agosee https://news.ycombinator.com/item?id=40270758 https://news.ycombinator.com/item?id=40270758 for more extensive discussion on this point
- mannyv 2y agoThis totally neglects to mention that the commercial c compilers kicked gcc's ass when it came to performance. Sun's cc and and IBM's xlc were substantially better across the board, and I know the latter supported profile-based optimization. There were also a bunch of commercial c compilers, all of which I've forgotten. gcc was the lowest common denominator compiler, with the benefits and drawbacks of being in that position. In any case gcc won the *nix compiler wars because it was free and easily accessible. Getting a license for the commercial compilers took work and/or funds, and the latter was something most unix users didn't have.
- johngossman 2y agoAnd they weren’t cheap either. The Sun compiler was over $1000 IIRC.
- pjmlp 2y agoThat was the reason why GCC adoption took off in first place. During the UNIX freebie days no one cared about Stalmman's freedoms. After Sun being the first UNIX vendor to split UNIX into multiple SKUs, for developers and users, then GCC suddenly became relevant after all. For languages like Ada, this was even worse, because SunOS/Solaris SDK only contained traditional UNIX compilers. For something like Sun Ada compiler, it was extra.
- anthk 2y agoYou all forgot something: on stability and speeds, Unix compilers rot over time. From 1996-1999, the stable choice on both speed and reliability was the GNU one. https://pages.cs.wisc.edu/~blbowers/fuzz-2001.pdf https://pages.cs.wisc.edu/~blbowers/fuzz-2001.pdf FVWM ran circles around MWM or CDE itself about speed. Rxvt was much lighter than an xterm, not everyone needed to plot Tek graphs. Even some late Irix users preferred JWM against the propietary options. Nowadays, GNU's the slight bloated one, being Guix the 'essential' GNU distro, making lots of 32 bit machines without SSD's a crawling nightmare to install.
- 2y ago
- johngossman 2y agoThis makes me feel very old. I remember that issue. I was a Pascal snob at the time but interested because C had a reputation for speed. A year later I got my first job and read K&R, not realizing I would be using C and C++ for most of my career. It mentions Lattice C. Does anybody here remember if Microsoft C was a fresh start, or did they license the entire codebase and use it for a start? I used Lattice on both PC and Amiga, but quickly dumped it on Amiga in favor of Aztec C, for which I still have fond memories. It was much faster and produced a ASM file intermediary which was useful for figuring out how to optimize. Nostalgia is a powerful drug. I’m sure I’d blanche with horror having to develop with those tools today.
- eesmith 2y agoThe linked-to article says: "One that has survived is Lattice C, one of the most performant of the compilers tested by Byte. Lattice C was so good that it was licensed by Microsoft and sold as Microsoft C V1.0 before being replaced by Microsoft’s own in-house Microsoft C V2.0 compiler."
- johngossman 2y agoI read that, but I'm not convinced it is correct. It is a best ambiguous--development could have gone internal but started with the Lattice codebase. It is also incorrect at least as to version numbers. MSC 3.0 was the first version that wasn't developed by Lattice, whatever the provenance of the source
- eesmith 2y agoPeter Norton wrote this in 1983: "The Microsoft C compiler has interesting historical roots. Although Microsoft itself works with C, this compiler is not a direct Microsoft product. Instead, it is an adaptation of the famous and highly regarded Lattice C compiler." There are also ads like https://archive.org/details/PC-Mag-1984-09-04/page/n51/mode/2up?q=lattice https://archive.org/details/PC-Mag-1984-09-04/page/n51/mode/... saying "Microsoft C compiler / Includes Lattice C and the MS Librarian". I can't find info about v2 or v3. Edit: https://winworldpc.com/product/microsoft-c-c/2x https://winworldpc.com/product/microsoft-c-c/2x says "Microsoft C 1.0 and 2.0 are a rebranded version of Lifeboat Associates Lattice C", so your doubt seems well founded.
- blairfrandeen 2y agoYou had me at "Free University Compiler Kit"
- e63f67dd-065b 2y agoIt was written by Tanenbaum, who worked at VU Amsterdam, which translates roughly in english to the Free University of Amsterdam. VU remains to this day a fairly significant institution in the field of CS academia.
- HarHarVeryFunny 2y agogcc really was a game changer. Software tools used to be really expensive. I remember in the 1980's buying both Rational System's Instant-C and WATCOM-C (32-bit DOS compiler) each for many hundreds of dollars before switching to free Linux and gcc. Instant-C was, at the time, a magical kind of product. It was basically a C interpreter that could resolve undefined symbols at runtime - run your program then write a function and continue if it was missing. You edited code by function rather than by file, so everything was incremental and instantaneous, a big contrast to the normal experience back then of kicking off a big build and practicing your juggling while it progressed..
- deleted 2y ago[deleted]
- cenamus 2y agoWas there a connection to any Lisps? Cause that sounds extremely like the interactive developement process there
- HarHarVeryFunny 2y agoI don't know if that was part of the inspiration or not - I don't recall Rational themselves selling LISP. It was really just a way to speed up the whole compile-link-debug cycle. It was only a relatively short-lived product - I suppose since the speed of Turbo-C provided much of the same benefit.
- anthk 2y agoA LISP 'repl' environment (read-eval-print-loop) works exactly like that. Stop on an error, fix it, continue like nothing. Unix and C where designed to fault/abort fast on errors, and showing no output on good behaviour.
- bwanab 2y agoLate 70s, I worked for a company that built embedded monitoring equipment. They'd been using the Intel 8051 coding it with assembly and had just done their first Z80 boards. I was fresh out of college and told them I could code it in C in 1/4 the time they'd been getting assembly code done. They gave the go ahead and I bought Whitesmith's cross compiler. I was able to code and test on the pdp-11s, then burn ROMs to test on the target machine. They were stunned when I requested another 4K of ROM, but went ahead. We did several devices this way before I moved on. They never went back to assembly though. Fun times.
- kragen 2y agohaha, yes, that's usually the way it goes!
- thefaux 2y ago> FORTRAN was provided for the IBM 1401 by an innovative 63-pass compiler Must have been fantastic to debug when there was an unexpected interaction between pass 37 and 51.
- mjcohen 2y agoIIRC, it was a 53-pass compiler.
- Someone 2y ago63, according to the paper they wrote about it in 1965. https://ibm-1401.info/1401-IBM-Systems-Journal-FORTRAN.html https://ibm-1401.info/1401-IBM-Systems-Journal-FORTRAN.html: “The 1401 FORTRAN compiler has 63 phases, an average of 150 instructions per phase, and a maximum of 300 instructions in any phase.” The phases aren’t all what I would call a compilation phase, though. For example, phase zero: “Phase 00 - Snapshot. Loads a snapshot routine into 350 positions of core storage. This routine lists a specified amount of core storage.”
- svilen_dobrev 2y agoAbout 1988-1990, There was a Metaware HighC (and C++) compiler, which had platform-coverage comparable to GNU - RISCs, intel x86, etc. With own "yield" extension (yeah, generators/coroutines, back then), and few others. Maybe the first locally And globally heavily optimizing one.. the assembly code produced was looking rather weird But was faster and/or smaller than others. no idea what happened to that company
- WalterBright 2y agoThe article neglects to mention Datalight C, the first C compiler using data flow analysis optimizations. It did such a good job that the magazine reviewers decided it was cheating by deleting the meat of their benchmark codes. What actually was going on was the benchmark code was proven by DFA to do nothing, so was removed. Within a year other compilers started doing DFA. The article also neglects Zortech C++, the first native code generating C++ compiler. ZTC++ was the catalyst that made C++ a major language, as the PC was where 90% of the programming was. Before ZTC++, C++ and Objective-C were neck and neck, judging from the volume on comp.lang.c++ and comp.lang.objectivec. With ZTC++, the volume of the former exploded, and Objective-C disappeared into oblivion (later resurrected by Apple for a while).
- WalterBright 2y agoP.S. The DFA I wrote for Datalight C still persists in the DMD D compiler: https://github.com/dlang/dmd/blob/master/compiler/src/dmd/backend/gflow.d https://github.com/dlang/dmd/blob/master/compiler/src/dmd/ba...
- kragen 2y agothese are indeed significant omissions, and you wrote both datalight c and zortech c++
- WalterBright 2y agoSome compilers I've written are Northwest C, Datalight C, Zortech C, Zortech C++, Symantec C++, Digital Mars C++, and the Digital Mars D compiler. The last one, DMD, still has code in it from those previous compilers :-/ I've also written a Java compiler (not from scratch) and a Javascript compiler/interpreter, and designed the ABEL (Advanced Boolean Expression Language) PLD compiler.
- kragen 2y agoi don't know if you should admit to that last one, you might have to hide from people who program cplds
- teo_zero 2y agoI still remember my first steps with C on my Amiga, after years of BASIC. I opted for the Dice compiler because Lattice was too expensive. At that time the norm was to send the money via mail and receive floppy disks in exchange via the same means. By pure chance, the Dice distributor in my country lived in my city and we could close the deal in person, in a parking lot like smugglers or pushers!
- robinsonb5 2y agoDice was very nice - and later on vbcc was pretty cool, too. In fact vbcc is so nice I used it for a toy CPU project a couple of years ago, because its backend interface is unusually well-documented and accessible. (I think tangling with either gcc or llvm would likely have added another six months to the project.)
- massifist 2y agoI remember sometime back in the 90's buying a used copy of Visual C++ 5.0 from some dude at the mall. It felt kinda shady, like a drug deal was going down, but I turned out well and I scored a legit(?) copy for much cheaper than market value. I was very excited when I got it home, and it kept me busy for a long while. There's a lot of good documentation (and source code) on those CD's and it taught me a lot, (pretty much) coming from Quake C. I think at some point I also started using DJGPP, which pushed me toward GCC (and Linux).
- int_19h 2y agoIn those days, the CDs included the entirety of MSDN for local use - indeed, most CDs in the box were MSDN. And IMO the documentation was better written, too.
- kragen 2y agoi would have thought 01983 was a bit early for > many insist that C is the programming language and that it will last forever but it's 41 years later and c is #2 on https://www.tiobe.com/tiobe-index/ https://www.tiobe.com/tiobe-index/, followed by c++, which is almost a superset. items #4, #5, and #6 use c syntax but are high-level languages, and item #7 is a redesign of c as a high-level language with different syntax by, in large part, the bell labs team that designed c in the first place. the #1 item is a high-level language that departs significantly from c syntax, but its almost-universally-used interpreter is written in c 41 years isn't forever but it's longer than computers had existed in 01983. so that's not a bad showing, especially given the thousands of programming languages that existed before c ______ (for future reference, the somewhat questionable ranking in the article i linked is currently python, c, c++, java, c#, js, golang, 'visual basic', sql, fortran, delphi/object pascal, assembly language, ruby, swift, scratch, matlab, php, kotlin, rust, and r.)
- phicoh 2y agoYes, both C and Unix are amazing designs. Far from perfect, but good tools for many jobs. In my opinion, it is now time for Rust to take over. But comparing Rust to C, it took a huge amount of improvement over C to replace C.
- kragen 2y agoi don't think rust has replaced c, or is likely to preceding c, there was a large, complex, portable algol-family language capable of handling a range of applications similar to c's, called pl/1. if you read 'the elements of programming style', from about the time c was born, many of the examples are in fortran; most others are in pl/1. gary kildall's first job working on microcomputers was at intel writing pl/m, a cut-down pl/1 for microcomputers, for which he wrote cp/m, from which ms-dos grew. ibm's database db2 is still written in a dialect of pl/1 called pl/x. one of wirth's first languages was a thing called pl/360, which was a version of pl/1 with extra low-level facilities for bootstrapping a better language in short, pl/1 was very widely used and highly influential, even though it's almost forgotten today and that's because it kind of sucked. compiling it required a large computer and even then was slow. even at the beginning, it was highly complex, so learning it took a long time. this got worse over time as more and more features were piled onto it, often as ill-advised efficiency hacks that then couldn't be removed, because people's programs depended on them. because it was highly complex, and there were a lot of surprising problems that resulted from complex interactions of all its complex features; compiler developers improved this situation significantly by working hard to provide better error messages, but that only diminished the problem rather than eliminating it the preceding paragraph describes rust exactly as well as it describes pl/1, so if someone succeeds in producing a c-like small, simple language that provides enough of rust's unique advantages (which are indeed very compelling) i expect that it will replace rust i doubt it will replace c tho
- Blackstrat 2y agoGood article. As of the early 90s, Watcom was by far the best compiler option for professional development on Windows and OS/2. We used both Microsoft and IBM before settling on Watcom. Borland was fun on home PCs, but we didn’t approve it for commercial development. Also did a large LAN based system in UCSD-Pascal in the mid-80s. Visual Basic and the Web really ruined my programming desires.
- stergios 2y agoHopefully the next part covers some of the compilers available on the 68k personal computers of the late mid to late 80s. MegaMax and Manx come to mind a some of the more prominent examples.
- Koshkin 2y agoThe Tiny C compiler deserves to be mentioned.