Thursday, March 24, 2022

Mimalloc Concurrent Reference Counting Back-end

 Right, so I would really want to write a typed Egel.  But I decided I cannot without a better performing back-end, I would just add types to a too slow language. Seems I cannot get rid of rewriting the Egel interpreter for a while yet.

I studied various solutions, hoped for a drop-in concurrent reference counting garbage collector but none exist. So now I am writing an back-end on basis of Daan Leijen's excellent mimalloc which I'll use as the concurrent slab allocator.  The code for the moment does seem to write itself, which is excellent.

I can only hope it'll give me the one order increase in performance I need, otherwise, it'll be all for nought. But I'll do some extensive testing on this (since that needs to be done) and that'll include performance metrics.

Thursday, March 17, 2022

Typed Egel

 Below, how Egel could look typed.  But I need something for software engineering in the large too, objects or modules or something. Mulling over that.

def fib: int -> int = [ 0 -> 1 | 1 -> 1 | | N -> N + fib (N - 1) + fib (N - 2) ]
type list[N] = nil | cons N list[N]
def concat: [N] => list[N] -> list[N] -> list[N] = [ nil YY -> YY | (cons X XX) YY -> cons X (concat XX YY) ] class ord N = def compare: N -> N -> int def less: N -> N -> bool instance ord int = def compare: int -> int -> int = int_compare def less: int -> int -> bool = int_less def sort: [ord N] => list[N] -> list[N] = [ nil -> nil | (cons X XX) -> insert X (sort XX) ] where def insert: [ord N] => N -> list[N] = [ X nil -> cons X nil | X (cons Y YY) -> if X < Y then cons X (cons Y YY) else cons Y (insert X YY) ]