bs is a programming language and a compiler/interpreter for modest-sized programs on
UNIX
Unix (; trademarked as UNIX) is a family of multitasking, multiuser computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, a ...
systems.
[ The bs command can be invoked either for interactive programming or with a file containing a program, optionally taking arguments, via a ]Unix shell
A Unix shell is a command-line interpreter or shell that provides a command line user interface for Unix-like operating systems. The shell is both an interactive command language and a scripting language, and is used by the operating system t ...
, e.g., using a Shebang (Unix) #!/usr/bin/bs.
An early man page
A man page (short for manual page) is a form of software documentation usually found on a Unix or Unix-like operating system. Topics covered include computer programs (including library and system calls), formal standards and conventions, and ev ...
states, " bs">kbd>bsis a remote descendant of Basic
BASIC (Beginners' All-purpose Symbolic Instruction Code) is a family of general-purpose, high-level programming languages designed for ease of use. The original version was created by John G. Kemeny and Thomas E. Kurtz at Dartmouth College ...
icand SNOBOL4, with a little C thrown in."[
]
History
The bs command appears in UNIX System III Release 3.0 (1980), first released outside of Bell Labs
Nokia Bell Labs, originally named Bell Telephone Laboratories (1925–1984),
then AT&T Bell Laboratories (1984–1996)
and Bell Labs Innovations (1996–2007),
is an American industrial research and scientific development company owned by mult ...
in 1982.[ It was written by Dick Haight (Richard C. Haight) circa 1978, who recounts it as follows:][Personal communication from Dick Haight, 10 September 2019.]
The Release 3.0 manual mentions bs prominently on page 9 (emphasis added):[
While not released outside prior to System III, the bs command was present internally in UNIX/TS 1.0 (November 1978),][Personal conversation with ]John R. Mashey
John R. Mashey (born 1946) is an American computer scientist, director and entrepreneur.
Career
Mashey holds a Ph.D. in computer science from Pennsylvania State University, where he developed the ASSIST assembler language teaching software. He w ...
, 9 September 2019. PWB/UNIX 2.0 (June 1979),[ and CB UNIX editions 2.1 (November 1979)]["CB/UNIX man 7"]
'' The Unix Heritage Society'', November 1979. Retrieved on 9 September 2019.["CB/UNIX man 1"]
'' The Unix Heritage Society'', November 1979. Retrieved on 9 September 2019. and 2.3 (1981).
The bs command does not appear in some earlier internal releases, e.g., the UNIX Support Group’s March 1977 release,[ nor the PWB/UNIX manual dated May, 1977, suggesting its creation circa 1978. It does not appear in any version of ]Research Unix
The term "Research Unix" refers to early versions of the Unix operating system for DEC PDP-7, PDP-11, VAX and Interdata 7/32 and 8/32 computers, developed in the Bell Labs Computing Sciences Research Center (CSRC).
History
The term ''Resear ...
nor the Berkeley Software Distribution
The Berkeley Software Distribution or Berkeley Standard Distribution (BSD) is a discontinued operating system based on Research Unix, developed and distributed by the Computer Systems Research Group (CSRG) at the University of California, Ber ...
.
Subsequently and into the 1990s, bs was included in a variety of System III-derived or System V-derived commercial operating systems including, but not limited to: PC/IX;[ ]UNIX System V
Unix System V (pronounced: "System Five") is one of the first commercial versions of the Unix operating system. It was originally developed by AT&T and first released in 1983. Four major versions of System V were released, numbered 1, 2, 3, an ...
Releases 2 & 3: SVR2
Unix System V (pronounced: "System Five") is one of the first commercial versions of the Unix operating system. It was originally developed by AT&T and first released in 1983. Four major versions of System V were released, numbered 1, 2, 3, ...
,[ ]SVR3
Unix System V (pronounced: "System Five") is one of the first commercial versions of the Unix operating system. It was originally developed by AT&T and first released in 1983. Four major versions of System V were released, numbered 1, 2, 3, an ...
, SVR3.2 (1986);[ ]HP-UX
HP-UX (from "Hewlett Packard Unix") is Hewlett Packard Enterprise's proprietary implementation of the Unix operating system, based on Unix System V (initially System III) and first released in 1984. Current versions support HPE Integrit ...
;[ AIX;][ and ]A/UX
A/UX is Apple Computer's Unix
Unix (; trademarked as UNIX) is a family of multitasking, multiuser computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by ...
.[
(The User's Manual for the AT&T UNIX PC (3B1) specifically mentions that the bs command is not available, but that it is available on SVR3.2.][)
Occasionally, bs was touted as one of the primary programming languages for development under UNIX.][ However, bs is not included in the POSIX.1 commands and utilities (the standard ]List of Unix commands
This is a list of Unix commands as specified by IEEE Std 1003.1-2008, which is part of the Single UNIX Specification (SUS). These commands can be found on Unix operating systems and most Unix-like operating systems.
List
See also
* List of G ...
) nor in the Single UNIX Specification and is not provided with most contemporary operating systems. For example in Linux
Linux ( or ) is a family of open-source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically packaged as a Linux distribution, which i ...
, similar syntax and functionality is provided by bc, Perl
Perl is a family of two High-level programming language, high-level, General-purpose programming language, general-purpose, Interpreter (computing), interpreted, dynamic programming languages. "Perl" refers to Perl 5, but from 2000 to 2019 it ...
, and POSIX shell.
In the 21st century, bs is present in, at least, HP-UX
HP-UX (from "Hewlett Packard Unix") is Hewlett Packard Enterprise's proprietary implementation of the Unix operating system, based on Unix System V (initially System III) and first released in 1984. Current versions support HPE Integrit ...
Release 11i (2000),[ as well as AIX versions 6.1 (2007)][ and 7.2 (2018),][ likely due to their ]UNIX System V
Unix System V (pronounced: "System Five") is one of the first commercial versions of the Unix operating system. It was originally developed by AT&T and first released in 1983. Four major versions of System V were released, numbered 1, 2, 3, an ...
heritage.
Design and features
The bs[ ]man page
A man page (short for manual page) is a form of software documentation usually found on a Unix or Unix-like operating system. Topics covered include computer programs (including library and system calls), formal standards and conventions, and ev ...
, ostensibly the programming language's only specification, characterizes it as follows:
A bs program is compiled and executed differently from programs written in the other principal Unix programming languages of the time: C, FORTRAN, and assembly language, whose respective commands compile program source code to executable assembler output (a.out
a.out is a file format used in older versions of Unix-like computer operating systems for executables, object code, and, in later systems, shared libraries. This is an abbreviated form of "assembler output", the filename of the output of Ken Th ...
). Instead, a bs program is, first, converted by the bs command to an internal reverse Polish ( RPN) intermediate representation
An intermediate representation (IR) is the data structure or code used internally by a compiler or virtual machine to represent source code. An IR is designed to be conducive to further processing, such as optimization and translation. A "good ...
and then executed by the command's internal virtual stack machine. The bs language, thus, is a hybrid interpreter and compiler
In computing, a compiler is a computer program that translates computer code written in one programming language (the ''source'' language) into another language (the ''target'' language). The name "compiler" is primarily used for programs that ...
and a divergence in Unix
Unix (; trademarked as UNIX) is a family of multitasking, multiuser computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, a ...
programming from Ancient Unix.
The bs language shares some features and syntax with BASIC
BASIC (Beginners' All-purpose Symbolic Instruction Code) is a family of general-purpose, high-level programming languages designed for ease of use. The original version was created by John G. Kemeny and Thomas E. Kurtz at Dartmouth College ...
, SNOBOL
SNOBOL ("StriNg Oriented and symBOlic Language") is a series of programming languages developed between 1962 and 1967 at AT&T Bell Laboratories by David J. Farber, Ralph E. Griswold and Ivan P. Polonsky, culminating in SNOBOL4. It was one of ...
, and C, the two former presumably inspiring its name. Like BASIC, it can be used interactively, either executing statements immediately or collecting them into a program to be executed subsequently. Like in SNOBOL4, the assignment operator (=) is used for I/O and bs can execute code in strings, using its eval
In some programming languages, eval , short for the English evaluate, is a function which evaluates a string as though it were an expression in the language, and returns a result; in others, it executes multiple lines of code as though they ha ...
function. It also includes SNOBOL's interrogation operator (?) used to test whether an expression evaluation succeeds or not. The built-in format function, limited to one argument, supports a subset of C's printf format conversion specifiers, e.g., "%f".
The language has some conspicuous elements. For instance, its program functions are defined using the fun ... nuf syntax and its functions can have local variables. Also, bs can operate in two modes, either interpreting (and executing) statements and programs or compiling them, and switching between the two using compile and stop. Otherwise, its functionality is unique only collectively (in one language), since individual features are redundant with those of coexisting tools, such as the Unix Shell
A Unix shell is a command-line interpreter or shell that provides a command line user interface for Unix-like operating systems. The shell is both an interactive command language and a scripting language, and is used by the operating system t ...
, e.g., file I/O and loops, and AWK, e.g., associative arrays and Regular expression
A regular expression (shortened as regex or regexp; sometimes referred to as rational expression) is a sequence of characters that specifies a search pattern in text. Usually such patterns are used by string-searching algorithms for "find" ...
matching.
The bs language was meant for convenient development and debugging of small, modular programs. It has a collection of syntax and features from prior, popular languages but it is internally compiled, unlike a Shell script
A shell script is a computer program designed to be run by a Unix shell, a command-line interpreter. The various dialects of shell scripts are considered to be scripting languages. Typical operations performed by shell scripts include file manip ...
. As such, in purpose, design, and function, bs is a largely unknown, modest predecessor of hybrid interpreted/compiled languages such as Perl
Perl is a family of two High-level programming language, high-level, General-purpose programming language, general-purpose, Interpreter (computing), interpreted, dynamic programming languages. "Perl" refers to Perl 5, but from 2000 to 2019 it ...
and Python.
Syntax Examples
''The following examples are derived from an A/UX bs(1) man page
A man page (short for manual page) is a form of software documentation usually found on a Unix or Unix-like operating system. Topics covered include computer programs (including library and system calls), formal standards and conventions, and ev ...
.''[
This example uses bs as a calculator:
This example is the outline of a typical bs program:
This example demonstrates I/O:
]
Sample Program
''The following is a sample bs program that emits the words to the song 99 Bottles of Beer
"99 Bottles of Beer" or "100 Bottles of Pop on the Wall" is a song dating to the mid-20th century. It is a traditional reverse counting song in both the United States and Canada. It is popular to sing on road trips, as it has a very repetitive ...
using /usr/bin/bs.'' "Language BS"
''99 Bottles of Beer
"99 Bottles of Beer" or "100 Bottles of Pop on the Wall" is a song dating to the mid-20th century. It is a traditional reverse counting song in both the United States and Canada. It is popular to sing on road trips, as it has a very repetitive ...
'', 8 August 1996. Retrieved on 9 September 2019.
See also
* dc
* bc
References
[
]
[
]
[
]
[
]
[
]
[
]
[
]
[
]
[{{cite magazine , magazine=PC Magazine , date=June 12, 1984
, title=IBM Goes UNIX
, page=218
]
[The /FILES file, A/UX 3.0.1 installation media, Apple Inc. (1993)]
Programming languages
Unix_programming_tools