Abstract
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.
Keywords
Introduction
Programming is an essential skill in the present digital world (Yusuf & Noor, 2023), and learning to code is becoming more common across educational settings (Popat & Starkey, 2019). Despite its significant importance in problem-solving and computational thinking skills (Yusuf et al., 2023), novice programmers often encounter a steep learning curve as they grapple with the complex nature of programming (Lahtinen et al., 2005). In addition to the inherent complexity of programming, novice programmers often display several psychological behaviors that can significantly compound their learning challenges (Nolan & Begin, 2016; Unal & Topu, 2021). Among these behaviors is a prevalent psychological phenomenon known as programming anxiety (PA). Programming anxiety may arise from the fear of making errors (Charles & Gwilliam, 2023), the relentless pursuit of optimal code efficiency (Connolly et al., 2009), or simply the overwhelming complexity of programming concepts, tools, and environments (Chang et al., 2024; Yildirim & Ozdener, 2022).
A literature synthesis provides more explanation of the aforementioned drivers of PA. As Connolly et al. (2009) pointed out, PA often stems from the intense pursuit of optimal code efficiency. This challenge is more pronounced among novice programmers, whose mental schemas and programming skills are still in the developmental stages. The underdevelopment of these mental schemas and skills contributes to feelings of apprehension when novices encounter the complexities of coding and the demands for efficient solutions. In addition, the occurrence of error messages can potentially engender feelings of discouragement among students who have not yet attained the requisite proficiency to rectify such errors (Charles & Gwilliam, 2023). This emotional response can instigate heightened anxiety, which can serve as a formidable impediment to the process of learning (Warr & Downing, 2000).
A more prevalent driver of PA is the vastness of the programming domain (Demir, 2022). With the plethora of programming languages, libraries, and frameworks, novice programmers may struggle with “decision paralysis” (Robins, 2019) – a situation where an individual is unable to make decisions due to the presence of a complex array of options. In this situation, they might question whether they are investing their time in the right language or framework, which can lead to confusion and self-doubt (Savage & Piwek, 2019).
The scholarly literature extensively acknowledges the influence of positive emotions in the context of learning, as they are seen to bolster self-assurance and active participation (Sinatra et al., 2014; Villavicencio & Bernardo, 2016). In contrast, studies have indicated that adverse emotions are a predictive variable of diminished learning outcomes (Pekrun et al., 2017). In the context of programming, this may include suboptimal coding quality, limited proficiency in debugging errors, and reduced efficiency in program completion, among others. Recognizing and addressing these emotions are crucial for creating a more nurturing and supportive environment for novice programmers.
Numerous research endeavors have investigated programming-related anxiety (e.g., Charles & Gwilliam, 2023; Connolly et al., 2009; Demir, 2022; Yildirim & Ozdener, 2022). However, there appears to be a paucity of empirical studies dedicated to the exploration of clusters of anxiety-induced behavior in different programming environments and their potential utility in predicting the differentials of programming learning outcomes. Specifically, while different programming environments are developed to reduce programming difficulty and promote meaningful learning, understanding how students react to these environments remains underexplored.
This study, therefore, addressed this gap by investigating the distinct clusters of anxiety responses elicited in block-based and text-based programming environments and how these clusters affect programming learning outcomes. Identifying these clusters is crucial as it allows for tailored interventions, assessment frameworks, and support strategies that can more precisely address the specific needs of different groups of students. Overall, this study advances the field of programming education by promoting inclusivity and more effective support mechanisms for all learners. It also advances the field of psychology by providing deeper insights into the psycho-emotional dimensions of novice programmers’ experiences, bridging the gap between psychology and computer science. The study addressed five main research questions: 1. What is the level of anxiety-induced behaviors among novice programmers during text- and block-based programming tasks? 2. What is the level of programming quality and error debugging skills among novice programmers during text- and block-based programming tasks? 3. Are there significant differences in anxiety-induced behaviors among novice programmers during text- and block-based programming tasks? 4. What clusters of anxiety-induced behaviors exist among novice programmers in text- and block-based programming environments? 5. Do anxiety clusters predict program quality and error debugging skills? 6. Do personality traits, gender, and computer experience moderate the relationship between anxiety clusters and programming learning outcomes?
Literature Review
Theoretical Explanations of Programming Anxiety
Programming anxiety (PA) can be examined through various theories of anxiety. By understanding it from the lens of psychological theories, researchers can gain insights into the sources, triggers, and consequences of this anxiety in the context of software development and programming tasks. One key framework that can help understand PA is the Cognitive-Behavioral Theory of Anxiety. According to this framework, anxiety often arises from negative thought patterns and irrational beliefs (Beck et al., 1985). In the case of PA, individuals may develop negative beliefs about their coding abilities, fearing that they will make errors or fail to meet project deadlines. These negative thoughts can perpetuate anxiety and create a self-fulfilling prophecy, as anxious individuals may become more prone to mistakes and missed deadlines.
Additionally, the Evolutionary Paradigm (Marks & Nesse, 1994) suggests that anxiety is an adaptive response that has evolved to help humans survive in challenging environments. In the context of programming, the fear of making errors or failing to meet project deadlines can be seen as a contemporary manifestation of this ancient adaptive mechanism. While modern programming tasks may not carry the same life-or-death consequences as ancestral threats, the same physiological and psychological responses associated with anxiety can still be triggered to help solve demanding problems.
Furthermore, the Yerkes-Dodson Law (Yerkes & Dodson, 1908), a principle from the field of psychology, is pertinent to understanding the relationship between anxiety and performance in programming. According to this law, there is an optimal level of anxiety for peak performance. While low levels of anxiety may lead to complacency, excessive anxiety, such as that experienced by programmers under pressure, can hinder performance. The concept of anticipatory anxiety, as outlined in the Anxiety Sensitivity Theory (Reiss & McNally, 1985), is particularly relevant to PA. Anticipatory anxiety occurs when individuals fear potential negative outcomes in advance of an event. Programmers often experience anticipatory anxiety as they anticipate the challenges and uncertainties associated with coding and software development. This anxiety may manifest in physical symptoms like sweating, increased heart rate, and muscle tension.
While the general concept of PA is well-explained by the above theories, it is important to consider how different programming environments might induce anxiety levels. However, investigating anxiety differences within these environments can be challenging due to the inherent variability in task complexity, which can induce anxiety (Chang, 2005). For instance, block-based programming environments often reduce cognitive load and perceived difficulty because they were originally designed to be more user-friendly and visually intuitive (Yusuf & Noor, 2023). This reduction in cognitive load can lead to lower anxiety levels compared to text-based environments, which require higher syntactical precision and abstract thinking (de Siqueira et al., 2022). These inherent task demands can threaten the internal validity of studies comparing these environments. Therefore, it is crucial to account for the influences of task demands when designing research and interpreting results.
Profiles of Anxiety-Induced Behaviors
Across the academic literature, various studies have systematically categorized anxiety-induced behaviors into distinctive profiles, often referred to as clusters. For instance, Stapp et al. (2022) conducted a study involving 2911 adolescents and identified three anxiety profiles: “Mood Generalized Anxiety Disorder” (Mood-GAD), characterized by a combination of non-atypical depression, mania, and generalized anxiety (25.6%); “Atypical-Panic”, with atypical depression and panic (11.3%); and the “Reference” profile (63.1%), associated with lower mood and anxiety-specific phobia. Similarly, in a study involving 745 students, Möcklinghoff et al. (2021) found five distinct anxiety profiles: low anxiety, mid-low anxiety, mid-high anxiety, high anxiety, and low interference.
In the Spanish context, Fernández-Sogorb et al. (2021) conducted research on 756 Spanish students and identified three main anxiety profiles: “high anxiety”, “school-based performance anxiety”, and “low anxiety”. Furthermore, Lowe (2021) investigated 592 students from nine middle and high schools in the United States, resulting in the identification of three latent profiles: low, middle, and high anxiety profiles. Despite the existing array of anxiety profiles in the literature, none offer a comprehensive understanding of the complex dynamics of anxiety-induced behaviors encountered during coding. Recognizing these profiles and their implications is paramount for educators and institutions striving to provide effective support to students in addressing and alleviating anxiety-related challenges that impact programming learning outcomes.
Relationship Between Anxiety and Learning Outcomes
Empirical studies have underscored the substantial influence of anxiety-induced behaviors on learning outcomes. These studies have identified a spectrum of adverse effects associated with anxiety, including diminished cognitive function (Edwards et al., 2022), impaired problem-solving abilities (Romano et al., 2019), and a pronounced decline in motivation and self-efficacy (Iyamuremye et al., 2023). These general assertions are also valid in the field of programming. For instance, previous research (Olipas et al., 2021) revealed a significant and negative correlation between anxiety and programming performance (r = −0.23, p = .000). A synthesis of this finding suggests that anxiety can hinder students’ ability to grasp and apply programming concepts, resulting in complications to complete coding tasks and ultimately leading to diminished programming performance.
Research evidence also suggests that anxiety-induced behaviors significantly impede students’ coding performance by hindering their comprehension and application of programming concepts (Connolly et al., 2009). This, in turn, undermines academic achievement, contradicting the primary objectives of programming education. Furthermore, programming anxiety tends to intensify during high-stakes testing situations (Tomić et al., 2022), where the fear of failure, combined with stringent time constraints and the critical nature of assessments, heightens anxiety levels. These anxiety-inducing factors collectively challenge students’ ability to recall programming concepts and apply them effectively during examinations (Tomić et al., 2022).
Factors Moderating Anxiety-Learning Outcome Relationship
Research has shown that despite the significant relationship between anxiety and learning outcomes, such a relationship may be moderated by external factors. Variables such as task complexity, personality traits, and gender have been widely discussed. Although no moderation effect of these variables was found, direct effects on both anxiety and learning outcomes were frequently reported (Hayat et al., 2020; Liu et al., 2023), suggesting their potential moderation role. However, an empirical caveat is in order. While the predictive role of personality traits was consistently reported, that of gender depends on discipline. For example, Justicia-Galiano et al. (2023) found that female students were perceived as being more prone to anxiety in mathematics than male students, leading to differences in performance. In contrast, Apridayani et al. (2023) reported no gender differences in overall students’ anxiety in English learning (t = 0.212, p = .832).
A plausible explanation for the inconsistent gender correlation is rooted in gender theory (Jule, 2014). This theory conceptualizes gender as categories of social expectations, roles, and behaviors. Although this view remains controversial in the literature, it does infer that some social activities are gender-stereotyped. Proponents of this view argued that disciplines such as mathematics and computing are perceived to be masculine and, therefore, females are more likely to struggle in these disciplines. Besides personality traits and gender, studies have shown that other programming-specific variables exhibit the potential to moderate the relationship between anxiety and learning outcomes. These include computer proficiency, prior programming knowledge, and math anxiety (Chang, 2005; Connolly et al., 2009; Nolan & Begin, 2016; Owolabi et al., 2014). Investigation of the moderation roles of the variables is important to understand the complex landscape of anxiety.
Methodology
Participant Recruitment
The analysis in this study is based on primary data collected in the Winter of 2022, running through the Spring of 2023 at a small university in Nigeria. The study employed a true experimental approach involving pretest and posttest design to observe each participant’s anxiety-induced behaviors, program quality, and error-debugging skills on eight distinct occasions. Participants included 83 year-two undergraduates enrolled in the “Introductory Programming” course (mean age = 19.5, male = 57, female = 26). The recruitment process involved a random assignment of participants to either a block-based programming group (n = 41) or a text-based group (n = 42). All the participants reported no prior knowledge of either block- or text-based programming.
Before the commencement of the study, participants were provided with an information sheet detailing the study’s objectives and were given the option to withdraw their participation at any point, with the assurance that their data would be promptly deleted upon their request. Subsequently, participants were required to carefully review and sign a consent agreement. Furthermore, participants were guaranteed the utmost privacy, with their data securely stored on an encrypted hard drive. The study received approval from an institutional review board, affirming its ethical and methodological compliance.
Instruments
Because anxiety is an elusive concept, its measurement is done using various assessment tools, including self-reports, physiological assessments, physical examination, and behavioral observation. For example, the use of electrocardiogram (ECG) and wearable devices for monitoring physiological indicators of anxiety has been validated in numerous studies (e.g., Baygin et al., 2024; Villarejo et al., 2012). These tools provide real-time, objective data on physiological responses associated with anxiety. Additionally, self-report measures such as the Beck Anxiety Inventory (BAI, Beck et al., 1988) and Hamilton Anxiety Scale (HAM-A, Hamilton, 1969) have been extensively validated and employed to assess individuals’ anxious states (Hallit et al., 2020; Muntingh et al., 2011; Oh et al., 2018). Lastly, observational methods, which involve annotating behavioral indicators of anxiety such as restlessness, fidgeting, and facial expressions, are commonly used in psychological research to complement self-report and physiological measures (Mian et al., 2015).
Studies have shown that the triangulation of data from these assessment tools enhances the comprehensive understanding and validity of anxiety assessments. Based on these arguments, our study integrates multiple well-established tools to provide a comprehensive assessment of students’ anxiety levels during coding tasks. Subsequently, we collected anxiety indicators using a combination of physiological, behavioral, and self-reported instruments. Physiological indicators, such as heart rate (HR) and heart rate variability (HRV) were assessed using an Apple Watch and ECG machine. The Apple Watch (series 9, 45 mm, GPS + Cellular) was employed as a wearable device for HR and HRV assessment. The ECG machine, on the other hand, was also employed to measure rhythms and electrical signals of the heart (HR and HVR) with the following specifications: BTL 5000 (Glasgow), 12-lead standard with <10 mA leak current, ≥50 MΩ input impedance, and 0.67 ∼ 100 Hz (-3 dB) response frequency.
For the measurement of behavioral indicators, including parameters like sweating, fidgeting, tension, and eye gaze, the camera system of the iPhone 15 Pro was employed. The iPhone was securely mounted on a tripod stand, positioned at a height of 1.43 m above the ground surface, facing the student. To ensure the highest quality of recording, the camera settings were configured to include a 0.5x digital zoom, 4K resolution, and cinematic mode.
In addition to the behavioral and physiological data, participants’ self-reported data were collected using the Beck Anxiety Inventory (BAI, Beck et al., 1988). Across the literature, several scales have been developed to assess programming anxiety, including the Programming Anxiety Scale (Yildirim & Ozdener, 2022), the Programming Anxiety Survey (Figueroa & Amoloza, 2015), the Computer Programming Anxiety Questionnaire (Connolly et al., 2009), and the Computer Programming Anxiety Scale (Choo & Cheung, 1991). While these scales measure programming-related anxiety, their items often address anxiety in a broader context. For example, items such as “I feel tense when my friends talk about programming topics that I don’t understand” (Yildirim & Ozdener, 2022) and “I think that learning programming is enjoyable” (Figueroa & Amoloza, 2015) are not designed to capture specific apprehensive behaviors during instant coding tasks.
Conversely, the BAI is particularly relevant for measuring specific anxiety behaviors during task performance. Items such as “numbness or tingling”, “feeling hot”, “inability to relax”, “nervous”, “shaky”, and “hands trembling” are indicative of the immediate anxiety responses that can manifest during programming. The BAI is a 21-item inventory where participants rate each item on a 4-point scale, ranging from 0 (not at all) to 3 (severely). The scale has demonstrated high internal consistency, with a reliability coefficient of 0.92, and has been widely utilized in various research studies.
Measurement Indicators.
Note. α = Cronbach’s alpha, n/a = not applicable.
Experimental Setup
The study was conducted within a formal classroom setting, where each participant group received programming instruction facilitated by a projection board (Figure 1). The block-based group was introduced to Alice 3, a block-based programming environment that enables the creation of animations and games, while the text-based group was exposed to Java programming. The curriculum encompassed four key programming topics, which included sequences, conditionals, loops, and methods. For each of these topics, participants initially attended a lecture spanning 6 hours, divided into three 2-h sessions, and conducted at different time intervals. Subsequently, they engaged in task-based sessions designed to expose them to programming tasks pertaining to program quality and error debugging that corresponded to the respective topic. Participants in the block-based group receiving lectures on the fundamentals of Alice-3D.
Although the lectures were attended collectively by all group members, the task-based sessions were conducted through individual scheduled observations. During this process, we assessed participants’ programming anxiety throughout the study using the instruments previously described. Because the use of ECG in a typical classroom setting is not feasible due to costs and training requirements, each student was placed in a controlled science laboratory and monitored by a paid ECG specialist. The Apple Watch was affixed to the participants’ left wrist, while the ECG leads were strategically placed to allow for unimpeded coding (see Figure 2). Specifically, the chest leads (V1 to V6) were positioned on the chest according to standard anatomical landmarks to capture cardiac activity effectively. Limb leads (RA, LA, RL, LL) were placed on the shoulder for the arms and on the lower abdomen for the legs, ensuring they did not interfere with participants’ movement while coding. Set up of the task-based session.
To prevent potential confusion of anxiety indicators with other psychological or behavioral symptoms, we maintained a controlled room temperature between 21°C and 23°C. Additionally, each student’s observation was carried out individually to account for potential social anxiety disorders. We eliminated time constraints, permitting participants to complete tasks at their own pace. Finally, we ensured adequate lighting tailored to individual preferences and maintained a quiet environment to minimize factors that might induce anxiety and impact mental well-being
Programming Tasks
As previously discussed, participants were initially exposed to four programming topics within their designated learning environments before engaging in task-based sessions. However, the task-based sessions were designed to encompass two broad problem domains: program quality and error debugging skills. In the “program quality” task, participants were presented with either a visual or a textual representation of problems and tasked with developing lines of code to either solve or simulate the given problem (see Figures 3 and 4). On the other hand, in the “error debugging” task, participants encountered virtual worlds or textual code and were instructed to identify and rectify errors (see Figures 5 and 6). Topic: Sequences; Task: program quality; Description: A sample of student tasks in the block-based group requiring participants to watch the sequential hand movement of the Biped and implement a code in Alice to accurately mimic the movement. Topic: Loops; Task: program quality; Description: A sample of student tasks in the block-based group requiring them to watch the repeated 3-step movement patterns of an adult Biped, implement a corresponding animation to mimic the movement, and increase the movement steps to 6 before greetings. Topic: Loops and Methods; Task: error debugging; Description: A sample of student tasks in the text-based group requiring them to run a Java code, and identify, and fix errors in the code. Topic: Loops and Method; Task: error debugging; Description: A sample of student tasks in the block-based group requiring them to watch a bouncing ball that illustrates the repetition of events. The bouncing of the ball was implemented in a separate method block using a loop function. However, the code contains an error because half of the ball goes into the ceiling of the classroom at each bounce. Participants are required to fix this error in the method block by limiting the height at which the ball can go.



