bs is a programming language and a compiler/interpreter for modest-sized programs on
UNIX
Unix (, ; trademarked as UNIX) is a family of multitasking, multi-user 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_interface#Command-line_interpreter, command-line interpreter or shell (computing), shell that provides a command line user interface for Unix-like operating systems. The shell is both an interactive command languag ...
, e.g., using a Shebang (Unix) #!/usr/bin/bs.
An early man page states, " bs">kbd>bsis a remote descendant of Basic
Basic or BASIC may refer to:
Science and technology
* BASIC, a computer programming language
* Basic (chemistry), having the properties of a base
* Basic access authentication, in HTTP
Entertainment
* Basic (film), ''Basic'' (film), a 2003 film
...
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, commonly referred to as ''Bell Labs'', is an American industrial research and development company owned by Finnish technology company Nokia. With headquarters located in Murray Hill, New Jersey, Murray Hill, New Jersey, the compa ...
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, 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
Research Unix refers to the 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). The term ''Research Unix'' first app ...
nor the Berkeley Software Distribution
The Berkeley Software Distribution (BSD), also known as Berkeley Unix or BSD Unix, is a discontinued Unix operating system developed and distributed by the Computer Systems Research Group (CSRG) at the University of California, Berkeley, beginn ...
.
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 Releases 2 & 3: SVR2,][ SVR3, SVR3.2 (1986);][ ]HP-UX
HP-UX (from "Hewlett Packard Unix") is a proprietary software, proprietary implementation of the Unix operating system developed by Hewlett Packard Enterprise; current versions support HPE Integrity Servers, based on Intel's Itanium architect ...
;[ AIX;][ and A/UX.][
(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 the shell commands of the most recent version of the Portable Operating System Interface (POSIX) IEEE Std 1003.1-2024 which is part of the Single UNIX Specification (SUS). These commands are implemented in many shells on moder ...
) nor in the Single UNIX Specification
The Single UNIX Specification (SUS) is a standard for computer operating systems, compliance with which is required to qualify for using the "UNIX" trademark. The standard specifies programming interfaces for the C language, a command-line shell, ...
and is not provided with most contemporary operating systems. For example in Linux
Linux ( ) is a family of open source Unix-like operating systems based on the Linux kernel, an kernel (operating system), operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically package manager, pac ...
, similar syntax and functionality is provided by bc, Perl
Perl is a high-level, general-purpose, interpreted, dynamic programming language. Though Perl is not officially an acronym, there are various backronyms in use, including "Practical Extraction and Reporting Language".
Perl was developed ...
, and POSIX shell.
In the 21st century, bs is present in, at least, HP-UX
HP-UX (from "Hewlett Packard Unix") is a proprietary software, proprietary implementation of the Unix operating system developed by Hewlett Packard Enterprise; current versions support HPE Integrity Servers, based on Intel's Itanium architect ...
Release 11i (2000),[ as well as AIX versions 6.1 (2007)][ and 7.2 (2018),][ likely due to their UNIX System V heritage.
]
Design and features
The bs[ man page, 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
In computing, assembly language (alternatively assembler language or symbolic machine code), often referred to simply as assembly and commonly abbreviated as ASM or asm, is any low-level programming language with a very strong correspondence bet ...
, whose respective commands compile program source code to executable assembler output ( a.out). 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
In computer science, computer engineering and programming language implementations, a stack machine is a computer processor or a Virtual machine#Process virtual machines, process virtual machine in which the primary interaction is moving short- ...
. The bs language, thus, is a hybrid interpreter and compiler
In computing, a compiler is a computer program that Translator (computing), translates computer code written in one programming language (the ''source'' language) into another language (the ''target'' language). The name "compiler" is primaril ...
and a divergence in Unix
Unix (, ; trademarked as UNIX) is a family of multitasking, multi-user 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 or BASIC may refer to:
Science and technology
* BASIC, a computer programming language
* Basic (chemistry), having the properties of a base
* Basic access authentication, in HTTP
Entertainment
* Basic (film), ''Basic'' (film), a 2003 film
...
, 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 Griswold and Ivan P. Polonsky, culminating in SNOBOL4. It was one of a ...
, 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 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_interface#Command-line_interpreter, command-line interpreter or shell (computing), shell that provides a command line user interface for Unix-like operating systems. The shell is both an interactive command languag ...
, 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 match 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 command languages. Typical operations performed by shell scripts include file manipu ...
. 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 high-level, general-purpose, interpreted, dynamic programming language. Though Perl is not officially an acronym, there are various backronyms in use, including "Practical Extraction and Reporting Language".
Perl was developed ...
and Python.
Syntax Examples
''The following examples are derived from an A/UX bs(1) man page.''[
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 using /usr/bin/bs.'' "Language BS"
'' 99 Bottles of Beer'', 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