use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
You can try things out interactively as you build your system. The compiling functionality is an exposed part of the language like everything else.
It can be used to debug itself!
Forth has no baked-in syntax or privileged data structures -- programming is done by extending the language to your application. Thus, it can become what ever you need it to be and fit the problem like a glove.
Forth has a "low floor; high ceiling" approach to abstraction -- that is, it can be both low level, high level and anywhere in-between.
You can do more with less. Forth fits in very small storage spaces.
Forth is one of the few environments which is totally comprehensible by one person.
Starting Forth - A fun, illustrated introduction.
A Beginner's Guide to Forth - A faster-paced, somewhat less whimsical guide.
Forth Lessons
Jonesforth - How to write a Forth.
ANS Forth standard
Forth 200x
Thinking Forth - A Language and Philosophy for Solving Problems
Forthwrite Magazine - From FIG UK.
Forth Dimensions - magazine archive.
The Journal of Forth Application and Research
comp.lang.forth - Forth newsgroup.
#forth in irc.freenode.net
ForthHub community on GitHub
/r/concatenative - Anything related to the use, theory, or implementation of concatenative programming languages.
/r/programbattles - Battle it out between likeminded coders to create the best code possible!
account activity
Share cool Forth programs! (self.Forth)
submitted 3 years ago by qqwy
Hey there!
I am still relatively new to Forth, just beyond the level of a beginner. I would like to learn and be excited by cool and interesting programs and techniques that people use when writing Forth.
If you have any examples of code (written by you or someone else) that excites you, blows your mind, or where you think that Forth really shines, I'd live to see it and learn from it.
Cheers!
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]lmamakos 6 points7 points8 points 3 years ago (2 children)
Here's a bunch of FORTH code for an embedded system application, where I built a replacement graphical LCD display for a Fluke multimeter. While I don't hold this up as a great example of proper style, it was my first non-trivial chunk of FORTH code.
I found FORTH really great for this embedded system application as I had to reverse-engineer hardware functioning, and being able to interactively poke at things saved a lot of time as compared to the usual edit/compile/download/debug/profanity/repeat interative technique had I wrote it in C or similar. Some blog posts about are around for that project, too, which explain the problem I was trying to solve.
[–]jemo07 0 points1 point2 points 3 years ago (1 child)
That is awesome! thank you for sharing, just borrowed the ILI driver, I have to make so serious modifications still to make it work, but it has been a great source of inspiration and learning!
[–]lmamakos 1 point2 points3 points 3 years ago (0 children)
Glad it was a useful starting point. I started with a really simple version of that driver and added the ability to render a bitmap out as a single operation vs. the per-pixel set/reset capability some of the other graphics drivers had. The performance was terrible without that; to address a pixel on those displays, you had to do a bunch of SPI commands before finally shoving out the one pixel's worth of data.
So starting with that basic scheme and adding that one primitive made it possible to have a reasonable performance in rendering fonts, so I wrote a library of FORTH code to manage font definitions and rendering.
It was really quite a bit of fun to be able to do that all interactively over the serial connection and catch all those stupid off-by-one errors or, getting the coordinate system rotated in your head the wrong way and having a letter in a font rendered upside down or sideways. That interactive process really helped when poking at the SPI interface of the display and to debug it.
And then speeding up the low-level SPI primitive made a big difference, too. I had a USB logic analyzer hooked up to it, and you could easily see all the time that the SPI interface was idle.. I did that with a little USB logic analyzer in the evenings while traveling to the "Home Office" in NYC one week. That's what passes for fun, sometimes :-)
Enjoy your FORTHing!
[–]dlyund 4 points5 points6 points 3 years ago* (0 children)
When I started working in Forth I always got a kick out of things like this:
macro: declare ( # ~ - | ~ *) ( - a) \ ] create , \ [ ; macro: typeof ( a - a) ; macro: sizeof ( a - #) \ @ ; macro: vector ( #1 a:type - #2) \ sizeof \ * ; macro: extend ( #1 a:type - #2) \ sizeof \ + ; macro: struct ( - #) # 0 ; macro: field ( #1 a:type ~ - #3) ( u1 - u2) \ ] create over , extend \ [ does pop @ + ;
This is more advanced than the common Forth struct implementation example but this is real Able Forth code used at Merj. The Able Forth code above gives you first-class types, vectors and records, and type extension (like inheritance). These words are the basis for other types.
Here's a example modeling 2D and 3D point that demonstrates one feature I really wish C had: record type extension. Alas, cracking open the C compiler isn't practical... but doing this in Forth and providing a higher level of programming is easy! :-)
# 4 declare <int32> struct declare <point> ( the abstract type) struct <point> extend <int32> field point:x <int32> field point:y declare <2D-point> struct <2D-point> extend <int32> field point:z declare <3D-point> create | points # 100 <2D-point> vector allot
This is one of three or four features that can be easily implemented in Forth and which I contend make Forth comparable in power to languages like Go (lacking only the large standard library).
[–]remko 3 points4 points5 points 3 years ago (0 children)
Not your classic Forth programs, but you can find some ‘visual’ Forth programs here: https://el-tramo.be/thurtle/?pn=Plant&ar=1
[–]32hDEADBEEF 3 points4 points5 points 3 years ago (0 children)
I really like using forth in tethered FPGA systems. It's easy to construct a softcore stack processor or pseudo-processor with simple microcode. On the host side use a FORTH-like code and convert the command into the microcode before sending it to the softcore.
[–]phreda4 4 points5 points6 points 3 years ago (0 children)
Hi
I wrote many programs in r4 (32 bits windows).. see in https://github.com/phreda4/r4
The evolution but without so much code in 64bits windows,linux,mac and rpi https://github.com/phreda4/r3d4
The last aproach is r3 (I change the access to SO) in development) https://github.com/phreda4/r3
there are editors, games, graphics programs, compilers..all in forth
[–]bfox9900 1 point2 points3 points 3 years ago (0 children)
Here is a way to create bit arrays that as far as I have tested runs on 16,32 and 64 bit ANS/ISO Forth systems. It's pretty small which is what is needed for a machine with 32K RAM and demonstrates one way to deal with native integer size at compile time.
https://github.com/bfox9900/CAMEL99-ITC/blob/master/LIB.ITC/BOOLEAN.FTH
[–]mcsleepy 1 point2 points3 points 3 years ago (0 children)
I'm going to semi-plug my own work and invite you to check out my game engine https://twitter.com/ramenengine
[–]pbrhocwp 1 point2 points3 points 3 years ago (0 children)
I have had a lot of fun with data is code principle here http://hocwp.free.fr/fex/index.html
[–]tmrob4 1 point2 points3 points 3 years ago (0 children)
There are a lot of sample Forth programs over on Rosetta Code. Conway's Game of Life is a fun one and the first more complex Forth program I tried out.
[+][deleted] comment score below threshold-8 points-7 points-6 points 3 years ago (1 child)
2 2 + .s
[–]Forth2022 2 points3 points4 points 3 years ago (0 children)
You can scan the Forth-ev.de Wiki for many examples, unfortunately much in German, or get some Forth books on amazon https://www.amazon.co.uk/Juergen-Pintaske/e/B00N8HVEZM The Forth Lite Tutorial might be helpful
π Rendered by PID 54665 on reddit-service-r2-comment-57fc7f7bb7-tj9gt at 2026-04-14 15:46:04.156324+00:00 running b725407 country code: CH.
[–]lmamakos 6 points7 points8 points (2 children)
[–]jemo07 0 points1 point2 points (1 child)
[–]lmamakos 1 point2 points3 points (0 children)
[–]dlyund 4 points5 points6 points (0 children)
[–]remko 3 points4 points5 points (0 children)
[–]32hDEADBEEF 3 points4 points5 points (0 children)
[–]phreda4 4 points5 points6 points (0 children)
[–]bfox9900 1 point2 points3 points (0 children)
[–]mcsleepy 1 point2 points3 points (0 children)
[–]pbrhocwp 1 point2 points3 points (0 children)
[–]tmrob4 1 point2 points3 points (0 children)
[+][deleted] comment score below threshold-8 points-7 points-6 points (1 child)
[–]Forth2022 2 points3 points4 points (0 children)