Stack-Based, concatenative, programming language. Built for school science fair not intended for real use in any capacity. Inspired from the Porth language written by Tsoding.
- refactor (readability, errors and structure)
- [] general heap allocations
- move the ("putc", "puti", "puts", ...) commands into a standard library
- add some syntax sugar for function parameters
- improve CLI (file output name / directory location)
- compile negative numbers (seems to work off rip)
- simple macro system
- [] faster interpreter
- [] better program error checker compile side
- [] speed optimize compiler
- web based visualization tool / debugger (not great but good enough for science fair presentation purposes.)
First you need a working Odin compiler follow the instructions on the Odin Website. Then clone the repository and run the build script to obtain the Junk compiler and the Jounce interpreter. The language tools currently support Linux however it should work on Windows & Mac as well.
Run junk <mode> <filename> <output path> to compile a source file.
Run jounce <filename> to run a compiled source file.
@import stdlib/std @end
fn main is
"Hello, World!" @puts
end
The Jounce language uses reverse polish notation meaning the operator comes after the operands ex:
2 3 + -> adds 2 and 3
Comparison works the same as arithmetic
a b == -> checks if a is equal to b
In Jounce everything on the stack is a number.
trueorfalse-> pushes a 1 for true and 0 for false onto the stack'a'-> pushes ascii value of character onto the stack123-> pushes the number literal onto the stack"string"-> pushes the pointer to the start of the string and the length onto the stack
if a b == do ... endif a b == do ... else b c == do ... else ... end
while a b > do ... end
loops support break but do not currently support continue.
@macro my_macro ... @end
To use the macro simply put @my_macro wherever you would like.
macros happen at the token level so if statements, variables and all the like is supported.
macros also support the @macro my_macro of a b is ... @end syntax in this context the is keyword is required.
fn my_func is ... end
In Jounce to return before the end of a function use the ret keyword.
because the language is stack based whatever the stack contains after the function execution is available from the calling location ex:
fn a is
b puti
end
fn b is
3
end
the 3 is available because its left on the stack after function b is complete so this would print 3 if a was called.
function parameters are as follows fn a of some_param1 some_param2 is ... end
10 -> x -> makes a new variable called x and 10 is stored
x 3 + -> x -> adds 3 to x and stores it back in x
Note: variables are block scoped
const x 32 end -> x is now available for every function in the file
const b 1 offset end -> sets b to the compilers internal iota counter and increments said counter
const c reset end -> sets c to the current iota value and resets it
the last two examples can be used to create structs
enum
ONE
TWO
THREE
FOUR
end@import some_file @end -> allows access to all the functions and macros in the other file
Note: the imports are not namespaced so if two files both have function f then they will conflict.
| Program | Language | Time |
|---|---|---|
| big loop | jounce | 1.77 |
| big loop | python | 0.52 |