9 ms·
Starting Forth – the classic Forth language tutorial
- synchronise 13y agoThis combined with JS-FORTH allows a person to learn and test examples without having to download any extra software. http://forthfreak.net/jsforth80x25.html http://forthfreak.net/jsforth80x25.html
- RodgerTheGreat 13y agohttp://repl.it/ http://repl.it/ has a JS-Forth mode with a somewhat nicer interface- I often use it when tinkering from an office machine or public computer.
- amasad 13y agoCoincidentally, I was just updating the editor on repl.it and added Forth syntax highlighting mode.
- jyf1987 13y agothere is jeforth running on js and have canvas support http://www.jeforth.com http://www.jeforth.com
- Pitarou 13y agoAlways wanted to study Forth! :-)
- robomartin 13y agoI love Forth and used it extensively for many years. I wonder how much real use it is seeing today. I remember a situation many years ago where a friend of mine chose to code his embedded product in Forth. As the company grew it became difficult to find programmers. As things got to the point where acquisition started to become a possibility Forth became a liability. He had to convert the entire code base to C in order to remove objections. I pitched in and helped with the effort. While it wasn't terribly difficult it did take time and cost money. That experience probably marked the last time I used Forth on an embedded system. Every time I considered the idea for my own work I remembered what happened to him. As a result I pretty much stayed with C/C++ for embedded work from that point forward. My gut feeling is that today Forth is a liability for most applications outside cases where there might be an existing code base that must be leveraged. EDIT: I still think it is important for programmers to learn about TIL's and Forth. You'd gain valuable perspective and a different way to see and approach problems.
- voltagex_ 13y agoAlthough it didn't sell well, the WikiReader [1] ran Forth. [1] http://yannramin.com/2009/10/16/the-wikireader-cool-device-future-hackability/ http://yannramin.com/2009/10/16/the-wikireader-cool-device-f...
- dvdkhlng 13y agoThe WikiReader does have a Forth interpreter embedded in its firmware, but doesn't run it by default. It is activated when pressing the right buttons at boot and allows developers to access a Forth console via serial debug-cable and/or compile Forth programs from Forth sources contained in the built-in micro-SD card. As Forth is very low-level and allows direct access to memory (and thus memory-mapped registers), it makes testing hardware quite efficient (and fun). What makes you believe the WikiReader didn't sell well? AFAIR quite the opposite.
- synchronise 13y agoJust reading this topic, turns out you can grab this for $11.99 + p&h from Amazon. http://www.amazon.com/WikiReader-WR-01-Pocket-Wikipedia/dp/B002N5521W/ http://www.amazon.com/WikiReader-WR-01-Pocket-Wikipedia/dp/B... I'm actually considering getting one of these for that price, would be an interesting device to tinker with FORTH.
- bcoates 13y agoStories like this always astound me. Learning Forth is probably less difficult than the average GUI widget library. Anyone who I'd trust around a C compiler could probably become a serviceable Forth coder in a weekend. Do moderately bright kids not get exposed to HP RPN calculators anymore?
- coolsunglasses 13y ago>Do moderately bright kids not get exposed to HP RPN calculators anymore? No, they learn BASIC (maybe) on the TI graphing calculators.
- jacques_chester 13y agoI have what I believe is a first edition. I grabbed it from the giveaway pile at my university, thinking it was not the kind of book you could buy anymore. Great to see it online.
- gngeal 13y agoScan it and post it! Some of us love old time typography.
- liyanchang 13y agotl;dr Forth is a programming language from the 1970s. This is the canonical book, published by someone who works at Forth Inc. (as K&R is to C) Forth is interesting, not because of widespread usage, but because it has a different way of looking at things. Reminiscent of people who tell you that you should learn LISP because you'll never use it, but it will make you a better programmer. The key difference is that it is stack based. (For those who are more mathy, you may have heard of RPN on the HP calculators) e.g. 2 5 * 3 - is take 2 and 5, multiply them. Take the result and 3, subtract them. get 7. The wiki article has a nice picture of stacks that may help: http://en.wikipedia.org/wiki/Forth_(programming_language) http://en.wikipedia.org/wiki/Forth_(programming_language) (btw, not super knowledgable about this stuff; just super confused, did some digging and figured others would be confused as well. Happy to edit.) EDIT 1: Habits die hard. Corrected Fourth to Forth.
- deleted 13y ago[deleted]
- zaf 13y agoI've just recently started to dig into stack-based programming languages and would love to get hold of the Leo Brodie manuals. One question to programming language experts: Is it possible to have a stack-based programming like forth but without the need for the extra characters needed in the syntax (like quotes, brackets etc..) and only use whitespace to separate the 'words'?
- dvdkhlng 13y agoStack-based programming does not need extra syntax characters (what you call quotes and brackets) to structure the program. arithmetic syntax: (a+b)*c lisp syntax (polish notation): (* (+ a b) c) forth syntax (reverse polish notation): a b + c * In fact all words in Forth are only separated by whitespace. However, to "emulate" more complex syntax, some words in Forth are marked to be executed immediately upon parsing (somewhat like "macros" in lisp) and then access the input stream to extract more than whitespace-separated tokens. Exampes: '(' parses comments : ( comment) 's"' compiles string literals : s" abc" '[if]' conditionally skips code fragments: 0 [IF] bla [THEN] Still the macro word itelsf needs to be whitespace-delimited.
- zaf 13y agoAh, so you mean that certain words can not only look at the stack but also look at manipulate the input word stream. Thanks for the explanation. I really ought to do a practical session with Forth.
- dvdkhlng 13y agoThere are various levels of abstraction when accessing the input stream. The lowest level is by inspecting the input (line) buffer. Just realized how that allows one to write a three-word quine [1] in ANS-compliant Forth: SOURCE TYPE BYE [1] https://en.wikipedia.org/wiki/Quine_%28computing%29 https://en.wikipedia.org/wiki/Quine_%28computing%29
- draegtun 13y ago>re: ... and only use whitespace to separate the 'words'? Have a look at Rebol which is a mix of Forth, Logo & Lisp. Here's an example of Rebol code (typed into the console (REPL))... >> multiply add 1 2 3 == 9 multiply and add are both functions which take two arguments. If I add parens then above becomes clearer. >> multiply (add 1 2) 3 == 9 So Rebol evaluates a list of words from left to right with non-variadic functions (ie. they have fixed argument arity). Here's an example of a conditional: >> if equal? 1 1 [print "1 is 1!!"] 1 is 1!! if is a function which takes two arguments (as is equal?). So this is code is evaluated like this: >> equal? 1 1 == true >> [print "1 is 1!!"] == [print "1 is 1!!"] If the first argument is true (which it is in this case!) then the second argument (which is a block) is evaluated... >> do [print "1 is 1!!"] 1 is 1!!
- rwmj 13y agohttp://git.annexia.org/?p=jonesforth.git;a=tree http://git.annexia.org/?p=jonesforth.git;a=tree Start with 'jonesforth.S'
- fizfaz 13y agoJust wanted to mention that Thinking Forth "A Language and Philosophy for Solving Problems" (also from Leo Brodie) is available here: http://thinking-forth.sourceforge.net http://thinking-forth.sourceforge.net I learned a lot from this book.
- bjz_ 13y agoFactor is another interesting concatenative programming language (inspired by Forth): http://concatenative.org/ http://concatenative.org/ I've been playing around with it for the past few days and found it to be very well documented. Well worth a look if you're looking for something to bend you mind in new ways!
- ggchappell 13y agoI like Factor a lot. Forth has always struck me as something with potential; but, alas, it's stuck in the 70s. Data structures are painful. You can forget about anything like generics, polymorphism, interfaces, etc. It supports functional programming poorly. It fails to benefit from modern ideas about modules/namespaces or type systems that stay out of your way. And there is no protection from anything at all. When I look at Factor, I find myself thinking, "This is what Forth should have been." So, yes, Factor is worth a look. Certainly as a mind-expander, and possibly as a practical production language (just guessing here).
- jim_lawless 13y agoHere's a list of some other free books on Forth and stack-machines. http://www.linuxlinks.com/article/20130618144353106/InvaluableForthBooks.html http://www.linuxlinks.com/article/20130618144353106/Invaluab...
- bjpcjp 13y agoMy first job after grad school with at Harris Semiconductor. We were selling RTX processors which natively ran Forth instructions. (The architecture was completely stack-based.) I agree that Forth is a liability today. I could see it being used as an introductory language - in junior high school, for example - but not much beyond that.
- tikhonj 13y agoI've always wanted to write a Forth tutorial just to take advantage of all the "forth" puns that come to mind. I could call it "setting Forth" :). Seriously though, I could probably write something interesting about ArrayForth and GreenArray chips--I've been playing around with them for a while and even wrote an emulator for their instruction set. Yet another topic in the queue for my blog, which doesn't even exist yet :P.