Re: hardware errors, do C and Forth need different things in hardware?
- From: John Passaniti <nntp@xxxxxxxxxxxxxxxxx>
- Date: Sun, 21 May 2006 02:29:54 GMT
Jeff Fox wrote:
These are ways Forth can beat C because C wants to
insist that one needs mainframe hardware and software.
That's the problem it was designed to sovle, to write
Unix as the software traffic cop for the hardware traffic
cop for hostile C programs.
C doesn't insist on anything.
Back a couple years ago, you wrote one of your typically leading messages asking about the executable size of a simple "Hello World" program in C. I happened to be working with a C compiler for microcontroller at the time (ImageCraft's HC08), and so I compiled some code to see the size. The result was around a couple hundred bytes, assuming one used puts to display the string instead of the overkill printf that's in most canonical examples. A minimal printf shot the size to about 1800 bytes. And in either case, that was the *entire* code, including startup and the vector to allow the processor to run the program. There was no OS on the target. This was code that talked to the bare metal.
Your reply at the time was "nice."
I really get tired of your apples-to-oranges comparisons. When talking about Forth, you have both feet planted firmly in the embedded systems space. You talk about systems that aren't general purpose, but are designed to be specific in what they do. And the company you now work for sells chips that are designed for specific functions, not for general-purpose computing.
So that's where you start, but for some reason the second you begin talking about C, you move the discussion somewhere else entirely. It doesn't matter that the vast array of micros being used in embedded systems don't have any operating system on the target. It doesn't matter that the majority of these are programmed in C with code that talks to the bare metal. It doesn't matter that the size of many of these systems doesn't even allow for a minimal operating system. It doesn't matter that for years, magazines that target the embedded systems community have talked about commonly-used techniques in C for using various models of cooperative multitasking (round robin task lists, message passing, a variety of state machine models, etc.).
None of that (and much more) matters to you. To you, C programmers have a "mindset" that forces them to require an operating system on the target, and write code that is far above the bare metal.
The problem is that you know better-- you have to know better-- but if you talked about C programmers who target embedded systems then your rants wouldn't work.
The thing is, you're right when you're talking outside the embedded systems space. C programmers writing code for general-purpose systems do expect an operating system to both provide services and to abstract away the underlying machine for portability. But that's not C for embedded systems-- supposedly what you're talking about.
The first reads BEGIN AGAIN. All Forth programmers are
suppose to be able to read that. It is suppose to be simple.
It does not imply hidden background tasks or watchdogs.
Thinking it is dozens of times more complicated than it
is misses the power of Forth and is an error. It isn't C.
do {
} while(1);
I don't see a bug there. I don't see a hidden background task.
What makes Forth fundamentally different than C and
gives it some fundamental advantages over C is that
it can do things with much less overhead than C. That
is because in C the idea is that software is bad and
an OS and hardware traps are needed to protect
everything from bad software. Bugs are planned, and
the whole picture is all about the planning for bugs.
Give a concrete example. I will code in C, and then show you the assembly code generated. You won't see anything in the assembly code that is unexpected, no reliance on an OS, no hardware traps needed to protect anything.
.
- Follow-Ups:
- References:
- Prev by Date: Re: Another way to do x^n
- Next by Date: Re: Is Forth really easy or is it complex?
- Previous by thread: Re: hardware errors, do C and Forth need different things in hardware?
- Next by thread: Re: hardware errors, do C and Forth need different things in hardware?
- Index(es):
Relevant Pages
|