Re: Coding Horrors, Cargo Cult Programming, and other Ghoulish Things
- From: Eric Grange <egrangeNO@xxxxxxxxxxxxxxx>
- Date: Mon, 30 Oct 2006 13:56:46 +0100
Do you know one algorithm that's developed in C, Delphi, Java...?
Most of the time, the same algorithm will be implemented differently in C, Delphi or Java, and it'll not just be a case of syntax adaptation, but one of a logic variant.
The _implementation_ does not change anything about compexity> or worst case results, as long as you do it correctly.
That's incorrect, even if you "do it correctly" (whatever that means), some languages/environment do perform some operations differently, which can add to the complexity, and may require the use of a different algorithm or variant.
Some classic examples:
- algorithms that involves testing the length of a string in a loop
(especially if that string is of varying length)
- algorithms that involve modifying parts of a structure, structure
which may be immutable for a language, not immutable for another
- algorithms that involve the use/availability of certain operators
or features that may not be replicated easily by code, from threading
related features to self-modifying code/runtime code generation
Do you state that you have to be able to read x86 and IL code to be a good programmer, and to write good code?
No, I state you have to understand the mechanisms involved in execution of code to write good code. That means knowing that your code isn't directly executed but an assembly is, that means knowing what an exception frame is, what a stack is, what a thread is, what memory actually is and how values are stored, etc.
You do not have to know the exact details of any of these particulars, but having an understanding, and having studied at least one case of each in sufficient detail is IMO necessary to make Good Code (tm).
Not knowing them means you'll be using them, but as magic... because you'll have to use them, whether you desire it or not.
I don't need to know how the Delphi compiler translate a for loop to use it correctly.
Well, actually you do, if you want to understand why the loop counter variable will sometimes go in reverse in the debugger ;)
> I only need that knowledge (eg. loop variable in a
register) when I have to optimize the loop.
That's a detail, and in practice, it's not guaranteed.
If I were to teach you, I would rather worry about you knowing that the loop bounds are evaluated only once at the beginning of the loop, which is a trait not shared by other languages' "for" loop (and which can be the source of the "same algorithm" having a different execution complexity...).
> So, not knowing how that thing is translated, will I eventually
> use that thing wrongly?
If you take Delphi's "for" as no more than syntaxical variation of C's "for", then you likely will use it wrongly, yes.
Yes. And these differences are (hopefully) documented.
That things are documented doesn't mean they're known, much less accounted for all the time...
If you only learn without understanding, you will forget things, that's a given. If you understand how things work, and why they were done this way and not another, why the limitations are there, and what plumbing they arise from, the odds of "forgetting" are much reduced.
It's all about understanding, rather than relying on "cargo cult" dogma, relying on a list of things that have to be done, for reasons forgotten. That path only leads to myth, faith-like certainties with no foundation, and distrust of everything that doesn't falls within the tiny bounds of the dogma.
A big word for such a little missing information. If that's more or less all the developer does not know, then it's ok for me.
It's unlikely to be, as it denotes lack of understanding.
> Nobody knows everything.
Indeed, that's IMO why one should strive to understand rather than "know", ie. learn the means to know, rather than the knowledge itself.
> If it's a sign that he did not grasp the whole concept, and
is unable to to learn (which is the case with the guy John> mentioned), then everything is lost.
IME it's a sign he was taught things without being taught "how" or "why", and to him all the things I detailed above are meaningless.
He was probably only taught recipes, by people who thought he did not need to know anymore than the high-level recipes.
Eric
.
- Follow-Ups:
- Re: Coding Horrors, Cargo Cult Programming, and other Ghoulish Things
- From: Hans-Peter Diettrich
- Re: Coding Horrors, Cargo Cult Programming, and other Ghoulish Things
- From: Ralf Mimoun
- Re: Coding Horrors, Cargo Cult Programming, and other Ghoulish Things
- From: Dennis Landi
- Re: Coding Horrors, Cargo Cult Programming, and other Ghoulish Things
- References:
- Coding Horrors, Cargo Cult Programming, and other Ghoulish Things
- From: John Jacobson
- Re: Coding Horrors, Cargo Cult Programming, and other Ghoulish Things
- From: Roger Lascelles
- Re: Coding Horrors, Cargo Cult Programming, and other Ghoulish Things
- From: Ralf Mimoun
- Re: Coding Horrors, Cargo Cult Programming, and other Ghoulish Things
- From: Eric Grange
- Re: Coding Horrors, Cargo Cult Programming, and other Ghoulish Things
- From: Ralf Mimoun
- Coding Horrors, Cargo Cult Programming, and other Ghoulish Things
- Prev by Date: Re: Coding Horrors, Cargo Cult Programming, and other Ghoulish Things
- Next by Date: Re: Why would I use .NET?
- Previous by thread: Re: Coding Horrors, Cargo Cult Programming, and other Ghoulish Things
- Next by thread: Re: Coding Horrors, Cargo Cult Programming, and other Ghoulish Things
- Index(es):
Relevant Pages
|