r/ProgrammingLanguages • u/terryio • 20h ago
Kiki Lang - query, markup, coding
I have been working on this for a while, and would like to share and get some feedback.
It started as a query language, then grows to add markup features, to be useful for building interactive data apps.
Below is a sample Kiki program. The idea of mixing markup and coding, is in the same category of LaTex or Typst, but Kiki focus more on data/query, and uses a different syntax design.
# Kiki Lang
Kiki is literal, meaning that the program is a prose. Lines start with "> " or inline \(12 + 34) are code blocks.
The two \(bold ~ core ideas) are:
- Lisp like syntax, which is nice across query, markup and coding.
- Algebric effect, which is used for errors, I/O, optionals, and state.
Here are the collections: list, record, and table.
> names = ["alice" "bob"]
> alice = {name = "alice" age = 20}
> users = |name age|
alice 20
bob 30
"=>" is a form of inline unit test:
> type-of names => :[string]
> type-of alice => :{name = string age = int}
> type-of users => :|name = string age = int|
Query is an important part of the language:
> users |> filter age >= 18
|> select name
Here is a function with pattern matching:
> fib = fn 0 -> 1
fn 1 -> 1
fn n -> fib (n - 1) + fib (n - 2)
And it can be called inline as \(fib 10).
9
Upvotes
View all comments
Show parent comment
4
u/terryio 20h ago
Well table is the most important part of kiki since it is to handle spreadsheet like data. Record is less important and only useful for writing certain functions. That syntax is layout (indent) aware. Any better idea for table syntax?