Try Blockly
The Blockly library adds an editor to your app that represents coding concepts as interlocking blocks. Arrange blocks in the editor below to generate code in multiple languages. When you're ready, press Play to run the code:
Blockly Basics

The Blockly library adds an editor to your app that represents coding concepts as interlocking blocks. Blockly generates simple, syntactically-correct code from the blocks in the editor, which your app can use to run games, control robots, or do anything else your imagination can concieve.
Built with Blockly
Blockly is already being used by hundreds of projects, most of them educational:
Scratch Blocks
Google and the MIT Media Lab’s Scratch Team are collaborating on the development of a new generation of graphical programming blocks, called Scratch Blocks. Scratch Blocks builds on Google’s Blockly technology and the Scratch team’s expertise in designing creative interfaces for young learners.
Scratch Blocks represents the first step in a broader collaboration between Scratch and Google, focused on developing new software toolkits that enable developers to create consistent, high-quality programming experiences for kids everywhere.