I implemented something like this in Python for my LaTeX/beamer presentation recently. For example, see this and the following slides:<p><a href="https://speakerdeck.com/mmcloughlin/better-x86-assembly-generation-with-go?slide=56" rel="nofollow">https://speakerdeck.com/mmcloughlin/better-x86-assembly-gene...</a><p>The sample code is in a file with special comments at the end of each line specifying which slide numbers it should be revealed on as well as inline commentary to show to the right of the line. Syntax highlighting is provided by Pygments.<p>I was thinking about open sourcing it, it's actually only approx 200 lines of Python but I think it's quite effective.