Robot Game: Comparing 6502 C, Assembly, and Forth
&gt; This brings us to one of the main shortcomings of Forth. If you need to access more than three local variables at once (in the body of a loop for example) there is just no convenient way to do so. [...] Consider the variables used in this C function that draws 1 bit-per-pixel images with optional rounded corners:
&gt; int DrawTile1bpp<p>Looking at the C version, the argument &quot;tile&quot; is used once in the function, to get the pointer to the tile. The pointer could be passed directly: one less local. x and y are passed only to calculate an address, this address could be passed directly - there are only three calls to this function, it might be worth the DRY exception.<p>t0 seems to be always 0, except when it is undefined.<p>The t_height, t_with are just offsets in the tile structure. This locals can go away too - probably eating the cost of fetching them each time is more effective than the cost of all the stack juggling done to avoid it. This reminds me a word from a Chess great master: &quot;don&#x27;t waste time trying to save one&quot;.<p>trans_row only exists to set skip_pixel, it seems one of them can go away. The logic seems to be  &quot;unless trans_row and something, do something&quot;. The C version might actually be more verbose than necessary.<p>Finally, the edge_style complicates a lot the logic. Using one function to do different things because it is so simple to &quot;just add another parameter&quot; is typical in many HLL, and often result in awful spaghetti code.<p>What a Forth programmer would do is to write one function for each edge style and see what the have in common. More often than not, they share a lot of subwords, so that having one function for each case is not more expensive than one function for all cases.<p>I suggest doing that with the C version and see what happens.<p>&gt; Without parenthesis or commas, there is no way to tell just by looking at the code which of those are functions, which ones are variables, which of them are inputs to the others, or what any of them return. Forth fans will say that that information is available in the stack comment for the word&#x27;s declaration, but that assumes that the programmer bothered to create one. Even if they did, you have to search in several places in the file to figure out what is instantly obvious if the same code were written in a language like C or Python. It&#x27;s easy to see why people criticize Forth for being &quot;write only.&quot; If you translated the line above into C, it could be doing any of the following:<p>Actually even in C some follow certain naming conventions - like #defines being all caps, member things being prefixed by m_, etc. And you can do that in Forth too.
Once again, &quot;write only&quot; has more to do with the author than wit the language.