Real-time collaborative programming (RCP), which allows multiple programmers to work concurrently on the same codebase with changes instantly visible to all participants, has garnered considerable popularity in higher education. Despite this trend, little work has rigorously examined how undergraduates engage in collaborative programming when using RCP. This study utilized a quasi-experimental design to investigate the impact of RCP on undergraduates’ programming knowledge and skills, behaviors, and attitudes toward collaboration. Eighty-two participants were randomly assigned to either the RCP group or the Traditional Collaborative Programming (TCP) group. The data analysis yielded noteworthy findings. First, RCP significantly improved learners’ problem-solving skills and led to higher knowledge test scores compared to TCP. Second, there were no significant differences in attitudes toward collaboration between the two groups. Third, analysis of programming behaviors indicated that the RCP group exhibited more efficient coding practices, including producing a greater volume of code and executing it more successfully. Additionally, the RCP group’s code-testing activities were predominantly concentrated at the first half of the class sessions. Based on the empirical research results, three major pedagogical implications were proposed. These findings highlight the benefits of integrating RCP into programming education and suggest avenues for future research into collaborative learning dynamics.