7 ms·
A different Forth I enjoy to hobby code puzzles in is [Factor](https://factorcode.org/ https://factorcode.org/) and is probably an easier place for people to st
by Pet_Ant 6y ago
A different Forth I enjoy to hobby code puzzles in is [Factor](https://factorcode.org/ https://factorcode.org/) and is probably an easier place for people to start. Forths are wonderful languages that everyone should have some exposure to, they are like a cross of Lisp and Smalltalk. You should definitely try it at least once.
- zoltar 6y agoI think this tech talk on Factor offers a pretty good tour of the language. https://www.youtube.com/watch?v=f_0QlhYlS8g https://www.youtube.com/watch?v=f_0QlhYlS8g
- jonahx 6y agoIf my aim was just to learn, what would be the advantages and disadvantages between gforth, retroforth, and factor?
- 7thaccount 6y agoI did not find gforth or factor to be very easy to get up and running with. If you want to learn forth concepts, you can build one yourself easily in any language (lots of examples), but Assembly or C are the most idiomatic as they allow you to get to a much lower level. Every forth system is different, but they share a lot of design fundamentals. There are almost too many to count. If you're okay with closed source, 8th has a very nice free version if you just want to get a hang of writing forth code in it. I usually recommend that one check out 8th as it comes with all the niceties of modern scripting languages and can cross-compile to a lot of systems, has GUI support, bluetooth, iPhone/Android, modern data structures, database support...etc. It's also a bit confusing that most Forth systems were traditionally for embedded work. There are a few commercial offerings (SwiftForth and VxForth) for that. It used to also be extremely common to bootstrap new hardware with Forth as you got a full REPL so you could interactively interact with the hardware and test out each piece before a compiler like C could be ported to the system. I'm not sure how common that is now, but there are a lot of Forth systems that are pretty barebones compared to modern languages. You have to look around.
- sigjuice 6y agoEvery forth system is different, The joke is that if you have seen one Forth system, you have seen one Forth system :)
- Pet_Ant 6y agoFactor is higher level with built-in support for lambdas (called "quotations") and a garbage collector and a ready made library. If traditional Forths are like C than Factor is like C#. You'll still get many of the same concepts but without the low-level friction that'll hamper you making fun things.
- megameter 6y agoProbably the most straightforward thing to do is to learn and implement your own based on an early Forth like FIG Forth or Forth 83: http://www.forth.org/fig-forth/contents.html http://www.forth.org/fig-forth/contents.html http://forth.sourceforge.net/standard/fst83/ http://forth.sourceforge.net/standard/fst83/ There are certain cosmological nuances of Forth that come through by the time you get to where you have bootstrapped IF ELSE - and while later Forths add more features(which is great for production uses) they aren't the essence of Forth, which is in the minimalism. Factor is also so much different that it deserves another category, despite syntactic resemblance.
- crc_ 6y agoA few comments follow; note that I'm not unbiased :) RetroForth is smaller and easier to build than gforth or Factor. I actively use it and seek to improve it, and I've been told the documentation is good, though I still feel I have a long way to go on that front. It's not a traditional Forth, but it works well for me. I borrow things from traditional Forth, colorForth, Factor, 8th, and other languages when I think they make sense for my needs. Releases are quarterly, with daily snapshots provided. Gforth is big and I find it to be difficult to build from source. If you need or want a traditional/standard Forth, it's probably what I'd recommend if using one of the commercial ones isn't an option. Definitely build it from source though; the releases are infrequent and the development versions have a lot of bug fixes and improvements. Factor is big, has lots of interesting stuff, but apart from stacks and colon decisions, really doesn't feel like Forth to me. It is under active development, but releases other than snapshots are very infrequent (last in 2018). Building from source isn't something I've done with this in years, and platform support is more limited (Linux, Windows, macOS, on x86 or x86-64). I've borrowed some ideas and terminology from Factor over the years and would consider it worth learning from.
- fouc 6y agoI would describe retroforth as a traditional forth (i.e. on the traditional chuck moore forth path), and gforth as a standard (ansi standard) forth
- chalst 6y agoI recommend studying a simple Forth implementation. rwmj wrote a tutorial/x86 implementation, now widely called Jonesforth: Main x86 source to bootstrap minimal interpreter/compiler: https://github.com/nornagon/jonesforth/blob/master/jonesforth.S https://github.com/nornagon/jonesforth/blob/master/jonesfort... Further Forth definitions: https://github.com/nornagon/jonesforth/blob/master/jonesforth.f https://github.com/nornagon/jonesforth/blob/master/jonesfort... rwmj gave some background in comments on the HN story: https://news.ycombinator.com/item?id=10187248 https://news.ycombinator.com/item?id=10187248
- dreamcompiler 6y agoThe difference is that Forth compilers can be bootstrapped from not-very-much assembler on an embedded system. That's not really true for Lisp and Smalltalk. Forth impresses me because of the degree of leverage that bootstrapping process affords for small computers.
- Pet_Ant 6y agoForth is sort of live image like Smalltalk, and great for designing languages/DSLs in like Lisp which is also homoiconic.
- lhorie 6y ago> Forth compilers can be bootstrapped from not-very-much assembler Do you have any resources handy on how one could do that from scratch?
- naters 6y agoJonesforth [1] is a classic example of this, and a really good example of “literate” code. [1] https://github.com/nornagon/jonesforth/blob/master/jonesforth.S https://github.com/nornagon/jonesforth/blob/master/jonesfort...
- benhoyt 6y agoA good learning resource is Jonesforth (something of a classic), on GitHub here: https://github.com/nornagon/jonesforth/blob/master/jonesforth.S https://github.com/nornagon/jonesforth/blob/master/jonesfort... I wrote several Forth compilers when learning to code as a teenager, one using the A86 assembler, and two fully bootstrapped-from-assembler ones for 8086 and 386. The 8086 source code is here (I didn't write the assembler myself): https://github.com/benhoyt/third https://github.com/benhoyt/third (KERNEL.F has the assembler parts)
- ampdepolymerase 6y agoThere is also https://github.com/kragen/stoneknifeforth https://github.com/kragen/stoneknifeforth
- fmakunbound 6y agoI think Factor is too high level to give you an impression of Forth. A multitasking, stand-alone Forth, with an optimizing compiler and assembler is something an average programmer can reasonably implement for themselves. The whole thing will definitely fit in your head, as well as your L1 cache.
- tailrecursion 6y agoPeople interested in learning what Forth is all about could examine Chuck's cmForth. Both its metacompiler and the Novix chip (or RTX 2000, both versions may exist) are pretty interesting.
- lebuffon 6y agoAnd for those interested in an FPGA version with similar features, check out the J1 and J1B (32 bit) CPUs by James Bowman. Remarkable machines in 200(ish) lines of Verilog.
- TurboHaskal 6y agoBesides the syntax, Factor is way closer to Smalltalk and Common Lisp than to Forth.