Hacker News new | ask | show | jobs
by vram22 2697 days ago
>I was going to mention that it is a lot like Rebol and Red in philosophy, but you beat me to it.

I agree, the philosophies are similar. Minimalism, relying more on your own code than libraries, not generalizing your code for a lot of cases that might not happen, etc.

One thing that puzzles me about Forth, though:

I did read a few books about it (much earlier, and I'm not a language designer, so what I say next could be wrong). Some of them talked a bit about Forth's internal design. I understood from that, that when multiple words (Forth subroutines) are defined, they are "threaded", from which I understood that they are added to a linked list of word definitions. Wondered why it needed to be a linked list. If it was a lookup table of some kind, like a Python dict or a Ruby hash (basically an associative array), looking up word definitions to run them would be faster than in a linked list, which is linear, I'd think.

Edit: I did just have an idea of what the reason for that may be, but will wait a bit to see if anyone replies with their explanation. Hint about my idea: it may have to do with Charles Moore's Forth philosophy - just a guess on my part.

1 comments

I'm very much a noob when it comes to Forth and I've asked myself the same question before. I think threaded is generic enough to not necessarily dictate the data structure. It more or less means that a word (if it isn't being defined and added to the dictionary (not dictionary as in Python dictionary, but what they call the list of words in Forth)) it will read from the stack, modify the stack, and then call the next word.

Someone on here or on the Forth subreddit should be able to answer though.