strash is an interpreted programming language written in Odin that I made for fun. I would not recommend using it for anything serious.
The only data type in strash are strings. These strings are stored in one infinitely recursive hash table. There are operators that operate on the strings, and there are a few builtin functions you can call.
'123' - '456' == '-333'
'123' * '456' == '56088'
'123' / '456' == '0.269737' // ALWAYS 6 decimal places
'123' % '456' == '123''123' != '456' == 'true'
!('true' & 'false') == 'true'
'true' | 'false' == 'true''123' + 'foo' == '' // Operators that are given unexpected inputs return empty stringfoo = '1'
bar = '2'
foo.baz = '3'
foo + bar + foo.baz == '6'foo.bar = 'hi'
baz = 'bar'
foo[baz] == 'hi'foo = 'true'
bar = '123'
foo & (bar = '456') // If statement (uses & short circuit)
bar == '456'i = '0'
$(
// loop code...
i = i + '1'
i < '10' // Last statement is the value of a block. $ repeats block if true
)
i == '10'foo ~ // ~ means all the following indented lines are joined into a string literal
bar = '1'
baz = bar + '2'
^foo // Execute value of foo as code. The variable scope is within foo (bar becomes foo.bar)
foo.bar == '1'
foo.baz == '3'foo ~ bar == '4'
foo.bar = '4' // Parameter
^foo == 'true' // Last statement executed is the return valueTo use a built-in function, you call an empty variable with the same name of the function. For example:
^rand // Returns a random number in the range [0, 1)Built-in functions may also accept arguments:
write_file.path = 'lib.str'
write_file.text = 'foo = "5"'
^write_file // Write a file "lib.str" with the contents: foo = "5"Here is the full list. There's probably a lot more I should add.
| Name | Description |
|---|---|
Prints text to the console. |
|
| read_file | Return the contents of a file at path |
| write_file | Write text to a file at path |
| append | Return a string which is 0, 1, 2... appended together |
| rand | Return a random number in the range [0, 1) |
Here's a recursive factorial implementation in strash:
fact ~ // Set variable "fact" to a multi-line string literal
result = '1'
(num > '0') & ( // If statement (short circuit)
num = num - '1'
result = (num + '1') * ^.fact // Recursive call "fact", located in parent scope
)
result // Return "result"
fact.num = '5' // Set "num" within scope "fact" to a string literal
print.text = ^fact // Call "fact" and store result in "text" within scope "print"
^print // Call "print", which is a built-in function that prints "print.text"Running this code prints 120.000000.
Download the repository and run:
odin run . -- ".\examples\hello_world.str"Tested with Odin version dev-2026-03
