Live data from Hacker News

Forth: The programming language that writes itself

ratfactor.com

111–120 of 174 posts

Re: Forth: The programming language that writes itself

#111
post #3

Why is it that languages like this don't scale? It's not the first time I see a powerful language that got forgotten. Other examples include SmallTalk and Common Lisp (tiny community). It is because some languages are "too powerful"? What does that say about our industry? That we're still not that advanced of a specie to be able to handle the full power of such languages? I say that because it seems languages that ar…

I don't think there's a unifying reason why programming languages languish in obscurity; it's certainly not because they're "too powerful." What does "powerful" even mean? I used to care more about comparing programming languages, but I mostly don't these days. Actually used/useful languages mostly just got lucky: C was how you wrote code for Unix; Python was Perl but less funny-looking; Ruby was Rails; JavaScript is…

Alike to big fortunes, no one wants to hear the truth about lot of them existing due to simple luck. There is a significant amount of post-hoc rationalization to explain the success by some almost magic virtues. Or even explain the success by lack of such virtues - "worse is better" and so on.

Re: Forth: The programming language that writes itself

#112
post #20

Earlier quoted context omitted.

That sounds interesting! Do you have any tips for us on how to use Forth effectively? What was the codebase?

Honestly, when I write forth now, which is usually for embedded targets, I've got a customized version of zforth that I've grafted some stuff like locals into. If it's a small program, it's better to not be afraid of things like globals, and just spend at least twice as much time factoring, writing comments and thinking than writing. It's important to read other people's Forth code and try to understand, as there's a…

That makes a lot of sense! Thanks!

What were the most common mistakes you saw people new to Forth making? Being afraid of global variables is one of them, I infer.

Re: Forth: The programming language that writes itself

#113
post #64

Earlier quoted context omitted.

I googled a bit on how common lisp is compiled. Apparently it is possible to add some sort of type hints and ensure that parameters/variables have a certain type. If one uses that for most code, it would potentially be enough to qualify as being close to the machine.

What does "close to the machine" mean to you?

To me it means that one attempts to use the machine well. I.e., avoid introducing overheads that have nothing to do with the problem one is trying to solve. As an example of something that is very far from the machine imagine wanting to add some integers together. One can do this in untyped lambda calculus by employing Church Numberals. If one looks at the memory representation now your numerals are a linked list of a size equal, or proportional, to the number. However, the machine actually has machine language instructions to add numbers in a much more efficient way. For this discussion maybe the most relevant example is that using dynamic typing for algorithms that don't need it is distant from the machine because every value now has a runtime type label that is actually not needed because if your program could actually be statically typed, one would know in advance what the type labels are so they are redundant.

Re: Forth: The programming language that writes itself

#114

I was captivated by the August 1980 issue of Byte magazine, which had a cover dedicated to Forth. It was supposed to be easy to implement, and I imagined I might do that with my new KIM-1 6502 board. Alas, the KIM-1 was lost when I went to college, and life forced me down different pathways for the next 45 years. About a year ago I finally began to work on my dream of a Forth implementation by building a Forth-based…

Circa 1980 BASIC was the dominant language for micros because you could fit BASIC in a machine with 4k of RAM. Although you got 64k to play with pretty quickly (1983 or so) it still was a pain in the ass to implement compilers on many chips, especially the 6502, which had so few registers and addressing modes that you're likely to use virtual machine techniques, like Wozniak's SWEET 16 or the atrocious p-code machine that turned a generation of programmers away from PASCAL.

FORTH was an alternative language for small systems. From the viewpoint of a BASIC programmer in 1981 the obvious difference between BASIC and all the other languages which that you could write your own functions to add "words" to the language. FORTH, like Lisp, lets you not only write functions but create new control structures based on "words" having both a compile-time and run-time meaning.

FORTH's answer to line numbers in BASIC was that it provided direct access to blocks (usually 1024 bytes) on the disk with a screen editor (just about a screenful on a 40x25) You could type your code into blocks and later load them into the interpreter. Circa 1986 I wrote a FORTH for the TRS-80 Color Computer running the OS-9 operating system and instead of using blocks it had POSIX-style I/O functions.

