This page focuses on simplicity—one of the key attributes of TOO that makes it viable for citizens.
Always remember, however, that there’s usually a simpler and better way to do something than the first way that pops into your head.
Donald Knuth Tweet
A typical general-purpose programming language (GPL) comprises around 150 syntax rules, 30 operators, and 40 keywords. In contrast, TOO is minimalistic relative to a common GPL. Refer to the following table for a comparison.
Language | Keywords | Operators | Syntax rules | Year |
---|---|---|---|---|
Fortran | 39 | 16 | 170 | 1957 |
C | 32 | 27 | 100 | 1970 |
C++ | 90 | 35 | 200 | 1979 |
Python | 33 | 39 | 90 | 1991 |
Java | 51 | 34 | 250 | 1995 |
Ruby | 13 | 28 | 60 | 1995 |
C# | 78 | 41 | 220 | 2000 |
Go | 25 | 34 | 100 | 2009 |
Typescript | 50 | 35 | 150 | 2012 |
Rust | 35 | 45 | 250 | 2015 |
TOO | 0 | 5 | 10 | 2022 |
thing ::= Id “{” {decl|event|when|func}* “}”
event ::= Id params
when ::= {Idsrc [“[” decl “]”]}+ Idsignal params “{” {act}* “}”
func ::= Id paramsin “→” paramsout [“{” {act}* “}”]body
act ::= [“*”]iter expr [“?” “{” {actT}* “}” [“{” {actF}* “}”]]
expr ::= ((Const|ref|call) [“→” (decl|params)]redirect)+
ref ::= Id [“[” (expr|“*”) “]”]index
call ::= Id “(” [{expr|“*”}*“,”]args “)”
params ::= “(” [{decl}+“,” […]variadic “)”
decl ::= [“[]”]array [Idalias “:”] {Id}+ [“=” Const] [Constimport]
In most instances, users will utilize a reference object followed by a call. For example, switch turn·it·on. Nevertheless, the syntax supports the creation of much more complex expressions. The examples provided illustrate some of the unique features of the TOO language, highlighting its expressive power despite being a micro language. Let’s break down each example to understand the concepts they demonstrate.
Example 1: Redirect Operator (→)
radius squared times math π → area times height → cylinder
Explanation:
The redirect operator (→) is used to assign the byproduct(s) of a sub-expression to a temporary variable(s). These temporary variables can be used later in the code, allowing for clear and concise expressions. The expression is intuitive, close to a spoken language, and can be read as: “radius squared times pi goes to area, times height goes to cylinder”.
Example 2: Star Operator (*)
go run(simulator, car[*] plate)
Explanation:
The star operator (*) acts as a wildcard, effectively creating a loop that iterates over the array members. The “go run” function spawns a lightweight thread for each element in the array, with each thread handling one car’s license plate.
Summary:
These features, although simple, provide powerful ways to express complex computations and concurrent operations succinctly.
Simplicity is the ultimate sophistication. It takes a lot of hard work to make something simple, to truly understand the underlying challenges and come up with elegant solutions. [...] It's not just minimalism or the absence of clutter. It involves digging through the depth of complexity. To be truly simple, you have to go really deep. [...] You have to deeply understand the essence of a product in order to be able to get rid of the parts that are not essential.
Steve Jobs Tweet
.
.