Technology

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.

Simplified syntax

TOO is tiny and simple

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.

LanguageKeywordsOperatorsSyntax rulesYear
Fortran39161701957
C32271001970
C++90352001979
Python3339901991
Java51342501995
Ruby1328601995
C#78412202000
Go25341002009
Typescript50351502012
Rust35452502015
TOO05102022

TOO 10 syntax rules

A carefully designed language with just 10 syntax rules can be remarkably powerful

thing ::= Id { {decl|event|when|func}* “}

event ::= Id params

when ::= {Idsrc [“[ decl ]”]}+ Idsignal params { {act}* }

func ::= Id paramsinparamsout [“{” {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]

Expressiveness

 

 

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 first part of the expression calculates the area of a circle (radius^2 * π) and stores the result in a temporary number thing called “area”.
  • The second part then multiplies this area by the height to compute the volume of a cylinder and stores this result in another temporary variable called “cylinder”.

 

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 (*) is used here to denote all elements in the “car” array, saving the need a “for” or “while” statement.
  • The entire expression initiates go-routines for each car in the “car” array, passing the license plate of each car as an argument to the “start” function of the simulator thing.

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:

  • Redirect Operator (→): Assigns the result of an expression to a temporary variable for later use. It allows for chaining computations in a readable manner.
  • Star Operator (*): Acts as a wildcard for arrays, enabling operations to be performed on each element of the array.

 

These features, although simple, provide powerful ways to express complex computations and concurrent operations succinctly.

What's NOT in TOO

  • No flow-control statements (such as for, while, foreach, etc.).
  • No basic types (such as int, char, int64, etc.).
  • No variable declarations (such as var, let, etc.).
  • No binary operators, e.g., a + b. TOO uses fluent style chaining instead, e.g., a plus (b).
  • No global objects that could be referenced anywhere.
  • No pointers.

What's in TOO

  • Fully object oriented – Every thing is just a thing, built from its member things. Things can be anything: gmail, string, sensor, boolean, number, twitter, sms, spreadsheet… anything…
  • Rule-based – the logic is structured in rules; each has a trigger and actions. This concept greatly simplifies the logic for novice developers (and also for professionals) since it is loop-free.
  • Functional language – functions in TOO may return multiple values, may take a variable number of arguments (variadic functions), and may be anonymous (lambda functions).
  • Maps replacing arrays – this means that elements are referenced by named subscripts rather than sequential numbers 0,1,… The extra information in the indices enriches the application. For example, the call to voice caller talk(phone[*], “hi “,*, “, hello world!”) would generate a voice call with the following message to all phone elements. For example, “hi Bob, hello world!”, and “hi Alice, hello world!”; where Bob, Alice, … are the indices of phone array.
  • Automatic memory allocation – maps also necessitates operators New since the elements of a map could be allocated automatically when referenced (they are deleted by garbage collection).
  • Concurrency based on light-weight threads and channels – adopted from Go language.
  • Interfaces and inheritance – adopted from Go language.

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.


.

.