Hyperlamda 101: Basics of Hyperlambda
Hyperlambda is not technically a programming language but a high quality abstraction of C#.
I will be taking you through the basics of hyperlambda in this article;
Outline
- Introduction.
- The Structure of Hyperlambda
- Nodes
- Expressions?
Introduction
The brainbox behind Hyperlambda is to have a programming language where you write the least amount of code. Hyperlambda is very easy to learn and you can go through its basics in less than 10 minutes. This article will give you an introduction to Hyperlambda from a bird’s eye view.
The Structure of Hyperlambda
When it comes to its syntax , Hyperlambda looks like YAML, however, it has its own unique kind of syntax, and even though it has the same readability traits as YAML, it is not the same. In theory, we could have used YAML, JSON, or XML to create Hyperlambda, but that would increase its verbosity, resulting in more difficult-to-read code. However, its structure is easily understood in 5 minutes, since it is literally just a text representation of a tree structure. Hyperlambda’s structure is based upon “nodes”, and each node has 3 properties.
- Name
- Value
- Children
To illustrate imagine the following Hyperlambda.
.data
foo1:bar1
foo2:bar2The above Hyperlambda consists of 3 nodes. The first node is called [.data]. This node has two children called [foo1] and [foo2]. Both of these nodes have a value each being “bar1” and “bar2”. The colon separates the node’s name and its value, and 3 spaces opens up the children collection. To play around with Hyperlambda you can use Magic’s “Evaluator” component.
Watch the video below to get more clarity
Nodes
To declare a node being a variable”. The “.” Is what allows us to declares variables. You can create nodes without the “.”, but they will be attempted invoked as slots (functions), unless their names starts with a “.”
Get barnascript’s stories in your inbox
Join Medium for free to get updates from this writer.
.foo:howdy world
is the same as
.foo:string:howdy world
because the default type of a node is a string
You can provide additional declarations of type of int and decimals like the ones below.
.foo:int:57 or .foo:decimal:45.67
Hyperlambada has a tree structure
What I am doing here is declaring a graph of tree object
Hyperlambda is not a key value collection like json, it is an name-value collection
Expression
Hyperlambda doesn’t have “variables”. This is because everything is a variable in Hyperlambda, including functions and arguments.
This creates a problem for us, being that we need to modify node names, node values, and their children collection. This is where expressions comes into the picture. An expression allows us to reference any node in our Hyperlambda object. An example of such an expression can be seen in the above screenshot where our invocation to [set-value] has the value of :x:@.dp. Its :x: part declares it as an expression type, while the @.dp part is the actual expression.
The x symbol simply means that “@.data/*” is an expression.
The @ means “find the first node in the hierarchy whose identity = .data”
The * symbol means “return all children from the node — .data” — in this case — bar1, bar2 and bar3
The .dp symbol refers to“every data point in the expression”
The # symbol means “take the value(s) in the expression and transform it(them) into a node”.
The @.dp/# allow us to transform the values in the expression
Note that this transformation happens by reference.







