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=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1014db,6154de2e240de72a X-Google-Attributes: gid1014db,public X-Google-Thread: fc89c,97188312486d4578 X-Google-Attributes: gidfc89c,public X-Google-Thread: 109fba,baaf5f793d03d420 X-Google-Attributes: gid109fba,public X-Google-Thread: 103376,97188312486d4578 X-Google-Attributes: gid103376,public From: bokr@accessone.com (Bengt Richter) Subject: Re: What's the best language to start with? [was: Re: Should I learn C or Pascal?] Date: 1996/09/26 Message-ID: <52eebp$fu4@kanga.accessone.com>#1/1 X-Deja-AN: 185500872 references: <51knkn$j61@dub-news-svc-8.compuserve.com> <01bba638$e913f800$87ee6fce@timpent.a-sis.com> <324844D7.1507@trw.com> organization: - newsgroups: comp.lang.c,comp.lang.c++,comp.unix.programmer,comp.lang.ada Date: 1996-09-26T00:00:00+00:00 List-Id: bs@research.att.com (Bjarne Stroustrup) wrote: >"Matthew M. Lih" writes: > > Hope you don't mind if I interject an experience. > > > > Tim Behrendsen wrote: > > > > > > What do they actually think happens inside a computer *magic*???? > > > > In some cases, yes! > > > > > They don't think *anything*. Think about the fresh-faced newbie on > > > his/her first day in CS 101. Their only experience with computers, > > > if they have any at all, is interacting with them at the user > > > level. They press a button, something happens. There's obviously > > > a mechanism behind it, but they don't have any concept of how it > > > works. > > > > Even some veterans don't have any idea. I'm taking > > a C++ class, and the instructor didn't have any idea > > that the "++" operator was developed because it > > corresponded to a very quick machine language > > instruction in the old PDP machines. When I pointed > > this out, his comment was along the lines of "Oh, > > you hardware types." >Actually, the story that ++ comes from the PDP11 instruction >set is a myth. Dennis Ritchie has denied it quite often, but >that doesn't seem to impress people. ++ is in C and C++ because >Dennis (being a mathematician) considered it a fundamental >(and useful) operation. It was in the PDP11 instruction set >because the designers at DEC independently had figured out >that it was an important operation to optimize. > - Bjarne You are certainly the one to correct me if I'm wrong, but to me the most important aspect of ++ (and --) is not that i++ increments and --k decrements, but that i++ evaluates to i and has the side effect i+=1, whereas --k evaluates to k-1 and has the side effect k-=1, allowing C statements such as a[i++] = b[--k]; to have special useful meaning. The really strikingly similar thing about the PDP-11 architecture was not instructions per se, but particular addressing modes for memory-referencing instructions, namely post-incremented register indexing and pre-decremented register indexing, providing a practically direct correspondence to a[i++] or b[--k]. If memory serves, PDP-11 machine language syntax used a single '+' suffix to indicate a post-incremented register index addressing mode, applicable to many memory-referencing instructions. A single prefixed '-' signified the corresponding pre-decrement indexing mode. E.g.,something like mov r0,(r1)+ or mov r0,-(r1). Instructions implementing a C statement such as i++; or --k; don't reflect the pre/post semantics that are important in a[i++] = b[--k]; and the corresponding addressing modes of the PDP-11. My 2 cents ;-) Regards, Bengt Richter (We had the 2nd PDP-11/45 on the West Coast, I believe :-) (With 4k added bipolar 300ns memory to keep your feet warm in winter).