Procedures of Task-Based Sessions.
Data and Scoring
We collected data from various indicators across different phases of the task-based sessions. The HR and HVR data recorded from the Apple Watch were extracted from the iPhone Health app at an interval of 5 seconds and the means were computed for each participant. In addition, the ECG was constantly monitored by an ECG specialist for cardiac arrhythmia, and the results were also recorded at an interval of 5 seconds. Before the intervention, both the ECG and Apple Watch were calibrated to provide accurate heart rate and heart rate variability data. The data collected from these devices were cross-validated and found to be highly consistent with each other (see Figure 7). This aligns with prior results (Falter et al., 2019; Saghir et al., 2020). Similarity in HR and HVR between Apple Watch and ECG in Block-based group.
For this reason, we computed the mean score of the two measurements to obtain a composite, continuous score. Subsequently, we transformed these heart-related indicators into categorical structures to understand their multimodal distribution. A heart rate (HR) falling within the range of 60–100 signifies a normal heartbeat, values between 101 and 105 indicate a slightly elevated heart rate, whereas heartbeats exceeding 105 are indicative of a highly elevated heart rate. This classification aligns with findings from prior medical studies (e.g., Avram et al., 2019).
Participants’ program quality was recorded in a grading rubric based on three constructs, each having a maximum of 10 points: readability, correctness, and reliability. Furthermore, their error debugging skills were recorded on two constructs: error identification (10 points) and error fixing (15 points). We employed a categorical structure to classify these learning outcomes. For programming quality, scores falling within 0–15 indicate low programming quality, while values between 16 and 30 indicate high programming quality. For error debugging skills, scores between 0–12 indicate low error debugging skills whereas scores between 13 and 25 indicate high error debugging
While we believe in the power of technology to automatically detect emotional indicators, we opted for manual coding of the video data due to our limited knowledge of deep learning algorithms. Therefore, we manually annotated the video in steps of 5 seconds on a one-dimensional, continuous rating scale (see Figure 8). One prior study has confirmed that 5-s intervals are long enough to include sufficient information about a behavior and short enough to provide an adequate number of discrete data points for statistical analysis (Yusuf et al., 2023). Template for behavioral annotation.
The continuous rating scale ranged from 0, indicating calm behavior, to 5, indicating extreme anxiety. Values closer to 3.5 indicate mild anxious behaviors. Lastly, the total score of the participants’ self-report from the BAI is calculated by summing the scores of individual items. Scores between 0 and 21 are indicative of low anxiety, scores between 22 and 35 suggest moderate anxiety, and scores exceeding 35 signify elevated levels of anxiety. Across all the indicators, we implemented a categorical framework along with the continuous rating. This approach was adopted to align with the underlying assumptions of the various statistical models utilized throughout this research.
Procedure
Our study commenced with obtaining ethical approval from the Institutional Review Board, followed by the recruitment of participants and their subsequent consent approval. Before the commencement of the interventions, we assessed participants’ anxiety levels in the absence of any exposure to task-based coding. Simultaneously, we assessed potential heart and breathing problems to exclude affected participants from the study. Upon initial assessment, none of the participants reported heart or breathing problems nor did the assessment indicate any Bradycardia (low heartbeat) or Tachycardia (high heartbeat). Following the coverage of each lecture topic, participants were exposed to two distinct task-based sessions, during which we recorded data on their anxiety levels, program quality, and error-debugging skills. Anxiety levels of the participants were documented both before and during each task-based session (30-min intervals) using the ECG machine and the Apple Watch.
Additionally, participants received pre-counseling sessions before each task-based session to mitigate potential apprehension regarding the clinical and physiological instruments used. Post-counseling sessions were also conducted to address any potential post-traumatic stress. To ensure the fidelity and effectiveness of our intervention, we initiated the research process by ensuring uniformity in instructional content across all intervention groups and implementing the content within similar timeframes. While we acknowledge that block-based tasks may be inherently less challenging for university students, the tasks assigned to students in both groups were similar in terms of difficulty level. This was done to control for the influence of task demand, which may also induce anxiety.
After the completion of the interventions, the Big Five Inventory and baseline survey were administered to collect participants’ personality traits, gender category, and computer experience. Overall, the study complied with the Code of Ethics of the World Medical Association (Declaration of Helsinki). For an overview of the data collection process, refer to Figure 9. Data collection flowchart.
Data Analysis
We explored the participants’ level of anxiety-induced behaviors (RQ1) and their programming quality and error debugging skills (RQ2) using descriptive statistics involving mean and standard deviation. We conducted further analysis to understand differences in the levels of anxiety across the experimental and control groups (RQ3) using multivariate analysis of variance. Our cluster analysis (RQ4) commenced with the identification of potential latent conditions that produced the anxiety behaviors. To achieve this, we employed the Hidden Markov Model (HMM, depmixS4 R package, Visser & Speekenbrink, 2010), a probabilistic framework where the observed behaviors are modeled as a series of outputs that emerged from one of several latent conditions (Andrade et al., 2016; Yusuf et al., 2023).
We then proceeded to classify the observed anxiety-induced behaviors into clusters based on the latent conditions using the Optimal Matching (OM) algorithm (TraMineR package, Gabadinho et al., 2011), which estimated pairwise dissimilarity of a time-ordered sequence of behaviors. We used the clusters of anxiety-induced behaviors (RQ5) to predict participants’ programming quality and error-debugging skills using multinomial logistic regression (nnet R package). Lastly, we included the moderating variables (gender, personality traits, and computer experience) to investigate the effect of these variables on the relationship between anxiety and programming learning outcomes (RQ6). All analyses addressing research questions one through three were conducted in SPSS version 28 while those of research questions four through six were performed in R package version 4.3.1.
Results
RQ1: What is the Level of Anxiety-Induced Behaviors Among Novice Programmers During Text- and Block-Based Programming Tasks?
Level of Anxiety-Induced Behaviors Across Groups.
Figure 10 provides additional details on the variability of anxiety-related behaviors across the block- and text-based groups. Before the treatment, responses on heart rate (HR), heart rate variability (HRV), and self-report show similar optimal patterns across the groups, with similar variability among participants. However, differences emerge after the treatment. For instance, at normal state, participants in both groups start with an optimal heart rate of 63 b/m (SD = 9.34), a heart rate variability of 58 ms (SD = 6.64), and a self-reported anxiety score of 18.9 (SD = 4.30). During the programming tasks, their respective heart indicators differ, with the text-based groups showing more elevated physiological responses. The text-based group also showed a more elevated response on the anxiety inventory which was collected immediately after the task-based sessions. Mean HR, HRV and Self-report responses on pre- and post-test across groups. Note. Points represent mean scores, bar plots represent variability (i.e., standard deviation).
RQ2: What is the Level of Programming Quality and Error Debugging Skills Among Novice Programmers during Text- and Block-Based Programming Tasks?
Level of Programming Quality and Error Debugging Skills.
RQ3: Are There Significant Differences in Anxiety-Induced Behaviors Among Novice Programmers during Text- and Block-Based Programming Tasks?
Multivariate Differences of Anxiety Indicators.
Univariate Differences of Anxiety Indicators.
Note. HR = heart rate, HRV = heart rate variability, SelfR = self-report, Obs = observed.
RQ4: What Clusters of Anxiety-Induced Behaviors Exist Among Novice Programmers in Text- and Block-Based Programming Environments?
We estimated the Hidden Markov Model (HMM) to model the anxiety indicators (data collected from self-report was not included). Before this, a model fit analysis was conducted, indicating the adequacy of three distinct classes in our current datasets. Put differently, five HMMs with 2–6 states were fit to the data, and 3 latent states was selected because it fits our model best (3-state AIC = 455.745, 3-state BIC = 626.036, log Lik = −129.87).
Anxiety-Induced Behavioral Probabilities.
The second state was interpreted as the ‘hesitant’ state. This is a condition where participants struggle to make decisions, leading to a slightly elevated heartbeat (Block: prob. = 0.608; Text: prob. = 0.817), slightly low heart rate variability (Block: prob. = 0.619; Text: prob. = 0.925), and a propensity to exhibit a mild behavior that results in wasting of time without performing their assigned tasks (Block: prob. = 0.776; Text: prob. = 0.956). Andrade et al. (2016) characterized hesitant conditions as silent pauses and unfocused situations where people spend much time in a state of heightened apprehension before making decisions. Lastly, the third latent state was interpreted as ‘anxious’ state. In this condition, the participants are in a state of apprehension as characterized by their elevated heartbeat (Block: prob. = 0.588; Text: prob. = 0.652), low heart rate variability (Block: prob. = 0.687; Text: prob. = 0.881), and observed anxious condition (Block: prob. = 0.643; Text: prob. = 0.669). Guerrero et al. (2023) characterized an anxious state as a state of pervasive experience shared by individuals in an attempt to complete a task or meet social obligations.
The main goal of profile analysis is to identify transition instances across different latent states (Yusuf et al., 2023). Therefore, we further our analysis to identify different transitions in the participants’ anxiety-induced behaviors. We found two prominent transition instances in each of the intervention groups (see Figure 11). In the block-based group, some participants frequently transition from the ‘anxious’ to ‘calm’ state, with an average probability of 0.5. In addition, some participants transitioned from the ‘hesitant’ to ‘calm’ state, with an average probability of 0.6. However, a large proportion of the participants in this group stayed within their ‘calm’ state with a probability of 0.8. Conversely, in the text-based group, some participants frequently transitioned from the ‘anxious’ to ‘hesitant’ state (transition prob. = 0.4) while some transitioned from the ‘calm’ to ‘hesitant’ state (transition prob. = 0.6). However, a larger proportion of the participants in this group stayed within the ‘anxious’ and hesitant state with a probability of 0.6. Transition probabilities.
Using the transition probabilities, we created a data matrix that explains each transition. We searched for typologies of the participants’ profiles from the data matrix and identified representative sequences of the latent states using the optimal matching (OM) algorithm. The OM algorithm reveals the presence of three representative sequences across the block- and text-based groups (see Figures 12 and 13). In the block-based group (see Figure 12), the first profile consists predominantly of participants who allocate approximately 87% of their time to the ‘calm’ state, exhibiting minimal transitions to the ‘hesitant’ and ‘anxious’ states. Notably, these participants display an average task completion time of 23 minutes and 56 seconds for each programming task. We designated this profile as ‘stay calm’, and it encompasses 46.3% of the classroom population. Anxiety clusters in block-based group. Anxiety clusters in text-based group.

