5 ms·
As much as I love Forth, I am a bit troubled by the list in the article: Some interesting but by no means complete Forth properties: no errors no file
by protomyth 8y ago
As much as I love Forth, I am a bit troubled by the list in the article:
Some interesting but by no means complete Forth properties:
no errors
no files
no operating systems
no syntax
uhm... Forth does have errors like Stack Underflow. When I programmed in Forth we did have the notion of files. It most certainly does have a syntax also.
- mruts 8y agoPeople talk about forth having no syntax the same way people talk about lisp having no syntax: not entirely correctly. Of course, every textual representation of anything has a syntax, but when people talk about something not having a syntax what they really mean is that the syntax is uniform: there is only one global (uniform) syntax.
- benj111 8y agoI've always interpreted it as a lack of keywords etc. Both lisp and forth can be built up from a small number of primitives. Everything you use day to day is basically optional.
- MrEldritch 8y agoYeah, there's "no syntax" in the sense that you could adequately describe the syntax rules on a Post-it.
- boomlinde 8y ago> there is only one global (uniform) syntax. While I agree with the general sentiment that Forth does have a syntax, this statement is not true in Forth. Instead, syntax is extremely local, because words may take over the parser and compiler to implement their own syntax. For example, "(" (which is used for comments) is typically implemented as a word that immediately executes during the compilation phase, takes over the input loop and just reads and discards characters until it has discarded the matching ")" character before returning control to the regular compiler. It has its own little parsing loop going on with its own syntax, totally overriding any global syntax for as long as it feels like.
- bunderbunder 8y agoI'd argue that Lisp has a syntax in that you do need at least a context-free grammar to describe valid Lisp programs. With Forth, on the other hand, while there is a rule for deciding when one word ends and another ends, and how to interpret literals, I think that, for all practical purposes, there aren't actually any strings that are syntactically invalid. As the ANSI Forth standard puts it: > This Standard does not require a syntax or program-construct checker. (page 33)
- madhadron 8y ago> there is only one global (uniform) syntax. Not quite. You have access to the reader in Forth, and it's quite typical to write a word that takes over for the reader for some time and then hands back to the usual reader. Julian Noble used this to implement a subset of FORTRAN for computational physics (more convenient than postfix for doing that) and to make state machine transition tables into code. Sadly, he is no longer with us. Common Lisp also provides access to the reader, so you can do the same trick, but it's not a ubiquitous thing to do the way it is in Forth.
- delish 8y agoThat list is probably inspired by Chuck Moore's article "1% the Code" https://web.archive.org/web/20060104084410/http://www.colorforth.com/1percent.html https://web.archive.org/web/20060104084410/http://www.colorf... Relevant excerpt: >colorForth does it differently. There is no syntax, no redundancy, no typing. There are no errors that can be detected. Forth uses postfix, there are no parentheses. No indentation. Comments are deferred to the documentation. No hooks, no compatibility. Words are never hyphenated. There's no heirarchy (sic). No files. No operating system. He probably means "blocks" instead of files and "a condition system or exception system" instead of "stack underflow."
- agumonkey 8y agohas moore written books or articles ?
- dang 8y agoThere's this classic, at least: https://colorforth.github.io/POL.htm https://colorforth.github.io/POL.htm https://hn.algolia.com/?sort=byDate&dateRange=all&type=story&storyText=false&prefix=false&page=0&query=problem%20oriented%20language%20points%3E3 https://hn.algolia.com/?sort=byDate&dateRange=all&type=story...
- agumonkey 8y agodank u
- 4thaccount 8y agoSafari online has a lengthy interview with him that is an excerpt from a book with lots of interviews on programming Titans. I read the one from Moore every year and I don't even write Forth. It is simply that good and thought provoking.
- elisharobinson 8y agoyes I read it once and it genuinely is the stuff to start cults
- Someone 8y agoTraditional forth has blocks each 1k in size, n≥1 buffers that each can hold a single block, and words - BLOCK: reads an individual block, returns address where it was loaded. - UPDATE: marks most recent block as dirty. - FLUSH: writes out all dirty blocks. ANSI forth (I think) added EMPTY-BUFFERS, which marks all blocks as not-dirty. If you wanted more, you could implement a file system on top of that. Example usage at http://wiki.c2.com/?ForthBlocks http://wiki.c2.com/?ForthBlocks (includes a full-screen editor)
- abecedarius 8y agoANS Forth does include file I/O as well as blocks. Back when I worked at FORTH, Inc. we all just used blocks. (also iirc EMPTY-BUFFERS predates ANS Forth, though maybe it wasn't standard then.)
- upofadown 8y agoIt gets philosophical fast, but something like a stack underflow error is a feature of the interpreter. It is not a part of the language itself. A misbehaving Forth program will happily underflow through all of memory.
- MaxBarraclough 8y agoAccording to the language spec, it seems to be non-compliant to handle stack overflow that way (even if it's obviously a good feature): > In all integer arithmetic operations, both overflow and underflow shall be ignored. The value returned when either overflow or underflow occurs is implementation defined. http://www.forth.org/svfig/Win32Forth/DPANS94.txt http://www.forth.org/svfig/Win32Forth/DPANS94.txt
- upofadown 8y agoI think they mean arithmetic overflow and underflow.
- MaxBarraclough 8y agoOops! Second attempt: looks like they single out "stack underflow" as implementation-defined behaviour: > A system shall document the system action taken upon each of the general or specific ambiguous conditions identified in this Standard. So, essentially the opposite of what I said.