The study investigates the potential of anxiety clusters in predicting programming performance in two distinct coding environments. Participants comprised 83 second-year programming students who were randomly assigned to either a block-based or a text-based group. Anxiety-induced behaviors were assessed using physiological measures (Apple Watch and Electrocardiogram machine), behavioral observation, and self-report. Utilizing the Hidden Markov Model and Optimal Matching algorithm, we found three representative clusters in each group. In the block-based group, clusters were designated as follows: “stay calm” (students allocating more of their time to a calm state), “stay hesitant” (students allocating more of their time to a hesitant state), and “to-calm” (those allocating minimal time to a hesitant and anxious state but displaying a pronounced propensity to transition to a calm state). In contrast, clusters in the text-based group were labeled as: “to-hesitant” (exhibiting a higher propensity to transition to a hesitant state), “stay hesitant” (allocating significant time to a hesitant state), and “stay anxious” (remaining persistently anxious in a majority of the coding time). Additionally, our results indicate that novice programmers are more likely to experience anxiety during text-based coding. We discussed the findings and highlighted the policy implications of the study.