B (programming language)

From Bauman National Library
This page was last modified on 21 May 2016, at 23:49.
B
Paradigm procedural
Designed by Ken Thompson, Dennis Ritchie
First appeared 1969
Typing discipline static
Website None
Influenced by
BCPL
Influenced
C

The B - programming language is an obsolete language that represented the transition between BCPL and language C. It is mainly the work of Ken Thompson and he appeared for the first time in about 1969.

History

The nature without types of B had sense in the Honeywell, on the PDP-7 and many other old computers, but it was a problem in the PDP-11 because it was difficult to access character types of data that the PDP-11 and most modern computers endured. Beginning in 1971, Ritchie made changes to the language while becoming your compiler to produce native machine language. The most notable was the addition of different data types for variables.

During 1971 and 1972 B evolved first "New B" (New B, NB) and then in C. Later, in early 1973, was added a preprocessor at the request of Alan Snyder.

The effort was sufficiently complete in this year during the summer to the core UNIX system for the PDP-11 was rewritten in C.

During the period 1972-1973 there was the need to port to Honeywell 635 and IBM 360/370, so Mike Lesk wrote the "package E / S portable" that would become the "standard I / S" (standard I / O or stdio) C language

B was continued until the 90 using in certain Honeywell mainframes and embedded systems for a variety of reasons, including limited use of hardware in these systems; extensive libraries, tools; or simply because it was good enough to do the job.

The hugely influential AberMUD was written in B.

Examples

Below are two examples of programs written in B.

main() 
  {
     auto a, b, c, sum;
     a = 1; b = 2; c = 3;
     sum = a+b+c;
     putnumb(sum); 
  }
main() {
  auto c;
  auto d;
  d=0;
  while(1) {
    c=getchar();
    d=d+c;
    putchar(c);
  }
}

Program that prints the first N perfect numbers, where N is the user input:

main()
{
    auto n,num,soma,cont;    num = 0;	
    cont = 0;

    printf( "Enter a value for N: *n*n");

    n=getchar();    printf( "\nThe first perfect numbers are: \n");

    while (cont != n);
    {
        num =num+1;
        soma = 0;
		auto i=1;
        while(i <= num-1)
        {
            if( (num % i) == 0 )
            {
                soma =soma+ i;
            }
	    i=i+1;
        }
        if ( soma == num )
        {
            printf("%d*n",soma);
            cont =cont+1;
        }
    }
}

Another example:

/* The following function will print a non-negative number, n, to
   the base b, where 2<=b<=10.  This routine uses the fact that
   in the ASCII character set, the digits 0 to 9 have sequential
   code values.  */

printn(n, b) {
        extrn putchar;
        auto a;

        if (a = n / b)        /* assignment, not test for equality */
                printn(a, b); /* recursive */
        putchar(n % b + '0');
}

External links

  1. http://man.cat-v.org/unix-1st/1/b
  2. https://www.bell-labs.com/usr/dmr/www/chist.html
  3. https://www.bell-labs.com/usr/dmr/www/kbman.html
  4. https://www.bell-labs.com/usr/dmr/www/bintro.html