Quote:
In the article, Joey does admit that he was new to Forth, which explains the longer development time and some of the resulting performance slowness for him. It hardly seems like a fair comparison. Regardless, it's not really a reflection on Forth except for its execution on 8-bitters.
Correct, I did say that some of the slowness in the results is due to lack of experience on my part, so I don't want people to take the numbers in the charts as completely representative. However, I still stand by the conclusion that using Forth on the 6502 entails an
extreme loss of performance. That can be demonstrated by analyzing the underlying assembly, and I tried to cover that briefly in my article.
GARTHWILSON wrote:
The 6502 (and especially the '816) is so easy to write short assembly-language pieces for though that I have never really seen Forth's 6502 slowness as a problem. Like they say, you can get 90% of assembly language's performance with only 10% of the code in assembly language, provided it's the critical 10%... or was it 95% and 5%?
You have said this many times, but my objection is this only really applies to some projects. I've gone back and watched years and years of the presentations at the SVFIG meetings and noticed that the programmers there tend to apply Forth to one or a small handful of problems and then claim based on that that it's superior to C and competing languages at all times and in all circumstances. One guy has been showing off a small robot he made in the 90s programmed in Forth and sold to educational markets and claims that Forth is the only language that makes sense for robots. I'm not sure to begin with that it was the best choice in the 90s for an educational robot, much less that it's always the best choice for educational robots nowadays, much less for all robots at all times nowadays. People tend to put on blinders when they find something that works for them and demonstrate the "If it works for me, it ought to be good enough for anyone" fallacy.
On the other hand, I can see how I put on my own blinders and might criticize Forth too heavily sometimes since I care about performance, which isn't a concern for a lot of other people's projects. I got interested in the 6502 to make programmable calculators where you're never thinking about making a device that is "fast enough" but one where you need to maximize performance since you're letting users create their own programs on the device. Squeezing out an extra 5-10% of performance is a huge win if that's horsepower you can hand over to the user to do calculations with. Compare this to something like a microwave. I've noticed that mine has a noticeable delay between the time I press a button and it responds with a beep. Adding more horsepower to get the delay down is a waste of time and won't sell more microwaves. A lot of engineering is aimed at producing "good enough" rather than maximizing performance where it wouldn't make a difference anyway. If you're able to hit those engineering goals with Forth, or by rewriting 5-10% in assembly as you suggested, then that sounds like success to me. My objection is to the idea that this method works for all projects all the time. If over half of my ROM is taken up by calculations that I need to be really fast, there just isn't a 5-10% chunk for you to find and rewrite because it's equally important that
all of them be fast. Like I said, however, I can see the appeal of using Forth for something where you don't miss the extra performance, and I don't mean to say it's a bad choice just because it doesn't work for what I want to do.
Quote:
For modern 32- and 64-bit processors, optimizing Forth compilers may yield results that have fewer machine-language instructions than the source code had Forth instructions. Super efficient.
This is really interesting. Have you looked at
Mecrisp Forth? It uses a very cheap ARM board as a tether to program MSP430 microcontrollers. It generates optimized assembly for the target, so no kernal or thread overhead on the MSP430. There's also a version that uses an ARM board to program other ARM boards. Some of the guys involved with it claim it's only about 3 times slower than C, which is pretty darn impressive. One of the optimizing Forths for Windows leaves the majority of registers vacant. This seems like a waste, though from people I've talked to who know a lot more about x86 than I do, thrashing the stack and ignoring the extra registers may not really have a speed penalty on modern processors. I would love to know more.
Quote:
Also, Forth, Inc. has a lot of stories from their own experience where for example it was estimated that a project would take a team of C programmers two years to complete a job, and one man came in and did it by himself in six months in Forth, reducing the hardware requirements in the process.
Chuck Moore has said this kind of thing in his presentations before and it's almost certainly nonsense. I think it belongs in the same garbage bin as saying that pure Forth on the 6502 is "only 25% slower" than the equivalent assembly, which pops up on other forums from time to time. Please let me know if you have any way of verifying this (EDIT: this meaning the claim about C programmers). I've often thought about how you would organize a comparison by having a C and Forth team solve the same problem.