Dissection of Hello World in Operon

Hello World is a classic first application that is written when learning new language. Here's the Hello World in Operon:

Let's go through this line by line:

  1. The query starts with the dollar-sign "$", which tells that we are assigning an input for the query. The input will become root-value, which can be refered with $ in the Select-statement.

    After $ comes the input-source, which first in our examples is most of the time "json". You might be familiar with JSON already, but if you are not, then don't worry, you will learn it fast by going through the examples. Here we say that the input is a JSON-string, which has the value "Hello world!".

    Assigning an input ($) is optional, so we may skip it. When omitted, the root-value will be an empty-value.

  2. Each query must have the Select-statement. Here we have again the dollar-symbol ($) after our Select-keyword, which means that we want to select root value, which was the value assigned by our input-source, in this case a JSON-string "Hello world!".

  3. Finally we have the line which starts with hashtag-symbol, followed by the greater-than -symbol. Everything followed by the hashtag-symbol means that it is a comment. This is how we denote the query's output while going through examples.

There's more than one way to do it

The above example is the verbose way to write the Hello World, but there are other ways to achieve this. Let's see a few alternatives.

Example

This is the form that we normally would use when working with Operon.

Example

We can of course just select what we want because there's no need for input in this example.

Example

This is like previous, but shorter form.

Example

We can also select the value with `-quotes. In this case the output is not a JSON-string, but a sequence of bytes.

Where to go next?

Check out next Operon 1-2-3 - first steps to learn Operon!


Operon-license