FORTH was faster than BASIC and better for systems work, but BASIC was dominant. Probably the best way to use FORTH was to take advantage of it's flexibility to create a DSL that you write your applications in.

Re: Forth: The programming language that writes itself

#115
post #36

I used to be a fan of these languages like Lisp and Forth and Joy (and Factor and Haskell), but then I found that what I a really long for is just (untyped) lambda calculus (as a universal language). (Combinatory logic is just a similar representation of lambda calculus, but the differences go away quickly once you start abstracting stuff.) I think expressing semantics of all (common) programming languages in lambda…

Grounding programming languages in mathematics like this is essentially the goal of Strachey and Scott's denotational semantics, which has been very influential in programming language theory: https://en.wikipedia.org/wiki/Denotational_semantics

All approaches to semantics of programming languages are mathematical, the denotational one is not "more mathematical" than the rest.

Re: Forth: The programming language that writes itself

#116
post #98

Earlier quoted context omitted.

> There are at least 3 rewrites of AmigaOS (AROS, MorphOS, AmigaOS 4.x) but despite so much passion nobody bothered to bring the desktop to Linux? The passion is there for the whole AmigaOS, of which the desktop metaphor, Workbench, is just a part. What fun is AmigaOS without Exec, Intuition and AmigaDOS? The passion is to see AmigaOS run, not to see Linux wearing its skin. GUIs for manipulating files a-la Workbench…

Well, you do you, and indeed, the entire community is free to do as it wishes. What I find surprising is that there are multiple entire Amiga-themed Linux distros – for example: https://www.commodoreos.net/CommodoreOS.aspx I reviewed it. I was not very impressed. https://www.theregister.com/2025/05/06/commodore_os_3/ And ones which put an Amiga emulator front and centre: https://cubiclenate.com/pimiga/ https://wilkie…

I think you can categorise Amiga enthusiasts in various ways, this is my taxonomy:

1. Hardware enthusiasts who specifically love the Amiga's original hardware, its peripherals, and the early post-Commodore direction (PowerPC accelerators), and/or modding all of the above. These sort of people used WarpOS back in the day and probably use MorphOS or AmigaOS 4 today. The question is whether, for these people, modern single-board computers "count" as Amigas or not.

2. Nostalgic enthusiasts of the system that the Amiga was, who are happy with a real Amiga, or with an emulated one, or an emulated one running on some board in a box shaped like an Amiga. Possibly with a non-Amiga UI to boot some classic games. These enthusiasts may enjoy fake floppy drive sounds that remind them of booting disks in their youth.

3. Software enthusiasts of the Amiga's OS, and the directions it took that were different from its contemporaries, and the software ecosystem that came from it. These people have a longer user-startup than startup-sequence. They probably have most of Aminet downloaded. These people might be interested in other alternative OSes, e.g. QNX or BeOS. If they're still using Amiga hardware, or emulators, they'd be interested in AmigaOS 3.5/3.9 and 3.1.4/3.2. This can also include AROS and the work to get it running on native hardware, not just m68k but also x86 and arm... but it's unlikely that it will ever support as broad a range of hardware that Linux does, which limits how many people would want to use it, because it's unlikely to be able to drive a random modern laptop.

4. The reverse of 3, Amiga users that were big UNIX fans, e.g. Fred Fish, the sort of people who ran GeekGadgets and replaced their AmigaShell with pdksh. They probably just moved wholesale to Linux and didn't look back.

There are probably other categories, but I think the one you're looking for is 5: enthusiasts of the Amiga's look and feel, but not its broader OS or its software. If they did care about that, they'd be in groups 2 and 3, and emulators or alternative AmigaOSes would satisfy them most.

I can't say why there aren't many alternative desktops for Linux. Probably because it takes a lot of resources to build a full desktop environment for linux - a Window Manager, or even just an existing Window Manager theme is not enough. A file browser is not enough. Ultimately it takes the applications themselves to play along, which only works when have the clout to make people write software in your style (e.g. KDE, GNOME, Windows, macOS, Android, etc.).

