In this chapter, we report two studies in which 3rd- and 4th-grade students used a distributed computing infrastructure (ViMAP-Tangible) in order to collaboratively invent "mathematical machines" for generating geometric shapes. ViMAP-Tangible combines the ViMAP visual programming language with a distributed computing infrastructure, in which students collaboratively control the behavior of a virtual agent using both mechanical devices and virtual algorithms. The curricular activities integrate engineering practices such as user-centered design; agent-based computer programming; mathematical reasoning about multiplication, rates, and geometry; and physical science concepts central to learning Newtonian mechanics. In Study 1, we investigate the key affordances of such a distributed computing environment for learning Integrated STEM, and identify the relationships between the various elements of students' physical constructions and computational models, and their STEM learning outcomes. Study 2 is a deeper investigation of the effect of iterative user testing on the refinement of children's designs and their STEM learning.