Nick Keighley said:
On Feb 19, 8:54 am, "Rod Pemberton" <
[email protected]>
wrote: ....
But I use an imaginary machine [...]
How do you confirm correctness of both high-level and low-level code with an
imaginary machine? Is your confirmation of correctness imaginary also? ...
That's one of the problems with the ANSI and ISO C specifications: it
doesn't specify a working machine model. Without it, there is no reference
working version of C that other implementations can be compared against.
Without it, everything in the specifications is open to interpretation as to
accuracy. That's the major problem that plagues the pedants on comp.lang.c.
Each of them has their own model in their head of how C works and what the
English words and phrases in the C standards mean. The British frequently
have a different understanding of "either-or" versus Americans. It seems
that not one of the pedants has ever programmed in assembly or believe they
need to. None have read "The C Rationale", or read historical works by the
C creators like "The Development of the C Language" or "Portability of C
Programs and the UNIX System" or "The C Language Calling Sequence" etc which
explain what C is supposed to do and make reference to assembly. If they
did, none of them would ever argue against the understanding that C is built
upon assembly and assembly is needed to fully understand C.
Forth programmers hate the fact that their early specifications did specify
a machine model. The problem wasn't that they specified a model, but they
specified a very narrow model that wasn't able to adapt, or had radical
changes in the following specification. But, that is far better than not
specifying one at all. Many Forths were able to comply very accurately with
their machine models. That allowed Forth to be widely implemented. Today,
a couple of the early specifications are loved, and still used while a
couple are hated.
I'm not familiar with the C! language. Did you mean the C language?
Perhaps you meant C# language? It seems that Wikipedia, Esolangs, nor
Google or Yahoo, will find anything on C! or C exclamation language ...
HOPL is inaccessible for some reason.
However, if C! is a C derivative, it most likely inherited the basic
functionality that a programmer needs to know. Most C derivative
languages have kept that functionality because it has become standard
due to microprocessors.
[...] but I can't see the utility in converting chunks of
C++ (or scheme or Haskell)into Z80 assembler.
Yes, converting C++ for ARM to Z80 to understand how a HLL is converted to
assembly would be questionable ... You'd want to study the ARM assembly
code generated for C++. They need to understand how a HLL is converted to
the assembly for their platform. They need to know how basic language
constructs are converted to assembly, e.g., pointers, control-flow,
procedures or function calls, etc.
but many C programmers (and maybe C++ programmers)
assume these are inviolate laws! They end up writing horribly
unportable programs for no reason except intellectual laziness
and lack of imagination about hardware engineers
(and compiler writers) might do.
Your concentration on assembly code encourages this (naff)
type of coding.
Ok, this is the same BS portable C argument that plagues comp.lang.c
thought ...
The first inherent problem with that argument is that microprocessors have
standardized on a basic computing architecture. Nearly all computing
platforms today use that architecture either because they are microprocessor
based or because they use the same hardware, e.g., memory. They
standardized way back around 1974. Mainframes followed suit slightly later.
What that means is that almost no one today - or in the past two decades for
that matter - has access to obscure, obsoleted, perverse platforms - or
other platforms that *NEVER* shouldv'e have been used to create the ANSI C
standard in the first place - where "portability" of C or C++ is actually
needed. Have you ever had access to a non-emulated EBCDIC platform in your
entire lifetime? (No.) Have you ever had access to a 16-bit byte platform
in your entire lifetime? (No.) Have you ever had access to a 9-bit
character platform in your entire lifetime? (No.) So, like it or not, it's
entirely up to the users of obscure platforms to fix the "non-portable"
nature of C code for their platforms.
The second inherent problem with that argument is even C that is
specification compliant is truly only 30% portable. And, that again is due
to standardization of microprocessors on 8-bit bytes for ASCII or EBCDIC,
contiguous memory, two's complement integers, generic integers so pointers
are the same size, etc. Another 50% of C can be made to work correctly, but
it's not portable by default. The compiler has to make it work. And, 20%
of C is just non-portable. IIRC, you were on c.l.c, so I shouldn't have to
mention stuff like setjmp, signals, buffering, POSIX based file I/O, etc.
nope. I get on just fine not knowing what code my HLL is producing.
Then, I'd quess you won't get fired for producing faulty code either ...
So, that qualifies you as either a novice or hobbyist. (Yes, I suspect you
probably aren't ...) A professional would do so as a matter of course. How
do you know your compiler is compliant with a specification, or your
compiler accurately implements what you expect your code to do?
Testing only? What if you missed something you could've caught had you
simply just read the assembly?
Rod Pemberton