Extensive studies have been conducted on programming knowledge, instructional environments and effective pedagogies in order to improve the teaching and learning of computer programming. However, there have been few studies on the usefulness and effectiveness of using simulation. The aim of this paper is two-fold: to describe the design and development of a computer-based simulation tool for learning computer programming and to report a case study of four students' learning experiences using the simulation tool, which provides a learning environment in the context of daily life. In solving the problem posed by the simulation tool, students are encouraged to think and construct their own solutions. Three categories with respect to students' learning processes were observed in the study, namely dynamic learning experience, fostering cognitive approaches and stimulating attitude change. Implications of the simulation for learning programming are also discussed. It is hoped that the simulation tool will inspire students to look beyond a specific simulation and transfer insights gained from the simulation to the learning of computer programming. [Copyright of Educational Media International is the property of Routledge. Full article may be available at the publisher's website: http://dx.doi.org/10.1080/09523980600641452]