The only alternative UI taken from retro machines to Linux, that I can think of, is ROX Desktop (https://en.wikipedia.org/wiki/ROX_Desktop) with its ROX-Filer... and even that doesn't look entirely like RISC OS, which you could be running instead of Linux.

Re: Forth: The programming language that writes itself

#117
The Forth super power is that you have full control over how a symbol is evaluated, both at compile and runtime. I don't know of anything else that offers that. Lisp doesn't.

That gives the developer pretty much free rein to do whatever they want, which can be both good and bad.

I've always loved the elegance of Frank Sergeant's 3 Instruction Forth paper [1], it's very cool once you wrap your head around it.

Also, studying the F83 Metacompiler is valuable as well. F83 is a very capable 8/16-bit Forth system.

I honestly marvel at how much work must have gone into F83, given the tools of the time. I wish I knew more about its development journey. How it got bootstrapped.

[1] https://pygmy.utoh.org/3ins4th.html

Re: Forth: The programming language that writes itself

#118
post #41

Earlier quoted context omitted.

Why specifically untyped?

Because it is the simplest thing we have, and has a pretty straightforward self-interpreter. It feels like you need a lot more metamathematics to deal with typed lambda calculus than with untyped one, and types are something that comes without a justification. Anyway, the idea is, if you have a language, you can think of source code written in the language as a giant lambda term, where you have all lambdas upfront an…

> have all lambdas upfront and only composition in the body

That is only possible for a very limited subset of lambda terms. For example, it's not possible for the one-point basis

    A = λx λy λz. x z (y (λw. z))
from which any closed lambda term can be constructed by composition.

Re: Forth: The programming language that writes itself

#119
post #36

I used to be a fan of these languages like Lisp and Forth and Joy (and Factor and Haskell), but then I found that what I a really long for is just (untyped) lambda calculus (as a universal language). (Combinatory logic is just a similar representation of lambda calculus, but the differences go away quickly once you start abstracting stuff.) I think expressing semantics of all (common) programming languages in lambda…

A lot of languages(including forth) maps really poorly to LC. Read some of the Forth writing on portability at all costs: http://www.ultratechnology.com/antiansi.htm

It's difficult to understand what they were actually doing, but reading between the lines, it sounds like an advantage of 'machine Forth' is writing some Forth words in assembly? I can see why that would run much faster for a jpeg decoder.

Re: Forth: The programming language that writes itself

#120
post #105
post #16

If you like Forth, but find it challenging to build real stuff with, Factor ( https://factorcode.org/ ) is most or all of the good stuff about Forth designed in a way that's much easier to do things with. It was designed by Slava Pestov (who I think had a big hand in Swift), and honestly it's a lot of fun to build webapps and other programs with, and much less brutal to read than Forth can be.

I had to have a peek if it's all just web. Apparently, no. https://concatenative.org/wiki/view/Factor/UI > The Factor UI is a GUI toolkit together with a set of developer tools, written entirely in Factor, implemented on top of a combination of OpenGL and native platform APIs: X11, Win32 and Cocoa. > UI gadgets are rendered using the cross-platform OpenGL API, while native platform APIs are used to create windows and…

Factor is not dead, but continues to make development progress. If you're curious you can find more information on the main page:

https://factorcode.org

The latest release of 0.100 was September 2024, and we are getting close to a new release which we hope to do end of the year or so.

https://github.com/factor/factor

The cross-platform UI that Factor has works on macOS, Windows, and Linux. On Linux, it unfortunately still uses a GTK2-GLext project for the OpenGL widget that we render into, but modern GTK3/4 has a Gtk.GlArea that we need to switch to using which will improve the compatibility on Wayland. However, it works fine with even the latest Ubuntu 25.10 release.

And of course, you could use other libraries easily, such as Raylib:

https://re.factorcode.org/2025/05/raylib.html

Post reply on HN