That's a pretty neat hack, but I can't think of a worse language for shader programming than javascript :-) Dynamic typing and closures are useful in some domains... but I wouldn't want to run that sort of logic per-pixel on a display with 14 million pixels. Plus declaring the types ahead of time is really important. (highp vs. lowp, type sizes, etc.)