B (programming language): Difference between revisions
Jump to navigation
Jump to search
imported>Freenull Undid revision 1292149307 by Kirdow (talk). Just because it references something created by a person that makes videos on the internet doesn't mean it's automatically vandalism. B is effectively a dead language with no reference implementations and you can count the ones usable on modern computers on one hand. Having a few links to real implementations is surely useful. Added two more for completeness' sake. |
|||
| Line 1: | Line 1: | ||
{{Short description|Procedural programming language}} | {{Short description|Procedural programming language}} | ||
{{ | {{About|the language developed at Bell Labs|the predecessor of the ABC language|ABC (programming language)}} | ||
{{Infobox programming language | {{Infobox programming language | ||
| name = B | | name = B | ||
| Line 6: | Line 6: | ||
| logo caption = | | logo caption = | ||
| paradigm = | | paradigm = | ||
| year = {{start date and age|1969}}<ref>{{cite | | year = {{start date and age|1969}}<ref>{{cite encyclopedia|url=http://www.britannica.com/EBchecked/topic/1663863/B|title=B - computer programming language |encyclopedia=Encyclopedia Britannica }}</ref> | ||
| designer = [[Ken Thompson (computer programmer)|Ken Thompson]] | | designer = [[Ken Thompson (computer programmer)|Ken Thompson]] | ||
| developer = | | developer = Ken Thompson, [[Dennis Ritchie]] | ||
| latest_release_version = | | latest_release_version = | ||
| latest_release_date = | | latest_release_date = | ||
| latest_test_version = | | latest_test_version = | ||
| latest_test_date = | | latest_test_date = | ||
| typing = typeless (everything is a [[Word (computer architecture)|word]]) | | typing = typeless (everything is a [[Word (computer architecture)|word]]) | ||
| dialects = | | dialects = | ||
| influenced_by = [[BCPL]], [[PL/I]], [[TMG (language)|TMG]] | | influenced_by = [[Fortran]], [[BCPL]], [[PL/I]], [[TMG (programming language)|TMG]] | ||
| influenced = [[C (programming language)|C]] | | influenced = [[C (programming language)|C]] | ||
| implementations = [https://github.com/ | | implementations = [https://github.com/wgibbs-rs/blang BLang LLVM-based B Compiler], [https://github.com/tsoding/b B by Alexey Kutepov (incomplete)], [https://github.com/Spydr06/BCause BCause, A Modern B Compiler] | ||
| operating_system = | | operating_system = | ||
| license = | | license = | ||
| Line 26: | Line 25: | ||
'''B''' is a [[programming language]] developed at [[Bell Labs]] circa 1969 by [[Ken Thompson (computer programmer)|Ken Thompson]] and [[Dennis Ritchie]]. | '''B''' is a [[programming language]] developed at [[Bell Labs]] circa 1969 by [[Ken Thompson (computer programmer)|Ken Thompson]] and [[Dennis Ritchie]]. | ||
B was designed for recursive, non-numeric, machine-independent applications, such as system and language software.<ref name=bur>{{cite web | B was designed for recursive, non-numeric, machine-independent applications, such as system and language software.<ref name=bur>{{cite web | ||
| Line 47: | Line 44: | ||
{{rquote|quote=BCPL semantics with a lot of SMALGOL syntax|author=Ken Thompson|source=<ref name=Ars>{{cite web |last1=Jensen |first1=Richard |title="A damn stupid thing to do"—the origins of C |url=https://arstechnica.com/features/2020/12/a-damn-stupid-thing-to-do-the-origins-of-c/ |website=Ars Technica |access-date=2022-03-28 |language=en-us |date=9 December 2020}}</ref>}} | {{rquote|quote=BCPL semantics with a lot of SMALGOL syntax|author=Ken Thompson|source=<ref name=Ars>{{cite web |last1=Jensen |first1=Richard |title="A damn stupid thing to do"—the origins of C |url=https://arstechnica.com/features/2020/12/a-damn-stupid-thing-to-do-the-origins-of-c/ |website=Ars Technica |access-date=2022-03-28 |language=en-us |date=9 December 2020}}</ref>}} | ||
Ken Thompson began developing B as a [[Fortran]] compiler for the [[PDP-7]], but found that his initial implementation far exceeded available memory. Through several iterations of simplifying the compiler and adapting the language to his own tastes that were influenced by [[BCPL]], he arrived at a language that expressed a subset of BCPL semantics in a distinct syntax. Thompson named the language B, which has been variously explained as an abbreviation of BCPL or Bon, another language he had developed, although he confirmed neither explanation.<ref name="chist">{{cite journal| first = Dennis M.| last = Ritchie| author-link = Dennis Ritchie| title = The Development of the C Language| date=March 1993 | journal = ACM SIGPLAN Notices| volume = 28 | issue = 3| pages = 201–208| url = http://www.bell-labs.com/usr/dmr/www/chist.html| doi = 10.1145/155360.155580|doi-access = free}}</ref><ref name="vcfeast">{{cite web|url=https://www.youtube.com/watch?v=EY6q5dv_B-o|title=VCF East: Ken Thompson interviewed by Brian Kernighan |website=[[YouTube]] |date=6 May 2019 }} 41:07</ref> | |||
Thompson added "two-address assignment operators" using <code>x =+ y</code> syntax to add y to x (in C the operator is written <code>+=</code>). This syntax came from [[Douglas McIlroy]]'s implementation of [[TMG (language)|TMG]], in which B's compiler was first implemented (and it came to TMG from [[ALGOL 68]]'s <code>x +:= y</code> syntax).<ref name=chist /><ref>{{cite web |author=Michael S. Mahoney |author-link=Michael Sean Mahoney |url=https://www.princeton.edu/~hos/mike/transcripts/mcilroy.htm |title=Interview with M.D. McIlroy |location=Murray Hill |date=18 August 1989|website=Princeton.edu}}</ref> Thompson went further by inventing the increment and decrement operators (<code>++</code> and <code>--</code>). Their prefix or postfix position determines whether the value is taken before or after alteration of the operand. This innovation was not in the earliest versions of B. According to Dennis Ritchie, people often assumed that they were created for the auto-increment and auto-decrement address modes of the DEC PDP-11, but this is historically impossible as the machine didn't exist when B was first developed.<ref name=chist /> | Thompson added "two-address assignment operators" using <code>x =+ y</code> syntax to add y to x (in C the operator is written <code>+=</code>). This syntax came from [[Douglas McIlroy]]'s implementation of [[TMG (language)|TMG]], in which B's compiler was first implemented (and it came to TMG from [[ALGOL 68]]'s <code>x +:= y</code> syntax).<ref name=chist /><ref>{{cite web |author=Michael S. Mahoney |author-link=Michael Sean Mahoney |url=https://www.princeton.edu/~hos/mike/transcripts/mcilroy.htm |title=Interview with M.D. McIlroy |location=Murray Hill |date=18 August 1989|website=Princeton.edu}}</ref> Thompson went further by inventing the increment and decrement operators (<code>++</code> and <code>--</code>). Their prefix or postfix position determines whether the value is taken before or after alteration of the operand. This innovation was not in the earliest versions of B. According to Dennis Ritchie, people often assumed that they were created for the auto-increment and auto-decrement address modes of the DEC PDP-11, but this is historically impossible as the machine didn't exist when B was first developed.<ref name=chist /> | ||
B is typeless, or more precisely has one data type: the computer word. Most operators (e.g. <code>+</code>, <code>-</code>, <code>*</code>, <code>/</code>) treated this as an integer, but others treated it as a memory address to be [[reference (computer science)|dereferenced]]. In many other ways it looked a lot like an early version of C. It included a generalized [[for loop]] as later appeared in C, which Thompson adapted from earlier work by [[Stephen C. Johnson|Stephen Johnson]].<ref name="vcfeast"/> There are a few library functions, including some that vaguely resemble functions from the [[stdio.h|standard I/O library]] in C.<ref name=bur /> | |||
In Thompson's words: "B and the old old C were very very similar languages except for all the types [in C]".<ref name="vcfeast"/> | |||
B is typeless, or more precisely has one data type: the computer word. Most operators (e.g. <code>+</code>, <code>-</code>, <code>*</code>, <code>/</code>) treated this as an integer, but others treated it as a memory address to be [[reference (computer science)|dereferenced]]. In many other ways it looked a lot like an early version of C. There are a few library functions, including some that vaguely resemble functions from the [[stdio.h|standard I/O library]] in C.<ref name=bur /> | |||
In Thompson's words: "B and the old old C were very very similar languages except for all the types [in C]".<ref name=" | |||
Early implementations were for the DEC [[PDP-7]] and [[PDP-11]] minicomputers using early [[Unix]], and [[Honeywell]] {{nowrap|[[GE-600 series|GE 645]]}}<ref name="Evolution">{{cite journal |first=Dennis M. |last=Ritchie |title=The Evolution of the Unix Time-sharing System |url=https://www.bell-labs.com/usr/dmr/www/hist.html |archive-url=https://web.archive.org/web/20150611114353/https://www.bell-labs.com/usr/dmr/www/hist.html |archive-date=11 June 2015 |journal=AT&T Bell Laboratories Technical Journal |volume=63 |number=6 Part 2 |year=1984 |pages=1577–1593|doi=10.1002/j.1538-7305.1984.tb00054.x |url-access=subscription }}</ref> 36-bit mainframes running the operating system [[General Comprehensive Operating System|GCOS]]. The earliest PDP-7 implementations compiled to [[threaded code]], and Ritchie wrote a compiler using [[TMG (language)|TMG]] which produced machine code.<ref>{{cite web |url=http://www.multicians.org/tmg.html |title=TMG |publisher=multicians.org}}</ref><ref>{{cite web |url=https://www.bell-labs.com/usr/dmr/www/chist.html |archive-url=https://web.archive.org/web/20150611114355/https://www.bell-labs.com/usr/dmr/www/chist.html |archive-date=11 June 2015 |title=The Development of the C Language |first=Dennis M. |last=Ritchie |author-link=Dennis Ritchie |publisher=Bell Labs/Lucent Technologies}}</ref><ref name="reader">{{cite tech report |first1=M. D. |last1=McIlroy |author-link1=Douglas McIlroy |year=1987 |url=http://www.cs.dartmouth.edu/~doug/reader.pdf |archive-url=https://ghostarchive.org/archive/20221009/http://www.cs.dartmouth.edu/~doug/reader.pdf |archive-date=2022-10-09 |url-status=live |title=A Research Unix reader: annotated excerpts from the Programmer's Manual, 1971–1986 |series=CSTR |number=139 |institution=Bell Labs}}</ref> In 1970 a PDP-11 was acquired and threaded code was used for the port; an assembler, {{samp|[[dc (Unix)|dc]]}}, and the B language itself were written in B to [[Bootstrapping|bootstrap]] the computer. An early version of [[yacc]] was produced with this PDP-11 configuration. Ritchie took over maintenance during this period.<ref name=chist />{{r|reader}} | Early implementations were for the DEC [[PDP-7]] and [[PDP-11]] minicomputers using early [[Unix]], and [[Honeywell]] {{nowrap|[[GE-600 series|GE 645]]}}<ref name="Evolution">{{cite journal |first=Dennis M. |last=Ritchie |title=The Evolution of the Unix Time-sharing System |url=https://www.bell-labs.com/usr/dmr/www/hist.html |archive-url=https://web.archive.org/web/20150611114353/https://www.bell-labs.com/usr/dmr/www/hist.html |archive-date=11 June 2015 |journal=AT&T Bell Laboratories Technical Journal |volume=63 |number=6 Part 2 |year=1984 |pages=1577–1593|doi=10.1002/j.1538-7305.1984.tb00054.x |url-access=subscription }}</ref> 36-bit mainframes running the operating system [[General Comprehensive Operating System|GCOS]]. The earliest PDP-7 implementations compiled to [[threaded code]], and Ritchie wrote a compiler using [[TMG (language)|TMG]] which produced machine code.<ref>{{cite web |url=http://www.multicians.org/tmg.html |title=TMG |publisher=multicians.org}}</ref><ref>{{cite web |url=https://www.bell-labs.com/usr/dmr/www/chist.html |archive-url=https://web.archive.org/web/20150611114355/https://www.bell-labs.com/usr/dmr/www/chist.html |archive-date=11 June 2015 |title=The Development of the C Language |first=Dennis M. |last=Ritchie |author-link=Dennis Ritchie |publisher=Bell Labs/Lucent Technologies}}</ref><ref name="reader">{{cite tech report |first1=M. D. |last1=McIlroy |author-link1=Douglas McIlroy |year=1987 |url=http://www.cs.dartmouth.edu/~doug/reader.pdf |archive-url=https://ghostarchive.org/archive/20221009/http://www.cs.dartmouth.edu/~doug/reader.pdf |archive-date=2022-10-09 |url-status=live |title=A Research Unix reader: annotated excerpts from the Programmer's Manual, 1971–1986 |series=CSTR |number=139 |institution=Bell Labs}}</ref> In 1970 a PDP-11 was acquired and threaded code was used for the port; an assembler, {{samp|[[dc (Unix)|dc]]}}, and the B language itself were written in B to [[Bootstrapping|bootstrap]] the computer. An early version of [[yacc]] was produced with this PDP-11 configuration. Ritchie took over maintenance during this period.<ref name=chist />{{r|reader}} | ||
| Line 91: | Line 86: | ||
/* Wikipedia note: the auto keyword declares a variable with | /* Wikipedia note: the auto keyword declares a variable with | ||
automatic storage (lifetime is function scope), not | automatic storage (lifetime is function scope), not | ||
"automatic typing" as in C++11 | "automatic typing" as in C++11 and C23 */ | ||
if(a=n/b) /* assignment, not test for equality */ | if(a=n/b) /* assignment, not test for equality */ | ||
| Line 133: | Line 128: | ||
n 2000; | n 2000; | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== References == | == References == | ||
| Line 143: | Line 135: | ||
* [http://man.cat-v.org/unix-1st/1/b Manual page for b(1) from Unix First Edition] | * [http://man.cat-v.org/unix-1st/1/b Manual page for b(1) from Unix First Edition] | ||
* [https://www.bell-labs.com/usr/dmr/www/chist.html The Development of the C Language], [[Dennis Ritchie|Dennis M. Ritchie]]. Puts B in the context of [[BCPL]] and [[C (programming language)|C]]. | * [https://www.bell-labs.com/usr/dmr/www/chist.html The Development of the C Language], [[Dennis Ritchie|Dennis M. Ritchie]]. Puts B in the context of [[BCPL]] and [[C (programming language)|C]]. | ||
* ''[https://www.bell-labs.com/usr/dmr/www/kbman.html Users' Reference to B]'', Ken Thompson. Describes the [[PDP-11]] version. | * ''[https://web.archive.org/web/20240425202455/https://www.bell-labs.com/usr/dmr/www/kbman.html Users' Reference to B]'', Ken Thompson. Describes the [[PDP-11]] version. | ||
* [https://www.bell-labs.com/usr/dmr/www/bintro.html The Programming Language B], S. C. Johnson & B. W. Kernighan, Technical Report CS TR 8, [[Bell Labs]] (January 1973). The [[General Comprehensive Operating System|GCOS]] version on [[Honeywell]] equipment. | * [https://www.bell-labs.com/usr/dmr/www/bintro.html The Programming Language B], S. C. Johnson & B. W. Kernighan, Technical Report CS TR 8, [[Bell Labs]] (January 1973). The [[General Comprehensive Operating System|GCOS]] version on [[Honeywell]] equipment. | ||
* [http://www.thinkage.ca/english/gcos/expl/b/index.html B Language Reference Manual], Thinkage Ltd. The production version of the language as used on GCOS, including language and runtime library. | * [http://www.thinkage.ca/english/gcos/expl/b/index.html B Language Reference Manual], Thinkage Ltd. The production version of the language as used on GCOS, including language and runtime library. | ||
| Line 149: | Line 141: | ||
{{Ken Thompson navbox}} | {{Ken Thompson navbox}} | ||
{{Programming languages}} | {{Programming languages}} | ||
{{ | {{portal bar|Computer programming}} | ||
[[Category:Procedural programming languages]] | [[Category:Procedural programming languages]] | ||
[[Category:Programming languages]] | [[Category:Programming languages]] | ||
[[Category:Programming languages created in 1969]] | [[Category:Programming languages created in 1969]] | ||