Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.misc > #953

Re: Learning to code by reading code

From "MikeWhy" <boat042-nospam@yahoo.com>
Newsgroups comp.lang.misc, comp.lang.c++
Subject Re: Learning to code by reading code
Date 2012-02-19 13:17 -0600
Organization A noiseless patient Spider
Message-ID <jhrhs6$ar8$1@dont-email.me> (permalink)
References (5 earlier) <reading-20120218195201@ram.dialup.fu-berlin.de> <jhpe5i$iug$1@speranza.aioe.org> <assembly-20120219023621@ram.dialup.fu-berlin.de> <jhqde4$grl$1@speranza.aioe.org> <d3b454ac-ae8e-4bd6-b67e-2e8e4050f849@w4g2000vbc.googlegroups.com>

Cross-posted to 2 groups.

Show all headers | View raw


Nick Keighley wrote:
> On Feb 19, 8:54 am, "Rod Pemberton" <do_not_h...@noavailemail.cmm>
> wrote:
>> "Stefan Ram" <r...@zedat.fu-berlin.de> wrote in message
>> news:assembly-20120219023621@ram.dialup.fu-berlin.de...
>>> "Rod Pemberton" <do_not_h...@noavailemail.cmm> writes:
>
>>>> learning how that language is converted to assembly [is important]
>
> I don't think so. When I come across a novel language feature I like
> to think how it would be implemented. But I use an imaginary machine
> (or these days, C!). Long ago I knew Z80 assembler (actually much of
> Z80 machine code) but I can't see the utility in converting chunks of
> C ++ (or scheme or Haskell)into Z80 assembler.
>
>>> Even given a specific source language and a specific
>>> assembly language, there is no specific way »how that
>>> [source ]language is converted to assembly«, this
>>> instead depends on the compiler[ author].
>>
>> I believe that's partially true, but not entirely.
>
> agreed
>
>> Many assembly languages
>> are very similar. Microprocessors standardized on certain concepts
>> around 1974 or so, e.g., 8-bit bytes for ASCII and EBCDIC,
>> contiguous memory, pointer size equivalent to integer size, typeless
>> integers, 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.
>
>> Many HLL
>> compilers, e.g., for C, produce the nearly the same code but
>> adjusted for different platforms. But, it's still the programmer's
>> responsibility to understand what that HLL code is producing for
>> their specific tools.
>
> nope. I get on just fine not knowing what code my HLL is producing.

This might be the salient point, at least for this narrow part of the 
discussion.

Each foo(), *foo, foo[i], ++foo, foo++, and for that matter, '{' and '}' has 
in my mind very specific implications and costs. As I type or read each 
'if', 'switch', 'for', 'try', 'catch', and 'return', I hold in mind on a 
subconscious level the underlying assembler, albeit on a broad generalized 
model. For that matter, I also hold a simplified model of how awk or perl 
scripts are read and translated as I write them. Reading the Erlang language 
spec recently, I can "see" the interpreter, how it's built (or how I might 
build one), and the runtime cost of many of its constructs. C#'s runtime 
type binding holds few mysteries if you understand COM, and Java's byte-code 
interpreter holds no mysteries at all.

Like some others, I also had my start with BASIC, and then dug into 6502 
assembler to understand the unannotated ROM disassembly. This seemed a 
completely natural progression. (Apparently, Bill and I have an even longer 
history together than I had imagined before this moment.)

Before that, though, I wrote toy-sized FORTRAN without the slightest notion 
beyond "this is how you iterate over these calculations N number of times", 
and "this statement label is how you tie this statement to that other." 
Certainly it's possible to write useful programs without understanding the 
how or why behind them.

While I don't intend any of this to be judgemental, I don't see how I can do 
what I do with just a collection of rote rules and a notion of magic that 
happens under the covers. As perhaps extreme examples, memory barriers and 
fences are vague notions and superstition with that view, and using CUDA 
effectively is not possible at all without an underlying understanding of 
how the parts fit together.

