5 ms·
I began designing a language that handled recursion and iteration as relations between variables which are topologically sorted to determine control flow. Each
by samsquire 4y ago
I began designing a language that handled recursion and iteration as relations between variables which are topologically sorted to determine control flow.
Each function is a toplogical graph of stream functions so it is similar to a data flow language or reactive programming language. The goal is that you should express the critical insight of the algorithm to work out what to write and the code is not nested so there is very little tree structure.
Algebralang is rough notes on how it would appear.
https://github.com/samsquire/algebralang https://github.com/samsquire/algebralang
Example programs in the repository are binary search, btrees, a* algorithm.
I wrote a multithreaded parallel actor interpreter in Java and it uses an invented assembly language which doesn't have a bytecode, it's just text.
https://github.com/samsquire/multiversion-concurrency-control#parallel-interpreter https://github.com/samsquire/multiversion-concurrency-contro...
I like the ideas behind ani language
https://github.com/waves281/anic https://github.com/waves281/anic
- Jtsummers 4y agoIf possible, I'd add indentation to your examples to make them much more readable. As it stands, it's like reading one of my math prof's C code (he was an old FORTRAN when it was shouting coder and never learned to indent): insert t node = recursive_deepest_first(items=t.children,item=t, lastRecursion=l)( if len(t.children) == 0 t.activate() location = reversed(t.children).find(item=i, item.value >= node.value) output = insert t node if len(t.children) > 3 { replace(t, Node(value=t.children÷(point=middle=m) = m.value,children.sort(item=i,sortKey=i.value)=t) output = l.t } else deepest t.children.append(node) ) Assuming this doesn't invalidate the program it reads more clearly and only takes one more line: insert t node = recursive_deepest_first(items=t.children, item=t, lastRecursion=l)( if len(t.children) == 0 t.activate() location = reversed(t.children).find(item=i, item.value >= node.value) output = insert t node if len(t.children) > 3 { replace(t, Node(value=t.children÷(point=middle=m) = m.value, children.sort(item=i, sortKey=i.value)=t) output = l.t } else deepest t.children.append(node) ) That original program was hard to decipher for both lack of indentation and the odd line breaks, and inconsistent choice of space or no space after commas. Another question, why do you use `if ... then...` in some examples and not in others? Is that a user choice?
- samsquire 4y agoWow thanks for reading my page and looking at the examples. I appreciate your time. There's a few bugs in that code. Sorry for presenting something that obviously wasn't ready. I didn't use location when I insert into that position in the btree. And the node spliting code has an error. And thanks for reformatting the code. It's a very rough design. The critical insight over many algorithms is hidden in one character or line. Such as a strategic -1 or +1 or pattern of recursion that means it becomes understandable. I find when writing code the structure of the code is more important than the calculation or addition or subtraction. Which is surprising because computers are calculators. The structure of traversal, laying out data in memory and structure of the jumping around instructions in memory is harder than the core insight of a division, or subtraction or addition or append or +1 or if statement here or there. When I write recursive code I often want to refer to outer context of an outer recursion. So that's the meaning of the "deepest"
- Jtsummers 4y agoYou may be interested in things like Strand and the work on parallel Prologs which have a similar "let the computer system sort out the proper execution order". This wouldn't satisfy your syntax desire (Algol family) but may help develop your understanding of the problem domain. A discussion last year: https://news.ycombinator.com/item?id=26948351 https://news.ycombinator.com/item?id=26948351 (wow, 18 months since that discussion, seemed more recent in my memory)