3 ms·
Loved the language - first as an embedded developer (late 80s), then with Harris Semi's RTX microcontroller team. I see a Forth reference about once per month o
by mud_dauber 4y ago
Loved the language - first as an embedded developer (late 80s), then with Harris Semi's RTX microcontroller team. I see a Forth reference about once per month on HN but nothing in developer-specific forums, so I have to assume Forth is dead.
What gives? Is there some use case that only Forth can satisfy? Is it just the simplicity and "strangeness"?
- jedimastert 4y agoI haven't gone as deep as I'd like to into Forth, but I liken it somewhere in between Assembly and C in terms of level of abstraction, and from what I can see the trends of programming languages are features that move further away from hardware and computer specifics towards higher level concepts (the first thing that jumps to mind is Lisp)
- Gordonjcp 4y agoIt's a bit like rolling your own macro assembler, in a way.
- DonHopkins 4y agoYes indeed, but even more so: Forth is vastly more powerful than a mere macro assembler, because you have the full power of Forth to write arbitrary functions and mini-compilers to assemble code, no just simple macros! It comes with structured control flow constructs, and you can even write your own. Not only is the assembler itself written in Forth, but you can seamlessly extend and build on top of the it too, building high level interfaces and domain specific languages on top of low level assembly code and hardware. Check out the amazingly powerful x86 assembler in OpenFirmware, which is deeply integrated with the hardware, operating system, bootstrapping, debugging, tracing, breakpointing, disassembling, cross assembling, meta compiling, and calling back and forth with C code: purpose: x86 assembler https://github.com/openbios/openfirmware/tree/master/cpu/x86 https://github.com/openbios/openfirmware/tree/master/cpu/x86 purpose: From Forth, call the C subroutine whose address is on the stack https://github.com/openbios/openfirmware/blob/master/cpu/x86/call.fth https://github.com/openbios/openfirmware/blob/master/cpu/x86... purpose: Tools for creating disembodied assembly code sequences https://github.com/openbios/openfirmware/blob/master/cpu/x86/asmtools.fth https://github.com/openbios/openfirmware/blob/master/cpu/x86... purpose: Forth access words for special 386 registers https://github.com/openbios/openfirmware/blob/master/cpu/x86/asmspec.fth https://github.com/openbios/openfirmware/blob/master/cpu/x86... purpose: After a breakpoint, displays a backtrace of C stack frames. https://github.com/openbios/openfirmware/blob/master/cpu/x86/ctrace.fth https://github.com/openbios/openfirmware/blob/master/cpu/x86... purpose: 386 disassembler. https://github.com/openbios/openfirmware/blob/master/cpu/x86/disassem.fth https://github.com/openbios/openfirmware/blob/master/cpu/x86... purpose: Access to I/O ports and physical addresses under Linux https://github.com/openbios/openfirmware/blob/master/cpu/x86/ioports.fth https://github.com/openbios/openfirmware/blob/master/cpu/x86... https://github.com/openbios/openfirmware/blob/master/cpu/x86/assem.fth#L811 https://github.com/openbios/openfirmware/blob/master/cpu/x86... \ One of the very best features of FORTH assemblers is the ability \ to use structured conditionals instead of branching to nonsense \ labels. : IF >MARK swap long-offsets @ if dup h# eb = if drop h# e9 asm8, else prefix-0f h# 10 + asm8, then real? if 0 asm16, else 0 asm32, then else ASM8, 0 asm8, then ; : THEN >RESOLVE ; : BEGIN <MARK ; : UNTIL <RESOLVE ; : AHEAD 0EB IF ; : ELSE AHEAD BUT THEN ; : AGAIN 0EB UNTIL ; : WHILE IF BUT ; : REPEAT AGAIN THEN ; \ These conditional test words leave the opcodes of conditional \ branches to be used by the structured conditional words. \ For example, \ 5 # ECX CMP 0< IF EAX EBX ADD ELSE EAX EBX SUB THEN \ begin dx al in tbe # al and 0<> until https://github.com/openbios/openfirmware/blob/master/cpu/x86/startmacros.fth https://github.com/openbios/openfirmware/blob/master/cpu/x86... \ Some x86 assembler macros to make it easier to write x86 early \ startup code. There are macros to set MSRs to specific values, \ to set and clear individual MSR bits, to read and write PCI \ configuration registers with the common CF8/CFC mechanism, \ and to read and write I/O ports. \ The code keeps the MSR register number in %ecx, the low 32 bits \ of the value in %eax, and the high 32 bits in %edx, consistent \ with the way the rdmsr and wrmsr machine instructions work. \ The bitset and bitclr operations work on %eax, and the -hi versions \ work on %edx. \ The I/O port operations also leave the data in %eax, so you can \ use bitset and bitclr with them too.
- astrobe_ 4y ago> I see a Forth reference about once per month on HN but nothing in developer-specific forums, so I have to assume Forth is dead. Depends on your definition of dead |1]. > Is there some use case that only Forth can satisfy? Interactive programming with really low resources, or the advantage of having an interpreter that you can tune and adapt at will. [1] https://forth-standard.org/ https://forth-standard.org/