7 ms·
Forth: A New Way to Program a Mini Computer (1974)
- DonHopkins 4y agoFORTH ?KNOW IF HONK! ELSE FORTH LEARN! THEN
- mmastrac 4y agoThere's a soft spot in my heart for ((bumper)? stickers) that only 1/100 of 1% of the population will ever get.
- daggersandscars 4y agoIn the 1980s, you could get a replacement ROM that turned the Sinclair ZX81 (aka the Timex Sinclair 1000 in the US) into a Forth machine. It was a fun and affordable way to learn forth at the time. Forth holds a two unique positions for me: the first developer I met that made over US$100K/year was a Forth developer (25+ years ago). Forth is also the only language where I have met one person who wrote it for a living.
- abudabi123 4y agoHas anyone had success at seating on a narrowly confined Forth an Isabelle Higher Order Logic for spec. to code proofing a model?
- dingosity 4y agoI didn't notice the Jupiter Ace was a thing back in the day, but a while back got the xACE emulator running. I imagine it was a similar experience. Seems like it should be easy to build a code-a-like with an RC2014 or similar system. (And you would have the option of adding a better keyboard.)
- kstrauser 4y agoYoung me would have vastly preferred that to the Sinclair’s BASIC ROM. It would’ve been different from the stuff we were learning at school, but might’ve made that little machine actually useful.
- stolenmerch 4y agoYou may be interested in Collapse OS, a "Forth operating system and a collection of tools and documentation with a single purpose: preserve the ability to program microcontrollers through civilizational collapse". http://collapseos.org http://collapseos.org
- anthk 4y agoNo float/double number support, sadly. Yes, I know "starting Forth" has clues to live with that: https://www.forth.com/starting-forth/5-fixed-point-arithmetic/ https://www.forth.com/starting-forth/5-fixed-point-arithmeti... but I would like at least how to print two ints to make a double. I tried to implement D+, D-, M+ and such by hand, but they failed.
- mrlemke 4y agoNeither would the 8 bit CPU you are salvaging. You don't even really need it anyways, you could get away with integer math. You would be running trading algos for bullets and cigarettes in a shanty bazaar.
- PM_me_your_math 4y agoSomeone had made a programmable forth computer in Minecraft. Going back a few years, but I think it was RedPower Mod. It ended up teaching you a little forth to control your factory.
- JohnDeHope 4y agoBoth forth and lisp seem similar to me. They have a "three sentences to explain how everything works" vibe. Forth uses a stack and so "reverses" the order of things. Lisp uses trees and so "indents" everything. I wonder if there is some kind of underlying rule. If you want "one syntax to rule them all" then it has to be recursive and so there's only a few options: stack, tree, etc. Hmm well recursive isn't the right term here. Maybe somebody who actually has thought about this can correct me.
- deleted 4y ago[deleted]
- LudwigNagasena 4y agoWell, recursion is one of the primitives that allows construction of all computable functions: https://en.wikipedia.org/wiki/General_recursive_function https://en.wikipedia.org/wiki/General_recursive_function
- jerf 4y agoI think the combination of "simple universal syntax" and "utility to human brains to write programs" is indeed probably a relatively small space. This is in contrast to simply having a "simple universal syntax", and I don't know how many solutions that may have in the abstract sense. There are many cellular automata that from a certain point of view have "simple syntax" (at least in the sense of a limited number of symbols and super limited number of ways to put them together) and have universal computation powers, but are not useful in the slightest for human programming. (Not the most common Turing tarpit to get caught in, but this has snared a number of people over the years trying to turn cellular automata into programming languages.) Who knows what other exotic possibilities may lie out there in math space where no human mind has yet even peered. I think there's probably a lot of other things that are mathematically universal computers, but like cellular automata are just too unstable (in the mathematical sense, all small changes to program produce huge changes to output; we humans prefer languages that have that characteristic only in controlled and limited ways) for humans to program. And dropping the other criterion of "simple universal syntax" of course reveals a rich space of possibilities, notably including every other programming language that isn't Lisp/Forth/Haskell-esque in theoretically being one of the simple universal syntaxes lifted up to being a programming language. (Haskell is one of the other ones, BTW, being "lambda calculus" reasonably translated to a programming language. It isn't purely so but generally neither is a Lisp.)
- Pet_Ant 4y agoI was introduced to Froth via [Factor](https://factorcode.org https://factorcode.org) (which I discovered as a jEdit user as both have the same initial author). Factor is a garbage collected higher order Forth that makes it more fun to program in (example: 'quotations', basically pushing lambdas on the stack). If I am doing coding puzzles I do it in Factor. Some might argue that it's not a real Forth because it's not as close to the metal... but you could rewrite Factor in Forth and then the distinction would be gone (think Lisp reader macros). I recommend people curious give it a try.
- samatman 4y agoFactor is an interesting and opinionated language, I agree that it's worth grokking and playing around with. I don't consider it a Forth, nor does it need to be. Factor is borrowing from Joy, Lisp, and Smalltalk, the result has a very different flavor. Nothing wrong with that. The closeness to the metal is basic to the Forth experience, doing interesting things in Factor and in Forth uses completely different mechanisms. I suggest reading Programming a Problem-Oriented Language[0] by Chuck Moore, because it's among the best memoirs by an influential computer programmer, but also to get a feel for what Forth is all about, what makes it distinctive. [0]: http://www.forth.org/POL.pdf http://www.forth.org/POL.pdf
- retrocryptid 4y agoI feel obliged to mention Loeliger's Threaded Interpretive Languages. It really helped me figure out what was going on under the hood w/ FORTH. That might be my only "beef" w/ FORTH back in the day, introductory documentation was easy to find, but intermediate and advanced documentation was much harder to come by. Forth, Inc. now has a number of decent books. Check them out at https://www.forth.com/forth-books/ https://www.forth.com/forth-books/ . And the Internet Archive has plenty of FORTH books: https://archive.org/search.php?query=FORTH https://archive.org/search.php?query=FORTH . And the FORTH Interest Group has links to most everything else: http://www.forth.org/ http://www.forth.org/ . And let me echo the sentiment that it's delightful to have a programming language you could probably implement in a weekend and understand every bit of what's going on under the hood.
- robomartin 4y agoI used Forth professionally on a number of processors over about ten years. On a couple of them I had to implement the language from scratch, including having to write a code editor and other system tools. Remembering those days always makes me smile. I really enjoyed that work. The language is fun to use, fast to code and execute and as flexible as you want it to be. I made extensive use of it in robotics, including designing and building a networked multiprocessor walking robot controller from scratch. Remember, no Internet, Arduinos or SO; just bare chips, data books and your own creativity. My first Forth project was on a 6502.
- markus_zhang 4y agoThanks for sharing, are people still programming robots in Forth nowadays?
- anta40 4y agoI think C/C++ is the popular option nowadays.
- markus_zhang 4y agoYeah I think so. Thanks.
- adastra22 4y agoThis one comes to mind: https://www.excamera.com/files/j1.pdf https://www.excamera.com/files/j1.pdf
- robomartin 4y ago> are people still programming robots in Forth nowadays? Frankly, I haven't kept up with the Forth community. Back in the day it was really popular in astronomy as well. Lots of observatories used Forth to control their telescopes, etc. The transition to C/C++ was inevitable for a range of reasons. Finding qualified Forth programmers became really hard at some point. For me the transition happened when a friend of mine asked me to help port a Forth codebase to C. The system was used for DNA sequencing by researchers in the Human Genome project. It had become very difficult to maintain and evolve the product precisely due to not being able to find good (or enough) Forth coders. I think that was the last large Forth project I completed, which, oddly enough, involved abandoning Forth in favor or C.
- entaloneralie 4y agoForth, and its derivatives, has been the principal language I program with these past few years, but one that is on my radar lately, and I wish I had more of a use for is Joy, a purely functional forth-like language. In Joy, everything is a function that takes a stack as an argument and returns a stack as a result. For instance, the numeral '5' does not represent an integer constant, but instead a short program that pushes the number 5 onto the stack. https://en.wikipedia.org/wiki/Joy_(programming_language) https://en.wikipedia.org/wiki/Joy_(programming_language)
- spaintech 4y agoIn a real practical application, if you properly evaluate Forth for doing Embedded solutions, then it becomes a real viable option considering the alternatives. First thing is readability of a DSL for an embedded project, working through the HAL that are created just to communicate with the hardware is a real PITA, but forgoing that even further, creating your own DSL for the HW layer is extremely useful even for the HW teams, you can be calling connection the same for once, Pins will be Pins, you will SENDRESPONCE PIN20 etc. Furthermore, you can be doing unit testing with in the development phase not after, so that eases the debugging of the SW and expedites time to do integrated validation. Further more, the interactiveness of FORTH is a unique experience, it makes the little MCU feel like a complete system. There was a recent posting in youtube that best describes this, and IMHO, it’s a hard to beat option as you den with in a MCU, validate each of the function words in Forth to ensure that bit of the code is working. Finally, you don’t need a lot of the dedicated hardware to debug, you are with in the system and you can read the register and memory interactively, so no surprises. If you consider al this, then it’s IMHO a hard option to pass up for this kind of work. Here is the video I mentioned: https://www.youtube.com/watch?v=VPVbARJ8QsA&t=3120s https://www.youtube.com/watch?v=VPVbARJ8QsA&t=3120s Cheers!
- dublin 4y agoA little-known fact is that the entire preboot environment in Sun's UltraSPARC machines was really just Forth. It was possible to modify that Forth code to do more or different things than what the factory intended, and Sun actually had documentation on how to do that, IIRC. I really miss having an innovative, open-source friendly hardware manufacturer like Sun around - they were an extraordinary group of people. (I worked for them for a while in the late 90s, and it really was a great company, with by far the best tech-company culture I've ever encountered...)
- erichocean 4y agohttps://oxide.computer/ https://oxide.computer/
- krackout 4y agoI share the same feelings for Sun, mourned when it was bought by Oracle.
- andrewshadura 4y agoBack in my university student days, I wrote a pair of a compiler and an interpreter: the compiler accepted a language that looked like a mix of Oberon and Perl (I called it pıpl, from "pıpl isn't a programming language"), it produced Forth-like output, and then the interpreter ran it. The compiler was written in C+bison+flex, the interpreter was in Object Pascal. Unfortunately, the sources didn't survive.
- frr149 4y agoWhat is a good modern Forth to play around with? Is it still used im some industry?
- stevekemp 4y agoI've mostly only come across in-house tools that have been inspired by FORTH, or used it as an embedded language for company back-end tools. I suspect gforth is the most common way to get started. Though it has to be said more people probably write forth-interpreters than write serious code using the actual language. Embedded use might be one of the rare exceptions, as it can be used to give a very lightweight environment.
- timonoko 4y agoThis is always annoying to read as they wasted ")" to some shit. "(" should be: Push next word to X-stack ")" should be: pop and execute top of X-stack. So "(+ m n)" is equal to "m n +" And "(IF (< A B) (THEN C ELSE D)))" == "A B < IF C ELSE D THEN"
- timonoko 4y agoIF-sentence was totally wrong. Per se. (IF (< A B)) (THEN C ELSE D) looks about right. This is about readability, all else stays the same. You can avoid the minute overhead of "(" by not using it on a critical situation.
- shadowofneptune 4y agoI am not sure what you mean. "(" and ")" as their own words form comments in Forth. As an example: (if (< a b) Would be parsed completely differently from: ( if ( < a b ) The first will have the interpreter look up and execute the words "(if", "(<", "a", and "b)". The second will have the interpeter look up the word "(", which will skip all the text that comes before a ")".
- timonoko 4y agoOf course we fix the parser too, so that ( and ) are always separate. Otherwise too ugly.
- flohofwoe 4y agoLooks like Lisp, ugh ;) I guess Polish Notation wasn't as uncommon in the 70's as it is today, AFAIK pocket calculators used this too. And once you switch your mind over it feels just natural.
- b112 4y agoAnd once you switch your mind over it feels just natural. Yet what if the result is, your mind has become unnatural? !!!
- gardenfelder 4y agoI discovered Forth when building weather stations with an 1802 8-bit cmos processor; there was a tiny assembler language for it for making games which I adopted to a simple stack-based interpreter, and then I discovered Forth by way of a Byte Magazine piece on it. I started attending Forth meetings in the Bay Area where it was clear I knew from nothing about it, even though I had something similar running. So, I got a set of 8080 assembler codes for Forth and transliterated that to 1802 and the rest is history. From there, I put Forth on an Apple II and found a magazine article which disassembled the graphic and math routines from the Apple Rom; my friend Dan Wood used that to create for us "SciForth" a Forth which did all the math and graphics necessary to analyze data and present it from our weather stations, which, at that time, were being used to locate wind power systems, and for fruit frost prediction in California's central valley. In the long run, I continued down that path by writing inference engines in Forth. It's a clean and solid ecosystem. Even today, I think about returning to Forth to see how far I can push it.
- markus_zhang 4y agoI wonder what people are doing with Forth professionally these days. I see a lot of hobbyist projects such as porting Forth to a board which is definitely very fun and educational, but not sure what professional Forth looks like. Back in the day people used Forth for programming microprocessors. Are they still doing this?
- adastra22 4y agoDoes bitcoin script count? Or Postscript?
- astrobe_ 4y agoFrom what Forth, Inc. and MPE tell about their projects and customers, it seems indeed to be micro-controller focused, but extends sometimes to the desktop. For instance Forth, Inc. talked about a cold storage facility ("a fridge as big as a warehouse") for which they did both the code for the small temperature control devices and the facility monitoring graphical front-end (PC).