Back to comp.lang.misc | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Re: Learning to code by reading code (was: The way to read STL source code) "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2012-02-18 19:00 -0500
  Re: Learning to code by reading code "MikeWhy" <boat042-nospam@yahoo.com> - 2012-02-18 22:34 -0600
  Re: Learning to code by reading code "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2012-02-19 03:54 -0500
    Re: Learning to code by reading code "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2012-02-19 10:42 +0100
      Re: Learning to code by reading code "BartC" <bc@freeuk.com> - 2012-02-19 22:34 +0000
        Re: Learning to code by reading code "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2012-02-20 12:22 +0100
    Re: Learning to code by reading code "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2012-02-20 03:39 -0500
  Re: Learning to code by reading code "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2012-02-19 03:54 -0500
    Re: Learning to code by reading code Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-02-19 08:40 -0800
      Re: Learning to code by reading code "MikeWhy" <boat042-nospam@yahoo.com> - 2012-02-19 13:17 -0600
        Re: Learning to code by reading code Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-02-20 02:32 -0800
          Re: Learning to code by reading code "io_x" <a@b.c.invalid> - 2012-02-20 13:02 +0100
            Re: Learning to code by reading code Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-02-20 05:09 -0800
              Re: Learning to code by reading code "io_x" <a@b.c.invalid> - 2012-02-20 15:11 +0100
                Re: Learning to code by reading code Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-02-20 07:39 -0800
      Re: Learning to code by reading code "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2012-02-20 04:14 -0500
        Re: Learning to code by reading code "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2012-02-20 11:14 +0100
          Re: Learning to code by reading code Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-02-20 05:13 -0800
        Re: Learning to code by reading code Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-02-20 02:49 -0800
          Re: Learning to code by reading code "io_x" <a@b.c.invalid> - 2012-02-20 13:02 +0100
            Re: Learning to code by reading code Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-02-20 05:18 -0800
              Re: Learning to code by reading code "BartC" <bc@freeuk.com> - 2012-02-20 13:53 +0000
                Re: Learning to code by reading code Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-02-21 01:32 -0800
                Re: Learning to code by reading code "io_x" <a@b.c.invalid> - 2012-02-21 16:16 +0100
                Re: Learning to code by reading code Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-02-21 08:40 -0800
          Re: Learning to code by reading code "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2012-02-20 17:36 -0500
            Re: Learning to code by reading code Dombo <dombo@disposable.invalid> - 2012-02-21 00:45 +0100
              Re: Learning to code by reading code "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2012-02-21 04:35 -0500
                Re: Learning to code by reading code Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-02-21 08:48 -0800
                Re: Learning to code by reading code Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-02-22 00:12 -0800
                Re: Learning to code by reading code "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2012-02-22 06:12 -0500
                Re: Learning to code by reading code Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-02-22 04:30 -0800
                Re: Learning to code by reading code Geoff <geoff@invalid.invalid> - 2012-02-22 10:45 -0800
                Re: Learning to code by reading code Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-02-23 01:12 -0800
                Re: Learning to code by reading code "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2012-02-23 07:34 -0500
                Re: Learning to code by reading code Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-02-23 05:46 -0800
                Re: Learning to code by reading code "io_x" <a@b.c.invalid> - 2012-02-24 08:38 +0100
                Re: Learning to code by reading code "io_x" <a@b.c.invalid> - 2012-02-24 08:40 +0100
                Re: Learning to code by reading code "io_x" <a@b.c.invalid> - 2012-02-24 09:38 +0100
                Re: Learning to code by reading code "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2012-02-25 05:25 -0500
                Re: Learning to code by reading code Dombo <dombo@disposable.invalid> - 2012-02-25 12:50 +0100
                Re: Learning to code by reading code Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-02-25 06:13 -0800
                Re: Learning to code by reading code Gareth Owen <gwowen@gmail.com> - 2012-02-26 07:20 +0000
            Re: Learning to code by reading code Juha Nieminen <nospam@thanks.invalid> - 2012-02-21 08:23 +0000
              Re: Learning to code by reading code Juha Nieminen <nospam@thanks.invalid> - 2012-02-21 08:43 +0000
                Re: Learning to code by reading code "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2012-02-21 04:47 -0500
                Re: Learning to code by reading code Juha Nieminen <nospam@thanks.invalid> - 2012-02-21 10:09 +0000
                Re: Learning to code by reading code "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2012-02-22 05:38 -0500
              Re: Learning to code by reading code "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2012-02-21 04:31 -0500
                Re: Learning to code by reading code Juha Nieminen <nospam@thanks.invalid> - 2012-02-21 10:05 +0000
                Re: Learning to code by reading code "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2012-02-21 12:21 +0100
                Re: Learning to code by reading code "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2012-02-22 06:04 -0500
                Re: Learning to code by reading code "BartC" <bc@freeuk.com> - 2012-02-21 11:01 +0000
                Re: Learning to code by reading code "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2012-02-22 05:59 -0500
                Re: Learning to code by reading code "BartC" <bc@freeuk.com> - 2012-02-22 12:59 +0000
                Re: Learning to code by reading code "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2012-02-23 07:03 -0500
                Re: Learning to code by reading code "BartC" <bc@freeuk.com> - 2012-02-24 14:20 +0000
            Re: Learning to code by reading code Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-02-21 01:27 -0800
        Re: Learning to code by reading code Peter Remmers <p.remmers@expires-2011-04-30.arcornews.de> - 2012-02-20 22:25 +0100
          Re: Learning to code by reading code Jorgen Grahn <grahn+nntp@snipabacken.se> - 2012-02-26 08:47 +0000
            Re: Learning to code by reading code "BartC" <bc@freeuk.com> - 2012-02-26 10:55 +0000
        Re: Learning to code by reading code Nomen Nescio <nobody@dizum.com> - 2012-02-22 08:59 +0100
          Re: Learning to code by reading code "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2012-02-22 05:59 -0500
            Re: Learning to code by reading code Nomen Nescio <nobody@dizum.com> - 2012-02-22 13:47 +0100
              Re: Learning to code by reading code "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2012-02-23 06:21 -0500
        Re: Learning to code by reading code Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-02-22 00:08 -0800
  Re: Learning to code by reading code "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2012-02-19 03:54 -0500
  Re: Learning to code by reading code Marco van de Voort <marcov@toad.stack.nl> - 2012-02-19 11:27 +0000

csiph-web