4.3 KiB
Comun
Comun is a beautiful, greatly minimalist programming language made by drummyfish, based on his ideals of good, selfless technology known as less retarded software (LRS), of which it is now considered the official programming language. In the future it should gradually replace C as the preferred LRS language. The language has been inspired mainly by Forth, but also C, brainfuck and other ones. Though already usable, it is still in quite early stages of development and work in progress; currently there is a suckless implementation of comun in C and a number of supplemental materials such as a specification, tutorial and some example programs. The project repository is currently at https://codeberg.org/drummyfish/comun. The aim now is to make a self hosted implementation, i.e. write comun in comun. Though very young, comun is probably already the best programming language ever conceived.
The language is intended to be the foundation of a completely new, non-capitalist computer technology built from the ground up, which should culminate in the creation of the LRS much desired public domain computer. This technology is derived from the model of an ideal society and as such will aim for completely different goals (such as helping all living beings as much as possible without enslaving them) and values; this makes comun astronomically different in philosophy and design of the shitty, toxic capitalist joke languages such as C++ and Rust which pursue fascism, enslavement of humans to the productivity cult etc.
A quick sum up is following: comun is minimalist, low level with minimum abstraction, portable, imperative and stack-based, using reverse Polish notation. It can be both compiled and interpreted. There are only primitive integer data types (native integer size by default with possibility to specify exact width where necessary, signed/unsigned interpretation is left to the programmer) and optional pointers that can be used as variables, for managing multiple stacks, creating arrays etc. Its specification can fit on a sheet of paper and is completely public domain under CC0 (as is its current implementation). It has no standard library. There are no English keywords; commands are rather very short (mostly 1 to three symbols) math-like symbols. Source code only allows ASCII symbols (no unicode). There is an optional preprocessor that uses comun itself (i.e. it doesn't use any extra language). Functions and recursion are supported. Many features of the language are optional and never burden the programmer if he doesn't use them. Simplified versions of the language (minicomun and microcomun) are also specified.
Examples
Here is a very short showcase of comun code, demonstrating some common functions:
max: <' ? >< . ^ . # takes maximum of two values
max3: max max . # takes maximum of three values
# recursive factorial
factR:
?'
$0 -- factR *
;
^ 1
.
.
# iterative factorial
factI:
$0 --
@'
>< $1 * ><
--
.
^
.
The following is a quine in comun:
0 46 32 34 S 34 32 58 83 S --> S: "0 46 32 34 S 34 32 58 83 S --> " .
The following code translates brainfuck to comun:
0 "$>0 " -->
@@
<? ?
<-
$0 "+" = $1 "-" = | ?
$0 -> $0 -> " " ->
.
$0 "<" = $1 ">" = | ?
"$" -> $0 -> "0" -> " " ->
.
$0 "." = ?
0 "->' " -->
.
$0 "," = ?
0 "$<0 <- " -->
.
$0 91 = ? # left bracket
0 "@' " -->
.
$0 93 = ? # right bracker
0 ". " -->
.
^
;
!@
.
.
TODO: more, code examples, compare the above with C, ...