Background and Context Current programming learning research often compares novices and experienced programmers, leaving early learning stages and emotional and cognitive states under-explored. Objective Our study investigates relationships between cognitive and emotional states and learning performance in early stage programming learners with varying expertise (12 novices and 11 beginners; N = 23). Method Measures such as electrodermal activity, automated facial emotion recognition, and pupil diameter were collected to study cognitive and emotional states during a programming task. We examined how these states correlated with performance and the influence of expertise on these correlations. Findings Multiple regression analysis on panel data (n = 690 observations) suggested fear negatively impacts programming performance, irrespective of expertise level. Meanwhile, programming expertise positively moderated cognitive effort applied to the task. Implications Our findings highlight the importance for educators to design early programming experiences that anticipate and reduce fear and cognitive overload, promoting better learning outcomes.

