3 ms·
I am trying to design a language based on Ian Piumarta's metaprogrammable object model [1] (i.e. a Smalltalk-like where two methods are defined "a priori" in th
by sph 3y ago
I am trying to design a language based on Ian Piumarta's metaprogrammable object model [1] (i.e. a Smalltalk-like where two methods are defined "a priori" in the entire system, everything else is late bound and can be changed at runtime — believe it or not, more flexible than any Lisp) and I was trying to figure out how to implement the basic stuff like number addition in the language, when nothing has been defined yet.
Piumarta shows that with his model any function/closure/method can in theory and very easily be written in any language, so at first I was thinking of having tagged asm blocks:
Number + other = {.asm.
mov rbx, [self]
mov rcx, [other]
add rbx, rcx
mov [self], rbx
}
assert: { 5+6 } equals: 11
But then I would have to write an assembler, in the bootstrapping language (currently C which I've grown to dislike). So I thought about Forth:
Number + other = {.forth.
( self other -- self )
@ over @ + !
}
Which seems so elegant, portable, the bootstrapping language can be Forth (the Forth interpreter itself written in asm), and I don't have to write an x86_64 assembler in C. Win win win.
And during my research I came across this, running Pascal in Forth. Time is a circle and computer science keeps reinventing itself :-)
I like the opinion of the author that a great platform is one that lets you choose the perfect language to the problem at hand. My (ideal) language is fully late bound, based on message passing, which is extremely flexible, but not ideal for number crunching. Is this much of a problem, if a user can drop down to FORTRAN in the hot loops? I feel that is a much better idea than creating a multi-paradigm language that does everything but the kitchen sink (cough C++ and Rust), and is either mediocre like the former, or very complex like the latter.
IMO, we need simpler languages, based on the next level of abstraction — communication and not computation.
1: https://www.piumarta.com/software/id-objmodel/ https://www.piumarta.com/software/id-objmodel/
See also COLA: https://www.piumarta.com/software/cola/ https://www.piumarta.com/software/cola/ based on this model, but still too advanced for my brain to digest.
---
If anyone reading is familiar with Piumarta's COLA/object model and/or very late bound minimal systems, please drop me a line, I would be happy to pick your brain.
- pyinstallwoes 3y agoThis seems relevant to my open ended curiosity around the question 'what is the irreducible form of compute?' I've been thinking of solving it with Forth, as well, coincidentally. I basically want to build a bootstrappable Forth as a meta-transpiler over a Forth VM that initially starts out in the earliest stage as the most minimum possible representation and add from there. In my research things that led to this being possible but I haven't sussed out: 1. Mov based architecture 2. Transport Triggered Architecture 3. Some two push-down automata based on some operation that assumes stack operations for left and right to manage params/addresses.
- alexisread 3y agoI'd have a look at Freeforth (Anonymous function eval at the shell, threaded subroutines with no swap, MSP433 cross compiler) https://github.com/dan4thewin/FreeForth2/blob/master/ff.asm https://github.com/dan4thewin/FreeForth2/blob/master/ff.asm Sectorforth (Minimal - 7 operators, everything else is in the prelude including IF) https://github.com/cesarblum/sectorforth/blob/master/sectorforth.asm https://github.com/cesarblum/sectorforth/blob/master/sectorf... And Retroforth (Multi platform VM, quotations) https://github.com/crcx/retroforth/tree/master/vm https://github.com/crcx/retroforth/tree/master/vm For larger coding, you may need a GC, Retro has a list class, and Freeforth operates a compacting dictionary which you may be able to modify
- sph 3y ago> 'what is the irreducible form of compute?' That is a very interesting question, which I'm trying to explore from another angle: what is the irreducible form of computing? As in, how minimal can a modern (operating) system be, to be able to boot and develop it completely at runtime? Modern development is like preparing a blueprint of a sculpture, magically applying it on real marble, and when something is not ideal, back to the blueprint. I don't know what the future operating system and post-UNIX paradigm looks like, but I want to explore that design space with a chisel and hammer on live silicon rock. A bare metal REPL to a fully reprogrammable environment/language. I don't have an answer to my or your query, but reducing the hypercomplex world of computing down to its axioms is a very fascinating topic.
- alexisread 3y agoThis is what the the COLA papers talk about as you're aware, a REPL where you can modify, recompile and use the environment dynamically. Smalltalk is also similar in this regard, with a nicer UX. One of the reasons why this style has not taken off (image-based) is that its very easy to lose track of changes while developing - there's no formal iteration boundary. This guy https://github.com/attila-lendvai/maru https://github.com/attila-lendvai/maru Has been experimenting with git branches for this. https://github.com/crcx/retroforth/blob/master/doc/RETRO-Book.md#metacompilation-and-assembly https://github.com/crcx/retroforth/blob/master/doc/RETRO-Boo... talks about this issue, and the Retroforth author's attempt to define more clean boundaries.
- JonChesterfield 3y agoAssemblers are mostly very large tables of data about instructions. If you're lucky, the architecture will have XML format descriptions of the ISA available that you can derive an assembler from. I think x86-64 even has versions with experimentally determined instruction latency in the same data. A C assembler with the bulk of the implementation mechanically derived from XML is probably a reasonable project to attempt. I haven't done it yet but it's planned.
- alexisread 3y agoI think that if you have an escape hatch for something like numbers, it will get abused to the point where the language is incomplete without it, and you have two problems ;) I'd also agree about your ideal. Maru for a long time was my goto reference as it's small, has a compiler to x86, is self-hosting, and has fexprs as a fundamental design choice. The main issue with Maru, aside from being coded in C (bootstrapping from fundamentals), is that environments are implicitly dynamic, with no static control. https://github.com/GiacomoCau/wat-js https://github.com/GiacomoCau/wat-js has explicit dynamic variable handling, it uses the concept of wrap aka quotation plus env to determine what gets evaluated from the runtime env vs the compile time (static) env. One thing I'm less keen on, is the use of macros. I feel Zig has the right approach with a compiletime annotation. Wat also handles delimited continuations, which you can build an algebraic effect system on. Thus you can get multithreading, fibers, async, exception handling, IO, actors etc. very easily in little code. Wat also has modules. Forth is like a super power for bootstrapping, but is unopinionated and for higher level coding, could use more of the techniques from Wat. You might want to look at https://github.com/dan4thewin/FreeForth2/blob/master/ff.asm https://github.com/dan4thewin/FreeForth2/blob/master/ff.asm It compiles anonymous functions (words) at the shell. It may be possible to use this technique with dynamic variable handling to get an eager bound system when required.
- hansvm 3y agoIf you have a second, I'm much more interested in the particular research method you adopted to allow you to stumble across those papers.
- sph 3y agoSpending 12 hours a day in front of a PC, being on a sabbatical for a year, being obsessed with this problem for the entire duration. Then it's just a matter of Googling stuff, printing papers and reading them. I'm a high school dropout so probably there is a much more efficient way of doing academic research than mine. The path was mostly Lisp -> Forth -> Smalltalk -> Self -> COLA. Hacker News search is particularly good if you have the right keywords and you stumble upon the comments of the Elders that roam about and share their long lost knowledge (user DonHopkins for example having an encyclopaedic knowledge on this stuff)
- vidarh 3y agoYou can have both. A minimal forth wouldn't need much to let you define words corresponding to assembler instructions using Forth syntax and leave the assembled instructions on the stack. Then you "just" need a word to create a compiled machine code word from what has been pushed to the stack.