From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: *** X-Spam-Status: No, score=3.8 required=5.0 tests=BAYES_00,INVALID_MSGID, RATWARE_MS_HASH,RATWARE_OUTLOOK_NONAME autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fc89c,97188312486d4578 X-Google-Attributes: gidfc89c,public X-Google-Thread: 109fba,baaf5f793d03d420 X-Google-Attributes: gid109fba,public X-Google-Thread: 1014db,6154de2e240de72a X-Google-Attributes: gid1014db,public X-Google-Thread: 103376,97188312486d4578 X-Google-Attributes: gid103376,public From: "Tim Behrendsen" Subject: Re: What's the best language to start with? [was: Re: Should I learn C or Pascal?] Date: 1996/08/06 Message-ID: <01bb8340$0353f4c0$32ee6fcf@timhome2>#1/1 X-Deja-AN: 172353366 references: <320433CE.6D5A@online.no> <4u1g29$hc0@solutions.solon.com> <01bb826a$b222f400$9bee6fce@timhome2> <4u3tt1$qub@solutions.solon.com> content-type: text/plain; charset=ISO-8859-1 organization: A-SIS mime-version: 1.0 newsgroups: comp.lang.c,comp.lang.c++,comp.unix.programmer,comp.lang.ada Date: 1996-08-06T00:00:00+00:00 List-Id: Peter Seebach wrote in article <4u3tt1$qub@solutions.solon.com>... > In article <01bb826a$b222f400$9bee6fce@timhome2>, > Tim Behrendsen wrote: > >Peter Seebach wrote in article > >[snip example of invalid usage of NULL pointer v.s. Null string] > >This completely makes the point. Someone who knows assembly language > >would *never* make that mistake, because it would be so obviously > >wrong. > > An interesting theory. Unfortunately, I long since lost track of these > articles, but in the old "use the OS vs. bang the metal" flame wars in > comp.sys.amiga.programmer, the assembly people would always talk about > how the first instruction in their programs was always > movel #0,0L > (Or however it is that you spell "write 4 bytes of 0 to address 0")... > > A high-level programmer would never do that, because someone who has > learned only the abstract semantics would not think of a null pointer > as the address of any real memory. It isn't; it's *guaranteed* that > no object has a null pointer as its address. > > >You cannot program in assembly and not understand a null > >pointer v.s. a pointer to a zeroed memory location. > > And you cannot program in abstract C and think of a null pointer as a pointer > to *any* memory location. On many machines that I use, you can't read or > write to it; it certainly doesn't *act* like it's memory. > > The people who did things like that were always assembler programmers relying > on their knowledge of what was "really" happening inside the machine. The C > abstract semantics clearly forbid it; however, on the majority of common > architectures, the hardware doesn't forbid it, and the assumption holds. > (By chance, mostly.) Both your points come down to the same thing; that if a programmer makes use of non-portable hardware-specific operations, then the code is not well-written C. I completely agree with this. Where I disagree with you is that you seem to be claiming that it would be bad to teach people the low level mechanisms, because then they would be tempted to use them. This seems very short sighted to me; certainly with knowledge comes responsibility, and along with teach the fundamentals there needs to be taught the portability skills. The problem is that the schools are so top heavy with the latter that the fundamentals are being neglected, and we end with the code-bloated world that we're living in now. -- Tim Behrendsen (tim@airshields.com)