We have just created a full Hyperlambda course, where the objective is to bring you up to a full understanding of Hyperlambda in one day. The course is given as a series of YouTube videos, where I show some aspect of Hyperlambda, allowing you to repeat what I am doing, and solve exercises as we proceed. The course starts out with the hello world Hyperlambda app, but rapidly proceeds to complex subjects such as how to create code that maintains code and multi threaded programming. You can find the entire Hyperlambda course here.
Index
- Session 1 – Hello World, Hyperlambda syntax, and the evaluator
- Session 2 – How the Machine Creates the Code
- Session 3 – Changing your tree with expressions and slots
- Session 4 – Dynamic slots and executing Hyperlambda files
- Session 5 – Multi Threaded Programming Constructs
- Session 6 – The Angular LowCode CRUD generator
- Session 7 – Authentication, Authorisation, JWT and RBAC
- Session 8 – Analysing the CRUD generator’s output
- Session 9 – Create a custom Authentication endpoint
- Session 10 – Creating a Custom Authentication Endpoint
- Session 11 – The [unwrap] slot
- Session 12 – Create a CRM Exercise
- Session 13 – Implementing a CRM System
- Session 14 – Create a Task Management System
- Session 15 – Creating a Task Management System
- Session 16 – What can you use Hyperlambda for?
- Session 17 – Record Slicing in Hyperlambda
- Session 18 – Database and SQL slots
- Session 19 – Branching and Looping
- Session 20 – When the Machine Speaks with the Machine
- Session 21 – Web Sockets in Hyperlambda
- Session 22 – Create a Chat Client
- Session 23 – Automatically Generated Unit Tests
- Session 24 – Create a web API with SQL
- Session 25 – Interceptors
Hyperlambda code
Below you can find some of the snippets and HTTP endpoints I am creating during the course. To understand what they do, please watch the above video course, and refer back to the relevant snippet when I’m using it in the course.
tutorial-01-01
.foo
foo1:bar1
foo2:bar2
foo3:bar3
.foo2
foo4:bar4
foo5:bar5
.dest
for-each:x:@.foo/*
add:x:@.dest
get-nodes:x:@.dp/#
tutorial-02-01
.lambda
http.get:"https://microsoft.com"
if
eq:x:@http.get
.:int:200
.lambda
log.info:Microsoft.com seems to be fine!
else
log.error:Microsoft.com is NOT OK!!
lambda2hyper:x:@.lambda/*
data.connect:code
data.create
table:snippets
values
content:x:@lambda2hyper
tutorial-02-02
.lambda
data.connect:code
data.read
table:snippets
columns
content
limit:-1
for-each:x:@data.read/*/*
add:x:@.lambda
hyper2lambda:x:@.dp/#
eval:x:@.lambda
tutorial-02-03
/*
* Script that formats all Hyperlambda files recursively within
* the specified folder.
*/
.folder:/modules/northwind/
io.file.list-recursively:x:-
for-each:x:-/*
if
strings.ends-with:x:@.dp/#
.:.hl
.lambda
io.file.load:x:@.dp/#
hyper2lambda:x:-
comments:true
remove-nodes:x:@hyper2lambda/*/auth.ticket.verify
lambda2hyper:x:@hyper2lambda/*
comments:true
io.file.save:x:@.dp/#
get-value:x:@lambda2hyper
tutorial-02-04
/*
* Script that formats all Hyperlambda files recursively within
* the specified folder.
*/
.folder:/modules/northwind/
io.file.list-recursively:x:-
for-each:x:-/*
if
strings.ends-with:x:@.dp/#
.:.hl
.lambda
io.file.load:x:@.dp/#
hyper2lambda:x:-
comments:true
insert-before:x:@hyper2lambda/*/data.connect
.
auth.ticket.verify:admin, root, guest, foo-bar
lambda2hyper:x:@hyper2lambda/*
comments:true
io.file.save:x:@.dp/#
get-value:x:@lambda2hyper
tutorial-04-01
slots.create:foo
math.add:x:@.arguments/0
get-value:x:@.arguments/1
return:x:-
tutorial-04-02
slots.create:foo
math.add:x:@.arguments/0
get-value:x:@.arguments/1
tutorial-05-01
/*
* Creates 4 fire and forget threads.
*/
fork
http.get:"https://aista.com"
fork
http.get:"http://microsoft.com"
fork
http.get:"https://google.com"
fork
http.get:"https://dzone.com"
/*
* Creates 4 threads and waits for all threads to return
* before it proceeds.
*/
join
fork
http.get:"https://aista.com"
fork
http.get:"http://microsoft.com"
fork
http.get:"https://google.com"
fork
http.get:"https://dzone.com"
/*
* Creates 4 sequentially invoked HTTP GET invocations.
*/
http.get:"https://aista.com"
http.get:"http://microsoft.com"
http.get:"https://google.com"
http.get:"https://dzone.com"
tutorial-05-02
// Thread number 1, loads a file, concatenates to it, and saves the file again.
fork
.lambda1
semaphore:semaphore-thread
io.file.load:/foo.txt
strings.concat
get-value:x:@io.file.load
.:"Appended by lambda object 1\r\n"
io.file.save:/foo.txt
get-value:x:@strings.concat
eval:x:@.lambda1
// Thread number 2, loads a file, concatenates to it, and saves the file again.
fork
.lambda2
semaphore:semaphore-thread
io.file.load:/foo.txt
strings.concat
get-value:x:@io.file.load
.:"Appended by lambda object 2\r\n"
io.file.save:/foo.txt
get-value:x:@strings.concat
eval:x:@.lambda2
HTTP endpoints
Below you can find the Hyperlambda HTTP endpoints I am creating during the course.
tutorial01.get.hl
.arguments
name:string
age:int
strings.concat
.:"Hello there "
get-value:x:@.arguments/*/name
.:", you are "
get-value:x:@.arguments/*/age
.:" years old"
unwrap:x:+/*
return
result:x:@strings.concat
tutorial02.get.hl
.foo
foo1:bar1
foo2:bar2
foo3:bar3
.foo2
foo4:bar4
foo5:bar5
.dest
for-each:x:@.foo/*
add:x:@.dest
get-nodes:x:@.dp/#
lambda2hyper:x:../*
log.info:x:-
return:x:@.dest/*
tutorial03.get.hl
/*
* Example of how to secure your API endpoint using JWT and
* the internals of Hyperlambda's JWT token slots.
*/
// Throws an exception unless user belongs to root or admin role.
auth.ticket.verify:root, admin
return
result:Hello World from a secure endpoint
tutorial04.get.hl
.data
foo1:bar1
foo2:bar2
unwrap:x:+/*
return
value1:x:@.data/*/foo1
value2:x:@.data/*/foo2
tutorial05.get.hl
.arguments
name:string
if
eq:x:@.arguments/*/name
.:Thomas
.lambda
return
result:Hi boss!
else-if
eq:x:@.arguments/*/name
.:John
.lambda
return
result:Hi John!
else
return
result:Hi stranger!
tutorial06.post.hl
/*
* Allows the caller to (securely) pass in Hyperlambda to
* our endpoint and execute it, allowing the caller to
* specify the logic to execute, and what data to return.
*/
.arguments
body:*
.accept:application/hyperlambda
// Loading Hyperlambda from [body] argument.
io.stream.read:x:@.arguments/*/body
// Ensuring we return raw Hyperlambda to caller.
response.headers.set
Content-Type:application/hyperlambda
// Transforming to Hyperlambda and adding lambda into [.lambda] object.
add:x:+/*/.lambda
hyper2lambda:x:@io.stream.read
// [whitelist] invocation preventing malicious slots from being executed.
whitelist
// Slots caller is allowed to invoke.
vocabulary
add
insert-before
insert-after
set-value
set-name
vocabulary
slots.vocabulary
for-each
while
if
else-if
else
strings.concat
return
return-nodes
unwrap
.lambda
// Returning lambda object to caller.
lambda2hyper:x:@whitelist/*
return:x:-
interceptor.hl
data.connect:crm
.interceptor
foo.get.hl
data.select:select * from status
return:x:-/*
Top comments (0)