Originally posted by rob.rice
a human can pull back and look at the task at hand
a compiler can't do that
compillers have gotten a lot smarter BUT thay at there
best look at one function at a time not the whole program
and no compiller will ever be smarter than a human
a compiller can't re strecuter the program the way a humen can
and useing an Hll the human cant see how restructureing
will help when it can help ( I'm not saying that it will always help)
That's a different level of optimizing, there's code level optimizing and algorithm/design level optimizing. Compilers don't come up with algorithms or designs, that's the part the programmer has to do (what else is programming for?). This is true for both assembly and HLLs. The thing you're talking about is not a task of a compiler, you might as well say that asm programmers are better because humans can talk and compilers can't. No matter what language, the design and algorithms have to be figured out by the programmer.
The difference between HLLs and assembly is with HLLs, the programmer focusses on the design, while with asm, the programmer has to do both the design and the code level details (optimizing). In cases where the design matters more than the speed gained by optimizing the code level by hand, I pefer HLLs but that's my choice.
It's true that the structure of an asm programming is more 'low-level' than a HLL program structure, but this has both advantages and disadvantages. HLLs often have nice features for creating data structures and designing programs (classes, interfaces, design patterns). In assembly, none of these present by default. You all have to do this yourself. Often asm programs lack any good design, but this too depends on the programmer. It's just that HLLs provide the basic elements for good design so chances are higher one will have a working design in HLLs than without these basic elements. Sometimes asm programmers tend to think low-level all the time, while high-level design is just as important.
there is also the matter of uneeded overhead that always comes
with HLLs you can't turn off just the useless parts of this over
head but you can turn off all of it and rebuild the parts you need
the compiller can't see what is going to be done it just gets ready
for every thing that can be done to be done this is part of what
I mean about humans being smater than compillers
This is true for standard libraries that have standard functionality of which some things aren't used but still present. Personally I rather have some extra stuff I don't use than writing all those routines myself.
Btw the STL C++ classes are mostly templates with inline functions, the basic data structures (vectors, lists, queues, maps) have an overhead close to zero.
and there some things that can be done in assembly that HLLs are just can't easly do like bit manipulation
Most bit stuff is available in HLLs to (I've missed rol/ror a few times though), but it's true that these things are easier in assembly, because it's more low level. The use of (complex) bit manipulation is very limited in most programs though (the occasional flag check can be done just as fast in C).
I am not saying that HLLs are useless but thay are not always the best way to do things
Then we agree :) It's like saying the glass is half full or half empty: HLLs are not always the best thing but asm isn't always the best thing either.
a rotter assembly programmer will most likely be a rotten Hll programmer Hlls are not a fix for not knowing what you are doing
But a good C programmer has to know a lot less than a good asm programmer. To beat the compiler you really need to know the CPU details, instruction timings, pipelines, cache stuff etc.
and yes one needs to know a whole of a lot more to program to
program in assembly than HLLs but at the same time one gains
a better understanding of how computers work even if you never
programs in assembly this alone makes it worth learning
I totally agree but don't mix up educational use with practical use.
Just like you're not saying 'asm rules', I'm not saying 'C++ rules', I enjoy programming in assembly and use it where I think it matters, I'm only explaining my view on the use of assembly and how it compares to HLLs.
Thomas