ArticleslgStudy

science

Occam (programming language)

Occam (programming language) is a 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 Occam (programming language) rather than just read about it. In short: Occam is a programming language which is concurrent and builds on the communicating sequential processes (CSP) process algebra, and shares many of its features. It is named after philosopher William of Ockham, after whom Occam's razor is named.

Occam (programming language) — main illustration
Occam (programming language) — illustration

Key takeaways

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

Reference excerpt

Occam is a programming language which is concurrent and builds on the communicating sequential processes (CSP) process algebra, and shares many of its features. It is named after philosopher William of Ockham, after whom Occam's razor is named. Occam is an imperative procedural language (such as Pascal). It was developed by David May and others at Inmos (trademark INMOS), advised by Tony Hoare, as the native programming language for their transputer microprocessors, but implementations for other platforms are available. The most widely known version is occam 2; its programming manual was written by Steven Ericsson-Zenith and others at Inmos.

Overview In the following examples indentation and formatting are critical for parsing the code: expressions are terminated by the end of the line, lists of expressions need to be on the same level of indentation. This feature, named the off-side rule, is also found in other languages such as Haskell and Python. Communication between processes work through named channels. One process outputs data to a channel via ! while another one inputs data with ?. Input and output cannot proceed until the other end is ready to accept or offer data. (In the not proceeding case it is often said that the process blocks on the channel. However, the program will neither spin nor poll; thus terms like wait, hang or yield may also convey the behaviour; also in the context that it will not block other independent processes from running.) Examples (c is a variable):

keyboard ? c

screen ! c

SEQ (sequential) introduces a list of expressions that are evaluated sequentially. This is not implicit as it is in most other programming languages. Example:

SEQ x := x + 1 y := x * x

PAR (parallel) begins a list of expressions that may be evaluated concurrently. Example:

PAR p() q()

ALT (alternative) specifies a list of guarded commands. The guards are a combination of a Boolean condition and an input expression, both optional. Each guard for which the condition is true and the input channel is ready is successful. One of the successful alternatives is selected for execution. Example:

ALT count1 < 100 & c1 ? data SEQ count1 := count1 + 1 merged ! data count2 < 100 & c2 ? data SEQ count2 := count2 + 1 merged ! data status ? request SEQ out ! count1 out ! count2

This will read data from channels c1 or c2 (whichever is ready) and pass it into a merged channel. If countN reaches 100, reads from the corresponding channel will be disabled. A request on the status channel is answered by outputting the counts to out.

Language revisions

occam 1 occam 1 (released 1983) was a preliminary version of the language which borrowed from David May's work on EPL and Tony Hoare's CSP. This supported only the VAR data type, which was an integral type corresponding to the native word length of the target architecture, and arrays of only one dimension.

occam 2 occam 2 is an extension produced by Inmos Ltd in 1987 that adds floating-point support, functions, multi-dimensional arrays and more data types such as varying sizes of integers (INT16, INT32) and bytes. With this revision, occam became a language able to express useful programs, whereas occam 1 was more suited to examining algorithms and exploring the new language (however, the occam 1 compiler was written in occam 1, so there is an existence proof that reasonably sized, useful programs could be written in occam 1, despite its limits).

occam 2.1 occam 2.1 was the last of the series of occam language developments contributed by Inmos. Defined in 1994, it was influenced by an earlier proposal for an occam 3 language (also referred to as "occam91" during its early development) created by Geoff Barrett at Inmos in the early 1990s. A revised Reference Manual describing occam 3 was distributed for community comment, but the language was never fully implemented in a compiler. occam 2.1 introduced several new features to occam 2, including:

Named data types (DATA TYPE x IS y) Named records Packed records Relaxation of some of the type conversion rules New operators (e.g. BYTESIN) Channel retyping and channel arrays Ability to return fixed-length array from function. For a full list of the changes see Appendix P of the Inmos occam 2.1 Reference Manual.

occam-π occam-π is the common name for the occam variant implemented by later versions of the Kent Retargetable occam Compiler (KRoC). The addition of the symbol π (pi) to the occam name is an allusion to KRoC occam including several ideas inspired by the π-calculus. It contains several significant extensions to the occam 2.1 compiler, for example:

Nested protocols Run-time process creation Mobile channels, data, and processes Recursion Protocol inheritance Array constructors Extended rendezvous

See also Concurrent programming languages List of concurrent and parallel programming languages

References

Further reading Communicating Process Architectures 2007 – WoTUG-30. IOS Press. 2007. pp. 513 pages. ISBN 978-1-58603-767-3. [1] Communicating Process Architectures 2006 – WoTUG-29. IOS Press. 2006. pp. 391 pages. ISBN 978-1-58603-671-3. [2] Communicating Process Architectures 2005 – WoTUG-28. IOS Press. 2005. pp. 405 pages. ISBN 978-1-58603-561-7. [3] Kerridge, Jon, ed. (1993). Transputer and Occam Research: New Directions. IOS Press. pp. 253 pages. ISBN 0-8247-0711-7. Roscoe, Andrew William; Hoare, Charles Antony Richard (1986). The Laws of Occam Programming. Programming Research Group, Oxford University. Egorov, A., Technical University – Sofia, (1983–2011) Записки по Компютърни архитектури

External links Information, compilers, editors and utilities at the WoTUG occam pages Compilers, documentation, examples, projects and utilities at the Internet Parallel Computing Archive (no longer maintained) Occam books on Transputer.net The occam-pi language. Tock occam compiler – (translator from occam to C from Kent) a Haskell-based compiler for occam and related languages.

Illustrations

Occam (programming language) illustration
Occam (programming language): 1983 "occam" by INMOS Limited
1983 "occam" by INMOS Limited

Worked examples

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

Start with the simplest possible case. Write down what Occam (programming language) claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In 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 Occam (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 Occam (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 Occam (programming language)

In research
Occam (programming language) appears in 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 Occam (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
Occam (programming language) is common in secondary-school and first-year university syllabi. It links to neighbouring topics Concurrent programming languages, Procedural programming languages, Programming languages created in 1983, so understanding it makes those chapters shorter.
In everyday life
Look for Occam (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.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Occam (programming language)” →

How to study Occam (programming language) in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Occam (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 Occam (programming language) out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Occam (programming language) in simple terms?

Occam is a programming language which is concurrent and builds on the communicating sequential processes (CSP) process algebra, and shares many of its features. It is named after philosopher William of Ockham, after whom Occam's razor is named.

Why does Occam (programming language) matter?

Because it connects several 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 Occam (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 Occam (programming language).

Tags

  • Concurrent programming languages
  • Procedural programming languages
  • Programming languages created in 1983

Keep exploring