Playground for the Q Language
My dev workflow frequently involve a mixed usage of JavaScript, Python, and R, each offering distinct advantages. Inspired by the book Writing An Interpreter In Go, I was motivated to develop a language that encapsulates the strengths of these three. Thus, the inception of Q.
Q's syntax is a blend of R and JavaScript. Its key features include:
- Simplified variable assignment:
let x = 1
,x = 1
, andx <- 1
are all valid. - Unquoted dictionary keys, so
{"key": value}
becomes{key: value}
. - Use of curly braces
{}
for grouping expressions, instead of indentation. - Defining functions as variable assignments, e.g.,
add = fn (a, b) { a + b }
. - Incorporation of the pipe operator
>
for argument passing in functions.
A noteworthy aspect of Q is its vector
data structure, inspired by R's vector type. Arithmetic
operations on vector
are broadcast across all elements, akin to Python's
numpy.Series
, but without the need for loops.
Q also embraces basic functional programming concepts, allowing functions to be passed as arguments and returned.
The playground is powered by a WebAssembly export of the Go code. You can try out the example code in the right editor panel and click on the run button on the bottom to see the output There is also a terminal panel that acts like a REPL.
While currently a prototype, I welcome any suggestions or contributions via the issue tracker on GitHub.