What are some advanced concepts in programming that most average programmers have never...

Quora Feeds

Active Member
Pat Roberts


Vector processing and vectorized algorithms.

Modern consumer-level CPUs (for the last 15+ years) have been capable of vector processing, but most programmers only use the scalar processing capabilities of CPUs. This is, IMO, primarily because all current popular languages were designed around scalar architectures, no higher level languages yet support robust or easy vector language extensions, and because most programmers are solving problems that are user-input bound, performance isn’t paramount. It increases the speed of some types of math multiple orders of magnitude, and the low-powered CPUs in phones and tablets couldn’t play and record MP4 and similar media codecs without it. It’s currently most commonly used in digital signal processing and image synthesis. GPGPUs are probably the only development platform where knowing how to write vectorized code is unavoidable. Video game console development used to be another, though I don’t know how useful it is for the current gen consoles (PS4, XB1) outside of low-level engine development.

Using the GNU Compiler Collection (GCC) - Vector Extensions

Cg Programming/Vector and Matrix Operations


Dynamic loading

Dynamic loading allows you to hot-swap compiled code on a running executable. Another feature is mod-ability without releasing source. Also potentially lower resource usage and faster execution, for example: MAME has a ton (100+?) emulation cores linked with or into the binary. To run a game only a couple are needed. Each time MAME runs, it loads everything it needs for every game. If the emulation cores were dynamically loaded based on the game selected, load time and memory usage would be significantly lower.


Branch table

This is probably better known, but I rarely see it in code. It’s an optimization technique. If you can reduce any large multiway branch test to an index, you can optimize the flow control using a branch table. Some compilers will reduce a switch statement to a branch table under the right conditions, but I’ve only seen that once, and with ICC. It’s a pretty hard optimization for a compiler to make. (It seems like many developers today assume testing string equality is free or as cheap as it is with primitives, and a compiler doesn’t have a chance to create a branch table with strings.) It works by creating an array of functions, then using the test variable as an index into that array to branch. So for example, in pseudo-code:

Normal:

a=getDropDownMenuSetting();
if(a==”ice cream”) icecream.serve();
else
if(a==”cake”) cake.serve();
else
if(a==”mousse”) mousse.serve();
//etc...more else/if statements


or:

a=getDropDownMenuSetting();
switch a:
case ”ice cream”:
icecream.serve();
break;
case "cake":
cake.serve();
break;
//etc...


A branch table optimizes the multiway branch like this:

const serveDessertFunctionArray[] = [
icecream.serve,
cake.serve,
mousse.serve,
//...etc
]
...
a=getDropDownMenuSettingAsIndex();
serveDessertFunctionArray[a]();



See Questions On Quora

Continue reading...
 
Top