From 5863ff5212ae73defcb31fbe9c448e36ced4e2b1 Mon Sep 17 00:00:00 2001 From: bog Date: Thu, 7 Mar 2024 15:49:37 +0100 Subject: [PATCH] :memo: updated readme. --- README.md | 156 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 154 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index cd18c91..b63e740 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,155 @@ -# bog +# Hello ! Welcome to my gitea account :) -HelloWorld! \ No newline at end of file +I have a **real** obsession for programming language design and development. I did a lot of prototypes, and most of them are just crappy full of bugs programs. **But**, some projects are ok as prototypes. + +Here you will find short descriptions of some languages I am not too ashamed to show. Some of them look like BASIC, and others like LISP. All of them was made with love, and dropped with the hope to make something better. + +Enjoy. + +--- + +[wuz](https://git.shellbox.fr/bog/wuz) is a programming language made in C with flex and bison. Its syntax looks like good old BASIC but having a more functional approach. + +``` +# a simple factorial +fun f (n as int) as int + if n == 0 + return 1 + end + + return n * f(n - 1) +end + +assert 120 == f 5 +``` + +``` +# a high order function +fun h (n as int, m as fun) as int + return (m (m n)) +end +``` + +--- + +[roza](https://git.shellbox.fr/bog/roza) is pretty much a clone of wuz with a syntax slightly different. + +``` +# functions are first class citizens +let a = fun (x as int, y as int) -> int + return x + y +end + +# function calls using curly brackets +assert 12 == {a 9 3} +assert 6 == {a {a 1 2} 3} +``` + +--- + +[grino](https://git.shellbox.fr/bog/grino) adopt a more functional lisp like syntax. Keywords are as short as possible: the function ``$`` is used to declare variables and the function ``->`` returns a lambda. + +``` +;; declare lambda +($ a (-> (x) (* x 2))) +(assert= 14 (a 7)) + +;; recursive factorial on lambda +(assert= 720 ((-> (x) + (if (eq? x 0) + 1 + (* x (self (- x 1))))) 6)) +``` +Grino supports [closures](https://en.wikipedia.org/wiki/Closure_(computer_programming)), allowing the definition of statefull functions. + +``` +;; Let's count ! +($ (i init) + ($ counter (- init 1)) + (-> () + (set! counter (+ counter 1)) + counter)) + +($ j (i 0)) + +(assert= 0 (j)) +(assert= 1 (j)) +(assert= 2 (j)) +(assert= 3 (j)) +(assert= 4 (j)) +``` + +--- + +[fakir](https://git.shellbox.fr/bog/fakir) has pratically the same syntax and semantic than grino. Fakir adds module importation features using the function ``@``. + +``` +($ a (@ './mod2')) + +(assert= 42 a::var) +(assert= 6 (a::fun 3)) +``` + +--- + +[snake](https://git.shellbox.fr/bog/snake) is a language agnostic build system. + +``` +x y z -> (*.py) { + $IN +} +``` + +``` +$Y = (x.c y.c z.d w t.h) +d -> a { + $Y[c.=.h] +} +``` + +--- + +[duck2d](https://git.shellbox.fr/bog/duck2d) is a little game framework scheme (a dialect of LISP) tool. It uses C++, OpenGL for rendering the game and guile for the scheme interface. It features an Entity Component System ([ECS](https://en.wikipedia.org/wiki/Entity_component_system)) to manage game entities. + +--- + +[muzgen](https://git.shellbox.fr/bog/muzgen) is a programming language for sound design tasks. It allows to manipulate and combinate oscillators in order to craft interesting sounds. + +``` +# play a sine at 440Hz. +[sine 440] + +# combine by adding two signals +[add [sine 220] [sine 220]] + +# using one sine to control another +[sine [mul 440 [sine 1]]] +``` + +--- + +[gux](https://git.shellbox.fr/bog/gux/src/branch/main/tests/fun.gux) is a statically and strongly typed language with a more modern syntax. + +``` +# variable declaration +var x : int = 4; +var y := 3.2; + +# factorial function +fac := fun (n: int) -> int { + if n == 0 { return 1; } + return n * this(n - 1); +}; + +# function overloading +fun first(n: int) -> int { + return 27; +} + +fun first(n: float) -> int { + return 79; +} + +assert first(4) == 27; +assert first(7.3) == 79; +``` \ No newline at end of file