The second profile within this group encompasses a substantial portion of participants who allocate approximately 75% of their time to the ‘hesitant’ state, with limited transitions observed to the ‘calm’ and ‘anxious’ states. These participants exhibit an average task completion time of 56 minutes and 5 seconds, and we designated this profile as ‘stay hesitant’. Participants in this category constitute 14.6% of the classroom population. The third profile encompasses a considerable cohort of participants who allocate minimal time to the ‘hesitant’ and ‘anxious’ states. However, these individuals exhibit a pronounced propensity to transition towards the ‘calm’ state. We, therefore, labeled this profile as ‘to-calm’, representing approximately 39.1% of the classroom population.
In contrast, within the text-based group (see Figure 13), a segment of the population (23.8%) demonstrates frequent transitions from the ‘anxious’ and ‘calm’ states to the ‘hesitant’ state. We categorized this group as ‘to-hesitant’. The second profile in this group encompasses participants who allocate around 66% of their time to the ‘hesitant’ state, thus labeled as ‘stay-hesitant’. Finally, the third profile comprises a substantial segment, encompassing 42.9% of the population, where participants spend a significant 88% of their time in the ‘anxious’ state. These participants exhibit an average task completion time of 14 minutes and 55 seconds, and we denoted this profile as ‘stay anxious’. In summary, the analysis of these profiles sheds light on the distinct patterns of anxiety-induced behaviors within the realms of block-based and text-based coding. These profiles highlight the importance of recognizing the unique challenges and needs of students in both coding environments and the potential implications for pedagogical strategies and support mechanisms.
RQ5: Do Anxiety Clusters Predict Program Quality and Error Debugging Skills?
We further our analysis to understand how each anxiety cluster associates with program quality and error-debugging skills (see Figures 14 and 15). According to our statistical models, novice programmers within the ‘stay calm’ profile exhibited a 2.57-fold likelihood of achieving high scores in program quality (estimate = 0.95, Odd Ratio [OR] = 2.57, 95% CI [1.37–2.65], p-value <.000) and excelling in error-debugging skills (OR = 2.03, 95% CI [1.58–2.61], p-value <.000). Furthermore, participants belonging to the ‘stay hesitant’ cluster demonstrated a 1.08-fold likelihood of attaining lower scores in program quality (estimate = 0.76, OR = 1.08, 95% CI [0.62–1.88], p-value <.001) and a 2.18-fold likelihood of encountering challenges in error debugging (estimate = 0.78, OR = 2.18, 95% CI [1.19–4.01], p-value <.001). Additionally, they faced a 0.13-fold likelihood of achieving diminished scores in error-debugging skills (estimate = −2.04, OR = 0.13, 95% CI [0.09–0.17], p-value <.001). Estimates and odds ratios for program quality among anxiety clusters. Estimates and odds ratios for error-debugging skills among anxiety clusters.

