ArticleslgStudy

computer science

Hoc (programming language)

Hoc (programming language) is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Hoc (programming language) rather than just read about it. In short: 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).

Key takeaways

  • Hoc (programming language) belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Hoc (programming language) to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Hoc (programming language) from memory before moving on to harder problems.

Reference excerpt

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.

Examples The following is a simple example of an interactive calculator session in hoc; highlighted text represents hoc's output:

And a simple example of functions and flow control:

References Kernighan, Brian W.; Pike, Rob (1984). The Unix Programming Environment. Prentice Hall. ISBN 0-13-937681-X.

External links hoc(1) – Plan 9 Programmer's Manual, Volume 1

hoc implementations and versions AT&T versions: The original code from the Unix Programming Environment book, including hoc. Source code of hoc from Bell Labs, released as free software. This is the Research Unix version, slightly improved over the one in the book. Plan9 version of hoc released under the MIT License. This version is slightly different from the Research Unix version, with the most notable difference being that numbered function arguments ($1, $2, etc., as in the Unix shell) were replaced by named arguments (as in C). See also Plan 9's hoc manual. Other versions: an extended version of hoc by Nelson H. F. Beebe. an extended version of hoc by Nadav Y. Har'El. an extended version of hoc by Jack Dennon. an extended version of hoc by Michael Hines, John W. Moore, and Ted Carnevale.

Worked examples

Example 1 — a first encounter with Hoc (programming language)

Start with the simplest possible case. Write down what Hoc (programming language) claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Hoc (programming language) before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Hoc (programming language) ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Hoc (programming language)

In research
Hoc (programming language) appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Hoc (programming language) in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Hoc (programming language) is common in secondary-school and first-year university syllabi. It links to neighbouring topics Free mathematics software, Numerical programming languages, Plan 9 commands, so understanding it makes those chapters shorter.
In everyday life
Look for Hoc (programming language) outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study Hoc (programming language) in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Hoc (programming language) means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Hoc (programming language) out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Hoc (programming language) in simple terms?

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 f…

Why does Hoc (programming language) matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Hoc (programming language)?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Hoc (programming language).

Tags

  • Free mathematics software
  • Numerical programming languages
  • Plan 9 commands
  • Software calculators
  • Unix programming tools

Keep exploring