Original author(s) | Brian Kernighan, Rob Pike (AT&T Bell Laboratories) |
---|---|
Initial release | 1984 |
Repository | |
Written in | C |
Operating system | Unix, Plan 9 |
Platform | Cross-platform |
Type | Programming language, Command |
License | Plan 9: MIT License |
hoc, an acronym for High Order Calculator, is an interpreted programming language that was used in the 1984 book The Unix Programming Environment to demonstrate how to build interpreters using Yacc.
hoc was developed by Brian Kernighan and Rob Pike as a glorified interactive calculator. Its basic functionality is to evaluate floating-point numerical expressions, e.g., 1+2*sin(0.7)
. Then, variables were added, conditionals, loops, user-defined functions, simple IO, and more, using a syntax resembling C.
An improved hoc interpreter was included in Eighth Edition Research Unix in 1985, but it has not been generally adopted by commercial Unix systems or by Linux distributions. Instead, the earlier calculator languages dc and bc have become widespread on those systems. hoc survived and continued to evolve as part of the Plan 9 operating system. Several improved versions of hoc were released as free software by Bell Labs and other individuals (see list below). hoc is used, alongside python, as a scripting language for the Neuron simulator.
The following is a simple example of an interactive calculator session in hoc; highlighted text represents hoc's output:
1+2*37 angle=PI/3 r=sin(angle) r 0.866025 r*21.73205
And a simple example of functions and flow control:
func atan2(){if($1>0){return atan($2/$1)}elseif($1<0){return atan($2/$1)+PI }elseif($2>0){return PI/2}elseif($2<0){return-PI/2}else{print"atan2 domain error"return0}} atan2(2,3)0.982794 atan2(0,0) atan2 domain error 0.0
AWK is a domain-specific language designed for text processing and typically used as a data extraction and reporting tool. Like sed and grep, it is a filter, and is a standard feature of most Unix-like operating systems.
Brian Wilson Kernighan is a Canadian computer scientist. He worked at Bell Labs and contributed to the development of Unix alongside Unix creators Ken Thompson and Dennis Ritchie. Kernighan's name became widely known through co-authorship of the first book on the C programming language with Dennis Ritchie. Kernighan affirmed that he had no part in the design of the C language.
C is a general-purpose programming language. It was created in the 1970s by Dennis Ritchie and remains very widely used and influential. By design, C's features cleanly reflect the capabilities of the targeted CPUs. It has found lasting use in operating systems code, device drivers, and protocol stacks, but its use in application software has been decreasing. C is commonly used on computer architectures that range from the largest supercomputers to the smallest microcontrollers and embedded systems.
Dennis MacAlistair Ritchie was an American computer scientist. He created the C programming language and, with long-time colleague Ken Thompson, the Unix operating system and B language. Ritchie and Thompson were awarded the Turing Award from the Association for Computing Machinery (ACM) in 1983, the IEEE Richard W. Hamming Medal from the Institute of Electrical and Electronics Engineers (IEEE) in 1990, and the National Medal of Technology from President Bill Clinton in 1999.
Pascal is an imperative and procedural programming language, designed by Niklaus Wirth as a small, efficient language intended to encourage good programming practices using structured programming and data structuring. It is named after French mathematician, philosopher and physicist Blaise Pascal.
troff, short for "typesetter roff", is the major component of a document processing system developed by Bell Labs for the Unix operating system. troff and the related nroff were both developed from the original roff.
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 to control the execution of the system using shell scripts.
The Bourne shell (sh
) is a shell command-line interpreter for computer operating systems.
GNU Units is a cross-platform computer program for conversion of units of quantities. It has a database of measurement units, including esoteric and historical units. This for instance allows conversion of velocities specified in furlongs per fortnight, and pressures specified in tons per acre. Output units are checked for consistency with the input, allowing verification of conversion of complex expressions.
The Unix philosophy, originated by Ken Thompson, is a set of cultural norms and philosophical approaches to minimalist, modular software development. It is based on the experience of leading developers of the Unix operating system. Early Unix developers were important in bringing the concepts of modularity and reusability into software engineering practice, spawning a "software tools" movement. Over time, the leading developers of Unix established a set of cultural norms for developing software; these norms became as important and influential as the technology of Unix itself, and have been termed the "Unix philosophy."
Sam is a multi-file text editor based on structural regular expressions. It was originally designed in the early 1980s at Bell Labs by Rob Pike with the help of Ken Thompson and other Unix developers for the Blit windowing terminal running on Unix; it was later ported to other systems. Sam follows a classical modular Unix aesthetic. It is internally simple, its power leveraged by the composability of a small command language and extensibility through shell integration.
dc is a cross-platform reverse-Polish calculator which supports arbitrary-precision arithmetic. It was written by Lorinda Cherry and Robert Morris at Bell Labs. It is one of the oldest Unix utilities, preceding even the invention of the C programming language. Like other utilities of that vintage, it has a powerful set of features but terse syntax. Traditionally, the bc calculator program was implemented on top of dc.
bc, for basic calculator, is "an arbitrary-precision calculator language" with syntax similar to the C programming language. bc is typically used as either a mathematical scripting language or as an interactive mathematical shell.
Part of the troff suite of Unix document layout tools, eqn is a preprocessor that formats equations for printing. A similar program, neqn, accepted the same input as eqn, but produced output tuned to look better in nroff. The eqn program was created in 1974 by Brian Kernighan and Lorinda Cherry. It was implemented using yacc compiler-compiler.
The Unix Programming Environment, first published in 1984 by Prentice Hall, is a book written by Brian W. Kernighan and Rob Pike, both of Bell Labs and considered an important and early document of the Unix operating system.
In computing and mathematics, the function atan2 is the 2-argument arctangent. By definition, is the angle measure between the positive -axis and the ray from the origin to the point in the Cartesian plane. Equivalently, is the argument of the complex number
In mathematics (particularly in complex analysis), the argument of a complex number z, denoted arg(z), is the angle between the positive real axis and the line joining the origin and z, represented as a point in the complex plane, shown as in Figure 1. By convention the positive real axis is drawn pointing rightward, the positive imaginary axis is drawn pointing upward, and complex numbers with positive real part are considered to have an anticlockwise argument with positive sign.
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, and others.
A command-line interface (CLI) is a means of interacting with a computer program by inputting lines of text called command-lines. Command-line interfaces emerged in the mid-1960s, on computer terminals, as an interactive and more user-friendly alternative to the non-interactive interface available with punched cards.