4 ms·
I am currently in the process of learning C and having never seen any B code before I am rather surprised at their striking similarities. What could C do at the
by I_Byte 5y ago
I am currently in the process of learning C and having never seen any B code before I am rather surprised at their striking similarities. What could C do at the time that B couldn’t? Why did C eventually replace B?
- edgyquant 5y agoB was interpreted while C wasn’t. C is basically compiled B which is why the letter was incremented.
- AnimalMuppet 5y agoThe linked article says that B was compiled...
- edgyquant 5y agoWell everything I’ve ever read says otherwise and it’s often referred to as an interpreter. http://progopedia.com/language/b/ http://progopedia.com/language/b/ >B is an interpreted programming language for mini-computers, a direct descendant of BCPL and ancestor of C. http://www.catb.org/~esr/writings/taoup/html/c_evolution.html http://www.catb.org/~esr/writings/taoup/html/c_evolution.htm... >based on Ken Thompson's earlier B interpreter which had in turn been modeled on BCPL, Iirc, and it’s been a while since I’ve read the history of Unix. B started as an interpreted language but evolved into C as types were added and it was switched to compiled to better interact with UNIX operating system internals (with Ritchie wanting to rewrite large portions of Unix in the new language.)
- IncRnd 5y agoThat's not exactly correct. Here is a snippet from an interview of B's creator, Ken Thompson in 1989, explaining this: "MSM: Did you develop B? Thompson: I did B. MSM: As a subset of BCPL Thompson: It wasn't a subset. It was almost exactly the same. It was a interpreter instead of a compiler. It had two passes. One went into intermediate language and which one was the interpreter of the intermediate language. Dennis wrote a compiler for B, that worked out of the intermediate language." ~ https://www.princeton.edu/~hos/mike/transcripts/thompson.htm https://www.princeton.edu/~hos/mike/transcripts/thompson.htm
- edgyquant 5y agoAh okay I figured I was remembering incorrectly but was pretty sure it was, at least initially, interpreted.
- aap_ 5y agoThe B version for the Honeywell 6070 was compiled. B on the PDP-7 and -11 was interpreted. In fact I have a writeup on the threaded code for these two: http://squoze.net/B/ http://squoze.net/B/
- gerdesj 5y agoYou could start here: https://en.wikipedia.org/wiki/B_(programming_language) https://en.wikipedia.org/wiki/B_(programming_language) As always on HN there is a certain amount of ... discussion about some of the finer points, generally about typing. I suspect that if you follow the refs in the WP article most of the usual bikeshedding here will resolve itself satisfactorily. For me (50 year old bloke) I dimly recall C always being available https://en.wikipedia.org/wiki/C_(programming_language) https://en.wikipedia.org/wiki/C_(programming_language) - apparently 1972ish so I was 2 or 3 when C came out and replaced B which probably didn't do much .... Oh look at this (wrt B): "However, it continues to see use on GCOS mainframes (as of 2014)"
- raygard 5y agoI used that B compiler on a Honeywell GCOS mainframe in the late 1970s and early 1980s. It was a blindingly fast compiler written at University of Waterloo by a Brazilian named Reinaldo Braga. Still available from a Canadian company named Thinkage. The Honeywell 6000 series used 36 bit words. C was needed because the byte-addressed PDP-11 was a bad fit for the word oriented B language. See https://archive.org/details/bstj57-6-1991 https://archive.org/details/bstj57-6-1991 for details.
- skissane 5y agoThinkage is still around, here is the B compiler manual from their website: https://www.thinkage.ca/gcos/expl/b/manu/manu.html https://www.thinkage.ca/gcos/expl/b/manu/manu.html Although it appears their main business nowadays is a Windows-based application to manage maintenance requests for landlords, etc
- kragen 5y agochar. float. a.out.
- asveikau 5y agoI don't know the answer to your question, but it's worth mentioning as well that C itself was pretty different before C89.
- enf 5y agoTypes and especially structured types. https://www.bell-labs.com/usr/dmr/www/chist.html https://www.bell-labs.com/usr/dmr/www/chist.html
- mettamage 5y agoYou just caught me at a moment where I'm reading Tanenbaum's book on Modern Operating Systems. Tanenbaum simplifies a lot of things, but here is his contribution [1]: > The second development concerned the language in which UNIX was written. By now it was becoming painfully obvious that having to rewrite the entire system for each new machine was no fun at all [0], so Thompson decided to rewrite UNIX in a high-level language of his own design, called B. B was a simplified form of BCPL (which itself was a simplified form of CPL, which, like PL/I, never worked). Due to weaknesses in B, primarily lack of structures, this attempt was not successful. Ritchie then designed a successor to B, (naturally) called C, and wrote an excellent compiler for it. Working together, Thompson and Ritchie rewrote UNIX in C. C was the right language at the right time and has dominated system programming ever since. Tanenbaum doesn't say it, but it almost seems like B and C were designed for creating UNIX. I wonder to what extent the authors of B and C were designing the languages for creating UNIX. [0] In one of the previous paragraphs, Tanenbaum mentioned that the first version of UNIX was written in assembly. [1] Modern Operating Systems (ed. 4, p. 715)
- lultimouomo 5y ago> All arithmetic in B is integer, unless special functions are written. There is no equivalent of the Fortran IJKLMN convention, no floating point, no data types, no type conversions, and no type checking. Users of double-precision complex will have to fend for themselves. This seems like a biggie.