9 ms·
Why Forth Isn't Slow (1985)
- emersonrsantos 6y agoWhy people are speaking a lot about Forth this year? Nothing against (I love Forth), just curious.
- andrewnc 6y agoI've wondered the same. It feels to me like we as a software writing community are yearning for a new paradigm or challenge. Often time this expresses itself as a framework du'jour. But recently it seems like people are reaching back to languages of yore to see if there is some piece of mystic art to be applied to today's problems. I'll admit I'm guilty of this outlook. I would love to write code professionally in Forth, APL, or any number of 'long gone' languages.
- Impossible 6y agoI was doing some programming language work last year for Facebook Horizon, and while not appropriate for that product it really made me interested in building a visual Forth or APL for programming in VR, mostly because the high amount of expressiveness with minimal symbols.
- andrewnc 6y agoI would use it if you ever built it :) that sounds fascinating.
- juancn 6y agoI think it's a yearning of simplicity. Software engineering today is complex, slow, and extremely removed from the machine. Forth is one of the simplest environments you can build that allows you to build complex software.
- cblum 6y agoI fell into that rabbit hole thanks to the quarantine. I've been find it therapeutic: the simplicity of it is unbeatable. It gives me the same sense of speaking directly to the machine that assembly does, but at a higher level. I've also grown to love RPN. I posted my project here just the other day: https://news.ycombinator.com/item?id=24604457 https://news.ycombinator.com/item?id=24604457 I had an absolute blast working on it, and I'm looking forward to my next Forth-related project (still deciding on what it's going to be).
- mikewarot 6y agoForth seems to be a write only language, I'm not sure if it's the reverse polish stack oriented structure, or the lack of modern things we're used to like arrays, procedure calls, etc... STOICAL seems to address all of these, but it's written in dense C code that I can't make heads nor tails of... but the ideas are really, really attractive. http://stoical.sourceforge.net/documentation.php http://stoical.sourceforge.net/documentation.php The stand out features for me 'string puts a string on the stack (along with a type flag for string 'cube : dup dup * * ; is how you would define cube, which is a bit different, but not a huge shift He's got ways to do types, dictionaries, arrays that also look like stacks... all sorts of magic including networking! How much of it could be crammed into something that boots inside of a VM?
- timonoko 6y agoThe reason might be that there is nothing new to invent or explore so they wallow endlessly in old dried-up shit. Forth is particularly useless, because it only truly made sense in fixed-width computers, where one word was equal one symbol and list of symbols was on separate paper tape. It was so sweet compared to Fortran that I still have cavities in my brain.
- durandal1 6y agoFlipping through this magazine just made me realize how much I miss computer magazines and hacking culture in the 80s/90s.
- StreamBright 6y agoExactly. I also miss the time when IT was much closer to the hardware without a gazillion of leaky abstractions.
- kbr2000 6y agoIndeed! Go wild: http://forth.org/fd/contents.html http://forth.org/fd/contents.html
- transfire 6y agoOh my! You found me a rabbit hole.
- joe_the_user 6y agoFlipping through the viewer made aware of how broken it was for anyone with a slow connection. It's a link to a middle page on a PDF viewer in archive.org. It annoys me you can't do things better than that.
- nix23 6y agoIt's 1985 and the slow connection was called postal service...you know that thing that broth you deadwood editions of pdf's. >It annoys me you can't do things better than that. Today you can, buy a faster connection or step on your government feet.
- klyrs 6y agoBrowsing the web: ignores every ad, installs blockers Reading old computer magazines: reads every ad, considers if copies of ancient literature still exist
- hyperman1 6y agoWe actually paid an euro for a few old Marklin ad folders on some flea market. My son loves them, and I have to agree they are beautifull. The ads in old elektuur/elektor magazines are also quite interesting and welcome. I still wonder why ad networks try to measure up me, instead of simply looking at the intended audience of the site I am at.
- protomyth 6y agoI still have a fairly complete set of Byte Magazines from the early 80's to about 2000. I absolutely loved the ads then and love reviewing them when I get a chance. It was amazing how much I learned from the ads. Explaining Computer Shopper to the web generation is always interesting.
- _ph_ 6y agoIn the good old days, one would buy and read a computer magazines equally for its content as well as the ads. They were an important source of information in a day and age without the WWW. Of course, the advertising back then used a trick which seems to escape all modern advertising think tanks: they had great user targetting without shady tracking schemes, by advertising things a magazine reader would be interested in. Imagine this trick being used in todays web :p.
- deleted 6y ago[deleted]
- failuser 6y agoThere was a report that targeting article contents yielded better revenue than targeting the audience for some European company, but I can’t find a link right away.
- randrews 6y agoIf you haven't ever used Forth or made a Forth interpreter, it's a fun project that I recommend doing.
- mikewarot 6y agoCan confirm... I wrote Forth/2 for OS/2, it was a hoot once I got it working. 8) It looks like I might be resurrecting "STOICAL", which was targeted at Linux, for Windows...http://stoical.sourceforge.net/documentation.php http://stoical.sourceforge.net/documentation.php It would be nice to see it run under Linux... the C source looks too much like typical "be as clever as possible" macro magic, which my non-C adjusted brain can't hack. I'll re-implement in either assembler, or free pascal. The reason is that STOICAL implements types, arrays, and dictionaries in what seems to be a quite reasonable and sane matter. It does type checking when you want, and seems like it could do object oriented as well, if I can push it that way.
- cblum 6y agoLearning how Forth is implemented and then implementing my own totally blew my mind. I've fallen hard in love with Forth. My greatest motivation to learn Forth inside and out is its value in rebuilding civilization if we ever find ourselves in a place where a significant amount of technology has been lost. I don't think there's a more powerful and yet incredibly simple way to bootstrap a general purpose programming environment than writing a Forth. It's a relatively small amount of knowledge that needs to be preserved, compared to all the complexity that would be needed to have compilers, garbage collectors, and all that jazz again. I mean, that's just my personal take on it.
- ddingus 6y agoI feel the same way. Given a reasonable initial Forth implementation, one can throw a dictionary at it and bring a whole tool chain up. I have seen embedded Forth developers do this on new CPUs and its fast and potent.
- oehpr 6y agoHey if you're looking to try writing some simple forth code in a fun context I recommend you try playing grobots http://grobots.sourceforge.net/ http://grobots.sourceforge.net/ I recommend you do the basics of the tutorial, then watching some matches with the provided sides. https://grobots.fandom.com/wiki/Tutorials/Beginner https://grobots.fandom.com/wiki/Tutorials/Beginner
- jandrese 6y ago> The learning curve is steep, and the documentation is, unfortunately, poor. Ouch.
- jedimastert 6y agoI guess I've found what's gonna keep me up past my bedtime tonight. Awesome. Does anyone have any other of these kind of programming games?
- RodgerTheGreat 6y agoI wrote a dungeon-crawling puzzle game based on (and implemented in) Forth called "Forth Warrior": https://github.com/JohnEarnest/Mako/tree/master/games/Warrior2 https://github.com/JohnEarnest/Mako/tree/master/games/Warrio... You can play a browser-based build here: http://johnearnest.github.io/Mako.js/?rom=Warrior http://johnearnest.github.io/Mako.js/?rom=Warrior (Warning: this game quickly gets pretty hard.)
- jedimastert 6y agoThis is great! I really goes to show how not-verse I am in Forth, but that's ok
- Doxin 6y agoCorewars[1][2][3] is somewhat in the same vein though the arena is the VM memory, and not a physics sim. You write an assembler program whose goal it is to as quickly as possible find other programs and make them run an illegal instruction. Last program standing wins. [1] http://koth.org/ http://koth.org/ [2] http://corewars.org/ http://corewars.org/ [3] #corewars on irc.freenode.net
- kmstout 6y agoAnd here's an archive of what appears to be all issues of "Forth Dimensions": http://soton.mpeforth.com/flag/fd/contents.html http://soton.mpeforth.com/flag/fd/contents.html Enjoy.
- DoctorOetker 6y agowhich flavor of Forth should I look at if I don't want to deal with the historical page sizes? (not sure of the nomenclature since I last looked at Forth)
- MaxBarraclough 6y agoANS Forth is the standardised Forth dialect. Gforth and JonesForth are solid Free Software implementations.
- siraben 6y agoOn the other hand, according to this[0] author who ported a game from assembly to C and Forth, Forth seems to drastically increase development time and perform 10-20 times worse than the equivalent assembly. [0] http://calc6502.com/RobotGame/summary.html http://calc6502.com/RobotGame/summary.html
- fctorial 6y agoI think the point of article is that forth isn't exponentially slower than C.
- transfire 6y agoFundamental problem speed wise appears to mostly be an issue with the limited 65C02 arch. Quote from article "The X register has to be adjusted to make room on the data stack each time a function is called. It takes 7 cycles to save the X register to the hardware stack at the beginning of the function and restore it at the end. It takes 2 more cycles for DEX for each byte of local variable used to adjust the data stack pointer."
- bjoli 6y agoI wonder how taliforth compares to something like VFX forth or SwiftForth. I just remember running an old gforth program in swiftforth and getting something like a 15x speed increase.
- MaxBarraclough 6y agoDoes that include using gforth-fast, which (if I understand correctly) enables JIT compilation?
- bjoli 6y agoI have been out of the loop for a long time, but AFAIK gforth-fast is still quite far behind the commercial forths when it comes to speed. I believe there is still room for improvement of forth speed, but iirc the VFX forth people didn't think it was worth the extra compilation time. Back then it compiled a 1MLOC project in 29 seconds, and the resulting code was plenty fast. As a baseline, a fast non-optimizing compiler should be able to compile about 1mloc a second for a moderately simple language.
- Mitch_Bradley 6y agoI was developing Open Boot - the Forth-based firmware that eventually became Open Firmware AKA the IEEE 1275-1994 Standard - at Sun back in the late '80s. It was intended to replace Sun's existing "sunmon" firmware which was written in C. The diagnostics group that maintained sunmon was adamantly opposed to Open Boot, probably mainly because it threated their ownership of the firmware. The argued against Open Boot, thinking that they had an ironclad argument: "Forth is interpreted therefore it is too slow". The argument totally backfired because I knew some facts about the hardware that had apparently escaped them. The dominant factor in the perceived firmware speed was scrolling text on the non-accelerated megapixel frame buffer. That involved a megapixel memory-to-memory copy for every line. On the monochrome display it was terrible and on the color frame buffer it was horrendous. The sunmon firmware ran from EPROM, whose access time was glacial compared to RAM and even worse compared to cache - and EPROM was not cacheable. To make matters even worse, on the SPARCstation 1 that was the first target for Open Boot, the EPROM data width was only 8 bits, so a 32-bit instruction fetch took 4 super slow EPROM accesses. You see where I am going with this, right? All it took to leave sunmon in the dust was to copy the screen-scrolling and bitblt routines into RAM. Just to pour salt on the wound, I also copied the modest-sized set of code words at the core of Forth into RAM. Direct-threaded Forth ran from RAM substantially faster than compiled C code ran from EPROM. Our project manager did not let me turn on the cache on the first shipment, worrying about bugs, but relented on later revisions. After the cache was turned on, Forth just flew. The fact that Forth is so well-factored, and the actual machine code is confined to a small compact area, meant that the cache performed extremely well. Furthermore, since Forth didn't need to use the SPARC register windowing mechanism - register windows were designed for C-style stack frames and are essentially useless for Forth stacks - the endemic SPARC problem of window spill and fill handlers didn't affect the firmware at all. That made the firmware much more adept at post-mortem examination of kernel crashes. In a lot of system code, the performance can be dominated by access to devices that are much slower than cache. In that environment, so long as you are careful about a few CPU intensive routines like memcpy and bitblt, threaded code can be nearly as fast as compiled code, and sometimes faster. And it is much more compact, which matters a lot when you have to fit everything into some flavor of ROM.
- mikewarot 6y ago
- 8bitsrule 6y agoI don't remember a lot about Forth, except this. After programming in (8-bit) assembler for about a year, I tried Forth. Getting the -code done- in -so little- time, I grinned broadly as I played Frisbee in that saved time. There's no way to save time like that any more; the computer's done -before- you finish typing 'run'. (Well, ok, infinite loops aren't any faster, just get -much closer to infinity. I postulate.) Anyway, those old mags always bring back that sense of WHOA! (I still have Kilobaud #1 and #2.)
- kazinator 6y agoForth isn't slow because it can be compiled to machine code, which is not even touched on by the article. The main argument of the article seems to be reiterating the idea that in a tree, most of the nodes are leaves. For instance, in a balanced binary tree containing 2^n-1 nodes, a little over half the nodes are leaves. So if we visualize the call graph as traversing a tree, where the leaves are primary primitives in machine language, the bulk of the activity is always going on in the machine language leaves. When a primitive operation returns, much of the time control soon passes to another primitive operation, staying near the bottom of the tree.
- nybble41 6y ago> When a primitive operation returns, much of the time control soon passes to another primitive operation, staying near the bottom of the tree. Depending on how the threading is implemented, the primitive "return" (NEXT) operation may even pass control directly to the next primitive; a typical threaded implementation of NEXT might be something along the lines of "load next codeword and branch to it". You only go through the full call/return sequence, e.g. updating the return stack, when entering or leaving a non-primitive word.
- SomeoneFromCA 6y agoWhoever likes Forth, might really enjoy Postscript (yeah, that printer-oriented language). It is probably the most used stack-based language around.