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).
10
Upvotes
View all comments
Show parent comment
3
u/sphen_lee 19h ago
A table is logically equivalent to a list of records with the same fields? I assume you can store it more efficiently (maybe columnar?)
In terms of syntax, it probably needs separators between columns. Like
||for the column names and then|between each column. Otherwise it could get hard to read if the values are not literals.(It's also nice to include a non-indentation variant. Like JSON? Some people prefer it, but it's also easier for code generators)