In contrast, participants in the ‘stay anxious’ cluster exhibited a 2.73-fold likelihood of obtaining lower scores in program quality (estimate = 1.03, OR = 2.73, 95% CI [1.63–2.83], p-value <.000) and a 2.10-fold likelihood of encountering difficulties in error-debugging skills (estimate = 0.74, OR = 2.10, 95% CI [1.50–2.93], p-value <.000). Conversely, individuals affiliated with the ‘to-calm’ cluster had a 1.66-fold likelihood of producing high-quality code (estimate = 0.51, OR = 1.66, 95% CI [1.36–2.02], p-value <.003) and efficiently addressing error debugging tasks (estimate = 0.63, OR = 1.48, 95% CI [0.91–2.41], p-value <.01). Lastly, the ‘to-hesitant’ group displayed a 1.26-fold likelihood of achieving lower scores in error-debugging tasks (estimate = 0.68, OR = 1.26, 95% CI [1.24–1.28], p-value <.01) compared to their aptitude in handling more challenging error-debugging problems (estimate = 0.65, OR = 1.22, 95% CI [1.02–1.45], p-value <.05).
RQ6 Do Personality Traits, Gender, and Computer Experience Moderate the Relationship Between Anxiety Clusters and Programming Learning Outcomes (Program Quality and Error Debugging)?
From the results presented in Figures 14 and 15, it is apparent that despite reaching relatively high odd ratios closer to 1, personality traits, gender, and computer proficiency did not significantly moderate the relationship between anxiety-induced behaviors and programming learning outcomes (program quality and error debugging skills). This result suggests that distinct clusters of anxiety-induced behaviors may have main effects on programming learning outcomes but their interaction with other external variables such as personality traits, gender, and computer proficiency may diminish the effects. Overall, these results shed light on how anxiety-induced behaviors are associated with programming performance and provide insights for educators seeking to enhance students’ programming skills and reduce their anxiety-related challenges.
Discussion
The study explored the clusters of anxiety-induced behaviors during coding in two programming environments and predicted students’ programming quality and error-debugging skills using information from the clusters. Differences in the anxiety indicators across the groups were also estimated. Our study has unveiled essential discoveries for elucidating the programming performance of novice individuals.
Firstly, we observed that participants engaged in programming tasks within the text-based environment exhibited higher probabilities of experiencing heightened levels of anxiety, as indicated by elevated heart rate, reduced heart rate variability, and self-reported feelings of apprehension. In contrast, the block-based group demonstrated normal cardiac rhythm indicators and displayed calmer physiological conditions during coding, revealing a significant difference between the two groups. Based on these findings, we hypothesize that there exists an interplay between psychological apprehension and the inherent characteristics of programming environments. These findings are consistent with existing literature that links increased emotional arousal with coding environments (de Siqueira et al., 2022). For instance, de Siqueira et al. (2022) observed that students using fableBlocks, a block-based environment, showed lower levels of PA compared to those using a traditional GUI text-based environment, although these differences were not statistically significant.
Moreover, the relative optimal emotional states observed in the block-based group imply potentially greater adaptability in the programming environment, which may contribute to a more favorable cognitive state (de Siqueira et al., 2022). Although such greater adaptability has been linked to the activation of autonomic nervous system responses (Choi et al., 2021), prior studies in the computer science literature showed that text-based programming environments are associated with high emotional distress due to their perceived complexity and cognitive load (Demir, 2022; Stefik et al., 2013). However, one recent study disagrees with our findings by indicating the insignificant effect of programming environments on anxiety (Unal & Topu, 2021).
As we consider the broad spectrum of anxiety-induced behaviors, we observed that evaluating anxiety differentials across diverse programming environments based solely on averaged anxiety scores may not provide a comprehensive assessment of whether one environment elicits more anxiety than the other. Therefore, we considered a more nuanced approach that involves moment-to-moment behaviors through group clustering. Our analysis revealed three representative profiles in each group: block-based (stay calm, stay hesitant, and to-calm) and text-based (stay hesitant, stay anxious, and to-hesitant). Each profile is characterized by its distinct nature of apprehension or confidence.
Consistent with these profiles, available pieces of research evidence have shown that some groups of students share similar patterns in learning and testing environments, manifesting through their engagement (e.g., Perkins et al., 1986; Rodrigo et al., 2009; Yusuf et al., 2023) and apprehensive behaviors (Lowe, 2021; Stapp et al., 2022). In the context of programming, previous clinical investigations of novice programmers (e.g., Perkins et al., 1986) suggest that such learning profiles often exist in part because groups of students sharing similar learning characteristics often bring different patterns of learning to the programming context
Notwithstanding the differentials in anxiety profiles, an examination of each cluster concerning programming environments reveals notable distinctions. Firstly, a substantial portion of participants in the block-based group tend to experience a higher degree of calmness (stay calm cluster) in contrast to their counterparts in the text-based group, who tend to exhibit increased anxiety (stay anxious cluster). In scenarios where the block-based environment tends to induce anxiety, participants frequently transition to a state of calm. This transition may be attributed to the inherent features of this environment, which permits the drag-and-drop execution of code and virtual elements. Recent studies have indicated that the block-based environment effectively mitigates syntax errors, which is a primary source of frustration among novice programmers (Yusuf et al., 2023), and offers a visually appealing and sensorially stimulating programming environment for students (Ebel & Ben-Ari, 2006). The elimination of syntax errors and the visually appealing nature of this environment have attracted sustained interest in the realm of programming education and have significantly alleviated the emotional distress associated with text-based programming (Yusuf & Noor, 2023).
In contrast, in situations where the text-based environment is perceived as less intimidating, participants frequently transition to a state of hesitation, potentially indicative of confusion and apprehension stemming from the environment’s inherent demands for syntax recall and textual coding. Although both groups consist of cohorts who remain hesitant throughout their assigned programming tasks, the proportion in the block-based group is smaller than that of the text-based group. Hesitation has been regarded as an emerging learning problem, particularly in cognitive-related tasks. It is considered a natural response when encountering challenges or uncertainties in a given task (Andrade et al., 2016). In the context of coding, it may manifest as a pause, a momentary delay in decision-making, or a temporary loss of focus during the coding process.
As our analysis suggests, hesitation appears to occur more prominently in the text-based coding environment when compared to the block-based counterpart. This finding is intriguing, given the scarcity of studies explicitly addressing hesitation during coding. Studies often link hesitation to the perceived difficulty of a cognitive task, manifesting in different contexts (Betz et al., 2023; rad Khojasteh & Abdullah, 2012). Consistent with these studies, we propose that novices in text-based environments might exhibit more hesitation due to the need for syntax recall and precise textual coding. Notably, these programmers might be more uncertain about the correctness of their code, causing them to pause, re-evaluate, and potentially revise their code.
Our analysis has shown that various clusters of anxiety-induced behaviors predict learning outcomes. Notably novice programmers identified as belonging to the ‘stay calm’ profile displayed a higher likelihood of achieving high scores in program quality and excelling in error-debugging skills. In addition, individuals affiliated with the ‘to calm’ group displayed a higher likelihood of producing high-quality code and efficiently addressing error debugging tasks. However, participants categorized under the ‘stay hesitant’ and ‘to-hesitant’ profiles demonstrated a lower likelihood of attaining high scores in program quality and encountered challenges in error debugging. Lastly, participants in the ‘stay anxious’ cluster exhibited a higher likelihood of producing lower-quality code and facing difficulties in error debugging.
The performance prediction of the anxiety clusters can be understood from the concept of “optimal anxiety” proposed by Yerkes and Dodson (1908). This concept suggests that there is an optimal level of anxiety required to reach peak performance. Put differently, the concept argued that the relationship between arousal and performance follows an inverted U-shape. In our present study, the ‘stay calm’ and ‘to-calm’ profiles may be construed as exemplifying optimal anxiety levels. This is substantiated by their demonstrated ability to maintain optimal heart rate and heart rate variability, in addition to their propensity to sustain a calm behavior during their coding tasks. On the other hand, the ‘stay hesitant’, ‘to-hesitant’, and ‘stay anxious’ profiles may represent high anxiety, thus obtaining lower scores in program quality and error debugging skills.
Studies have confirmed the validity of the optimal anxiety concept (Cuder et al., 2023; Jamil et al., 2022; MacArthur & Santo, 2023). However, a theoretical caveat has been made. Because anxiety is an involuntary action that is often induced by external stimuli, it is impossible to control its optimal level (Diamond, 2005). There is also a disagreement over what constitutes ‘optimal’ arousal (Cohen, 2011). However, as programming educators, we remain adamant through our findings that individuals sharing similar anxiety-related behaviors during coding are likely to exhibit comparable programming performance. Nevertheless, these behaviors may vary according to specific programming environments, suggesting that anxiety level is not universal but a context-dependent phenomenon. In pursuit of programming objectives, we recognize the significance of text-based programming environments in fostering computational competencies (Sun & Zhou, 2023). Simultaneously, we remain cognizant of the potential anxiety-inducing impact that text-based environments may exert on novice programmers when contrasted with block-based alternatives.
We did not find any moderating effect (from personality traits, gender, and computer experience) on the relationship between anxiety-induced behaviors and programming learning outcomes. From this finding, we conclude that the manifestation of programming anxiety may influence the extent to which novices develop quality programs and debug errors regardless of their personality profiles, gender categories, and computer experience. However, we did not rule out any direct effect of these variables on programming learning outcomes but their moderation effect is insignificant in this study.
Conclusion
In the ever-evolving landscape of programming education and cognitive psychology, our study has delved into the complex relationship between anxiety-induced behaviors and programming performance, particularly within the distinct context of block- and text-based environments. As our research findings have illuminated, this examination has not only broadened our understanding of the impact of anxiety on novice programmers’ performance but has also shed light on the influence of coding environments as contextual determinants of these anxiety-induced behaviors. The foundation of our investigation was rooted in the Yerkes-Dodson Law, which postulates an inverted U-shaped relationship between anxiety and performance. This classic framework has guided our exploration of how anxiety manifests among novice programmers and how it subsequently impacts their programming endeavors. Our results, while consistent with the framework to some extent, have added layers of complexity to this relationship.
Specifically, the identification of distinct anxiety profiles, including ‘stay calm’, ‘stay hesitant’, ‘stay anxious’, ‘to calm’, and ‘to hesitant’ has revealed that programming environments indeed play a pivotal role in shaping anxiety-induced behaviors. Not only do these profiles help in understanding the variations in the levels of apprehension among different groups of students but they also provide valuable insights for the integration of customized and individually tailored instructional approaches. We, therefore, emphasize the need for tailored interventions and instructional strategies that consider the contextual clusters of anxiety within programming education. Ultimately, this work contributes to the ongoing efforts to optimize the programming learning experience, enhance performance, and reduce anxiety-induced barriers for novice programmers in any programming environment.
Limitation
While our study has yielded valuable insights into the interplay of anxiety-induced behaviors and programming performance in distinct coding environments, several limitations merit consideration. First, the study’s focus on novice programmers in controlled educational settings may not fully capture the complexities of real-world programming tasks and contexts. The instruments used in this study may exhibit measurement uncertainties. For example, the ECG, while providing accurate heart rate and variability data, can be influenced by factors such as electrode placement and movement artifacts, requiring careful calibration. The Apple Watch offers convenient monitoring but may have reduced accuracy due to wrist movement and fit, potentially affecting heart rate variability measurements. For the Beck Anxiety Inventory (BAI), as a self-reported measure, variability can arise from participants’ mood and interpretation of questions, introducing subjectivity. Lastly, behavioral assessments are susceptible to observer bias and interpretation, influenced by environmental conditions and observer presence.
Lastly, our study did not address the effect of some variables such as self-confidence nor does it measure anxiety-related behaviors such as avoidance behavior and programming failure. While this is beyond the scope of this study, we recommend that future studies should address these crucial variables. Overall, our study has provided avenues for future research to refine our understanding of anxiety in programming education.
Implication for Policy
Despite the limitations of the study, our findings have significant policy implications. First, the study underscores the necessity of incorporating a block-based environment as an initial step in the introductory programming journey before introducing novices to the more demanding text-based programming paradigm. As confirmed by our findings, the latter is characterized by challenges stemming from the need for syntax recall and adherence to strict programming conventions, which often give rise to feelings of frustration and apprehension. Secondly, educational policymakers and institutions must recognize the influence of coding environments on novice programmers’ anxiety-induced behaviors. To foster optimal learning conditions, policy decisions should prioritize the creation of coding environments that promote a balanced state of anxiety, as identified in our study. This may involve the design of curricula and tools that minimize anxiety-inducing factors while enhancing the overall learning experience. Additionally, teacher training and professional development should address strategies for recognizing and managing anxiety among novice programmers. By tailoring policies to these insights, programming education can become more inclusive, accessible, and effective.
Footnotes
Declaration of Conflicting Interests
The author(s) declared no potential conflicts of interest with respect to the research, authorship, and/or publication of this article.
Funding
The author(s) disclosed receipt of the following financial support for the research, authorship, and/or publication of this article: The study was funded by Tertiary Education Trust Fund (TetFund), Nigeria (TETF/ES/UNIV/SOKOTO/TSAS/2020).
Data Availability Statement
The datasets used and/or analyzed during the current study are available from the corresponding author upon reasonable request.
