Fair point. It's unnecessary in a lot fewer cases. It used to be that nearly every programmer could potentially need to do it. Now it's probably 1 in 100 or fewer.
Not really. Unless you're writing code that deals with custom hardware. The closest you should get to ASM imo is compiler intrinsics (SSE and the like).
Wrong. In multimedia and graphics processing people still need to write a lot of assembly code because compilers make tons of mistakes. Same with bitcoin mining and checksuming.
Basically, if you need something CPU-optimized, sooner or later you will need assembly.
I don't know what platforms or compilers you're working on, but on x86 and arm the compilers are great. We (I work someplace you've heard of doing graphics and multimedia) have literally no assembly code. There is no reason why a good optimizing compiler can't generate fast asm, and often it thinks of optimizations that even our best engineers may miss.
You should try racing the compiler sometime on something more complex than a line or two of code. It will most likely win.
Also keep in mind that inserting asm throws off a ton of optimizations because the compiler can't guarantee you're following the c/c++ standards in your asm.
I also have worked in someplace you've heard doing multimedia, and I can assure you FFmpeg's assembly code is way faster than the C version, that's the whole reason why they have assembly code.
Do you want me to compile both and show you how wrong you are?
You can never trust the compiler to generate the most optimal code, and the generated code can never be as optimal as what an expert engineer would write.
I guess you don't want me to compare the performance of C-only FFmpeg vs. C+ASM FFmpeg. Right?
Maybe. But it's not necessary in most cases. You can often get by with doing optimization in C. If you need some vector operations, you can use intrinsics, which look like basic functions.
The only two reasons to drop to assembly now-a-days is when speed is of the utmost importance (say, certain parts of a video encoder) or if you need direct access to parts of the machine (like writing an OS). But usually you can get the same performance while staying in C, and even an OS only needs a small amount of assembly to manage the hardware.
5
u/felipec Oct 04 '13
It's still necessary in many cases.