10 ms·
FORTH is a fun little class of languages. These are easy to implement; in a few KB you can have a working development environment, with a screen editor, debugge
by kabdib 5y ago
FORTH is a fun little class of languages. These are easy to implement; in a few KB you can have a working development environment, with a screen editor, debugger and whatnot.
In my experience, FORTH doesn't really scale to big projects, or things that need a lot of dynamic allocation. It's great at low-level stuff like hardware bringup (we used it on the Atari ST, back in the day, and even the hardware engineers were writing code to exercise their designs), but doing anything at scale is going to be tough. You probably don't want to write a modern web server platform in it, for instance. But it's probably great on an Arduino with a serial port.
There were a lot of games started at Atari in FORTH ("Hey, this is simple! Who needs to hire expensive assembly language programmers?") but the only project that shipped was the pinball machine "Four by Four". I saw a bunch of expensive disasters and mostly steered away from it.
- NieDzejkob 5y agoThis reminds me of this video on a text processing example with Forth: https://www.youtube.com/watch?v=mvrE2ZGe-rs https://www.youtube.com/watch?v=mvrE2ZGe-rs
- bluedino 5y agoWeren’t some 7800 games written in Forth?
- kabdib 5y agoLooks like a few were: https://atariage.com/forums/topic/155951-games-written-in-forth/ https://atariage.com/forums/topic/155951-games-written-in-fo... These were written by third parties and published by Atari. Atari did not have any game programmers on the payroll at that point (all the software folks were working on the ST and related things). There might have been some contracting going on, but the days of an Atari employee coming up with a new game idea and shipping a new cartridge were gone.
- dingosity 5y agoWorms? was a FORTH jam, or at least that's what David Maynard said in a recent interview (since it seems this thread is becoming a list of FORTH games.)
- _0ffh 5y agoYes, the source is available here: https://github.com/savetz/worms https://github.com/savetz/worms
- perl4ever 5y agoI associate Forth with astronomy.
- ollran 5y agoThere is a list of Forth projects used in NASA missions. https://www.forth.com/resources/space-applications/ https://www.forth.com/resources/space-applications/
- praptak 5y agoDon't you mean Fortran?
- rscho 5y agoForth was originally thought of as a "fourth generation" language when Chuck Moore designed it while doing astronomy research.
- macintux 5y agoW. Richard Stevens wrote an early primer on Forth for Kitt Peak. http://forth.org/tutorials.html http://forth.org/tutorials.html
- lebuffon 5y agoSurprise. Fortran was used as well but Forth was used quite a bit by NASA. In some ways it is extremely auditable. A handful of assembler functions sit at the bottom the rest is Forth. Minimal numbers of variables in memory if code is written to use the data stack for inputs and outputs to functions. Much easier to certify than GCC. :-) There were a number of Shuttle experiments where the control software was written in Forth. It gives you a control interpreter out of the box and also bit level access to hardware so you can write custom drivers and then script the hardware control in the functions you wrote or compile them where speed is required, using an 8K..12K kernel. The Cassini probe used Forth software running on a Forth 2-stack CPU.
- perl4ever 5y agoNo, and I didn't mean spaceflight either. Which Forth was apparently used for but I didn't recall until I googled it. I associate Fortran with nuclear reactor engineers. I was told they were some of the earliest users of it, maybe even before it was out of "beta", so to speak. Quote from 1955: "Considerable effort is now being made by various groups to develop automatic coding techniques which would make the use of a large machine feasible on this kind of problem. The system of greatest interest is Fortran, which is being set up by IBM for the 704; there is some chance that it will be available by the end of the year. To use it, the engineer who is setting up the problem must formulate it in a somewhat modified algebraic notation, which is then entered directly in the machine. As a result, the task of stating detailed machine orders and assigning addresses, which is largely a clerical task and constitutes most of the work of coding, is completely eliminated. Some scepticism has been expressed by experienced programmers, on the grounds that the resulting code would be far less efficient than one designed by hand. Even if this is the case, however, a system of this kind will still have a wide range of applicability in reactor analysis and should be kept in mind in considering future machine work."
- o8r3oFTZPE 5y agoTwo ways to "scale". Up or down. FORTH scales down. Interesting how developers today impicitly assume the term "scale" mean "scale up".
- astrobe_ 5y ago"scale up" is usually used as a counter-argument to a solution that is perfectly fitted to the scale it is supposed to be used. This is nothing but a salesmen argument. It is not only in the Forth community that one hears disaster stories like: we did the software for client X in 3 weeks with a team of 4 programmers, but after a few decades they lost the know-how of our language so they decided to rewrite in a "modern" language that "can scale". They hired a team of 40 developers, it took 3 years, and the result is less reliable than the original. The only thing that scaled up were the development and maintenance costs and the only thing that was modernized is HR policy (i.e. let's hire disposable developers).
- thesz 5y agoIf you need dynamic allocation, you can invent a Forth dialect for your specific needs. And implement it in Forth. A domain-specific language for your problem domain, embedded in Forth. Consider control statements like conditionals or loops. They are implemented in Forth to express what is essential for imperative programming. You can just as easily implement region handling much like what Cyclone [1] did. Invent region, dispose region, allocate within region, etc. You can augment semicolon word to not only check for control statements to be valid, but also check for region handling correctness. [1] https://en.wikipedia.org/wiki/Cyclone_(programming_language) https://en.wikipedia.org/wiki/Cyclone_(programming_language) Of course, you have to be either well educated or highly inventive to do that. ;) And at the time of Atari most of programming projects were expensive disasters, not only games written in Forth.
- DonHopkins 5y agoFrom https://news.ycombinator.com/item?id=21823081 https://news.ycombinator.com/item?id=21823081 I wrote malloc.fth for Mitch Bradley's ForthMacs, which ended up in OpenFirmware: https://github.com/openbios/openfirmware/blob/master/ofw/core/ofwcore.fth#L3453 https://github.com/openbios/openfirmware/blob/master/ofw/cor... \ Forth dynamic storage managment. \ \ By Don Hopkins, University of Maryland \ Modified by Mitch Bradley, Bradley Forthware \ Public Domain \ \ First fit storage allocation of blocks of varying size. \ Blocks are prefixed with a usage flag and a length count. \ Free blocks are collapsed downwards during free-memory and while \ searching during allocate-memory. Based on the algorithm described \ in Knuth's _An_Introduction_To_Data_Structures_With_Applications_, \ sections 5-6.2 and 5-6.3, pp. 501-511. Forth systems running on C libraries can also call back to the native malloc/free implementation, but it's nice to have a pure FORTH implementation for embedded applications.
- svat 5y agoThis may be a tangent but I've encountered this code comment before and been confused; nice to be able to reply to its author! The confusion is that there's no book by Knuth called "An Introduction to Data Structures With Applications" (and Knuth's TAOCP doesn't have a section 5.6; his Chapter 5 on Sorting ends with 5.5 and whatever stuff is in TAOCP about memory allocation is Chapter 2; page 501 would put you in "Answers to Exercises"). Most likely what was intended is the book "An Introduction to Data Structures With Applications" by Jean-Paul Tremblay and Paul G. Sorenson (https://www.amazon.com/dp/0070651574 https://www.amazon.com/dp/0070651574 , ISBN 0070651574, https://books.google.com/books?id=ha4mAAAAMAAJ https://books.google.com/books?id=ha4mAAAAMAAJ) which from what I can find online has 7 chapters: 1. Information and its storage representation 2. The representation and manipulation of strings 3. Linear data structures and their storage representation 4. Linear data structures and their linked storage representation 5. Nonlinear data structures 6. Sorting and searching 7. File structures And so Chapter 5 probably has a 5–6.2 and 5–6.3 that cover such a memory allocation algorithm. Edit: I found a weird plagiarized/condensed version of the book online, and section 5.6 is indeed called "Memory Allocation; Garbage Collection", so quite likely that the book by Tremblay and Sorenson is what is meant.
- guenthert 5y agoForth on Atari w/o mentioning https://atari8bit.net/db/?d=cd&g=Books&f=FORTH-on-the-Atari-Learning-by-Using-1982Hofacker https://atari8bit.net/db/?d=cd&g=Books&f=FORTH-on-the-Atari-... Yep, those were the times. FORTH is all fun and such (well, the stack counting gets old after a while), but I have difficulties seeing it in larger, multi-person projects (were there any?). A good idea who's time came and went.
- chalcolithic 5y agoI hope I'm not breaking any rules by saying that I enjoyed your blog immensely over the years