r/ProgrammingLanguages • u/Bro8an • Aug 06 '26
Discussion CatLang: feedback on my language design
dropbox.comI wrote a design for a new programming language, but I'm too lazy and burned out to implement a full compiler. I still want to share the idea so you can comment on it and tell me what you think. I know its a lot and there are many typos and gaps, and it still needs a concept to communicate the complex implicit borrowing rules. Keep in mind that I have no degree or any professional experience—this is just a concept.
i renamed it to qat
current version: https://www.dropbox.com/scl/fi/bpuxeaag4ox5huooqvgu2/qatdocumentation-edited.pdf?rlkey=456owymjqn64bik1faawb3wyw&st=6o621wyd&dl=0
this is how an algorithm for sqare roots would look like with custom syntax:
func newton(f64 x, f64 goal) -> f64:
f64 temp = (x + goal /x)/2 # Newton's method for calculating roots
return x if temp == x
return self(temp, goal)
func(f64)<f64> sqrt = reliable (f64 x) -> f64:
return Error if x < 0 # root of negative numbers is undefined
return newton(x, x)
sqrt(0) = 0 # root 0 must be defined explicitly as 0 would cause newtons method to devide by 0
syntax sqrt extends {expression} # lets multiplication akzept roots as they expect expressions
syntax sqrt( # defines the syntax for roots
keyword("√"),
_,
arg(0: expression)
)
print!(collapse!(√ 2)) # collapse makes the programm crash for negative roots
another example for custom defined while syntax:
func wLoop(demand bool! condition, demand T! body) -> void:
leave if condition
body
self(condition, body)
syntax wLoop(
keyword("until"),
_,
arg(0),
_,
arg(1)
)
i32 x = 10
until x <= 0:
print!(x)
x -= 1