Let Go, Standard Library From Community
David B. Held
dheld at codelogicconsulting.com
Thu Apr 19 23:33:50 PDT 2007
Daniel Keep wrote:
> [...]
> This is one thing I really lament about my uni education thus far. Two
> topics that basically have *never* been covered in even minimal detail
> have been optimisation and debugging.
>
> To be honest, I wouldn't know the most efficient way to return or pass
> out a vector because I've never had any kind of grounding in the effects
> of the various ways of doing it. For instance: at what point does
> passing by reference become faster than by value?
This is where it really helps to have some understanding of what a
compiler actually does. The "Java Syndrome" helps students treat the
compiler like a magical black box where text goes in and executables
come out. While this is useful for cranking out thousands of
entry-level programmers that assiduously follow design specs, it's not
very good for creating engineers who are also artists.
If you want to understand pass-by-value vs. pass-by-reference, it helps
to understand how C works, and then how assembly works. Only when you
get an idea for the actual instructions involved and how much time they
take, relatively speaking, does it become practical to estimate these
things. You can never be 100% sure what code a compiler is going to
generate without looking at the output, but after you learn a few
languages, you can make pretty good guesses.
For function call performance, you need to understand registers, memory,
stacks, call frames, and calling conventions. You also need to
understand that references are just pointers that get automagically
dereferenced on use. Once you put these things together, it starts to
become fairly clear when one is preferred over the other (though there
is definitely a gray area where it depends on the actual code generation
and hardware characteristics).
If you really want to be a good programmer, you need to take your
education into your own hands. I would venture to claim that the
majority of experts in the world learned most of what they know from
self-study, and not from classroom lectures and textbooks. You are
particularly lucky to be alive at this point in time because you have
ridiculously more free information available to you than I did when I
was growing up. I would have killed to have as much of the internet to
access as you do.
If you are really serious about your education, you will soon find your
classes boring, because most of your learning will be self-directed.
But you have to be fairly motivated to engage in that kind of learning,
and everyone has different personalities. In the end, a diploma only
proves that you will jump through hoops for The Man (which is important
for getting a job in the corporate world, where docility is rewarded and
innovation is discouraged).
Dave
More information about the Digitalmars-d
mailing list