1 Introduction

Science, technology, engineering, and mathematics (STEM) workers are considered as sources of countries’ innovation, competitiveness, productivity and economic growth (Carnevale et al., 2011; Grigg et al., 2018; Hudson et al., 2020). However, nowadays, with evolving social demands, there exists a severe shortage of STEM workforce worldwide (Corin et al., 2020; Luo et al., 2021; Mystakidis et al., 2021; Nguyen & Riegle-Crumb, 2021; Ketenci et al., 2020; Šimunović & Babarović, 2021; Yahaya et al., 2021; Vela et al., 2020). This highlights the critical importance of encouraging STEM-oriented careers and developing STEM professionals for the labor market. Meanwhile, as the value of STEM is increasingly recognized globally, significant efforts have been made to promote STEM education (Ahmed, 2021; Jiang et al., 2021a; Mystakidis et al., 2021). A key goal of STEM education is to increase students’ interest in STEM careers (Karahan et al., 2021; Luo et al., 2021). Worryingly, although a series of initiatives to develop STEM career interest have been practically implemented in various STEM education programs, researchers are concerned that a substantial part of students with high mathematics or science achievements still choose not to pursue STEM careers (Carnevale et al., 2011; Karahan et al., 2021; van den Hurk et al., 2019). This elicits the need to theoretically explore the antecedents of STEM career interests.

With the rapid development of computer sciences over the past two decades, computing practices have been introduced into and driven the advances in STEM fields (Foster, 2006; Weintrop et al., 2016). Against this backdrop, coding plays a more important role in STEM professions (Arslan & Tanel, 2021; Boz & Allexsaht-Snider, 2021; Li et al., 2020; Weintrop et al., 2016). Simultaneously, STEM employees are frequently required to be literate in coding (Weintrop et al., 2016). Moreover, it is predicted that half of the STEM jobs will be computing-related ones in the future, where coding is an indispensable skill (Kaczmarczyk & Dopplick, 2014; Peters-Burton, 2020). Therefore, if students have a low intrinsic interest in coding, they may be reluctant to work as STEM professionals in the computing world. In other words, students’ intrinsic coding interest is very likely to influence their STEM career interests. However, to the best of our knowledge, previous studies have hardly examined coding-related factors as the determinants of STEM career interest. The extent to which and how students’ coding-related factors influence their STEM career interest is theoretically unclear.

The problem motivating our study is the pressing need to explore the antecedents of STEM career interest and the growing importance of coding in STEM careers, coupled with the unclear relationship between intrinsic coding interest and STEM career interest. We targeted senior high school students as participants in this study because usually during adolescence the formative stages of establishing options for their career development take place (Karahan et al., 2021; Robnett & Leaper, 2013; Witko et al., 2005). Specifically, the objective of this research is to examine the direct and indirect impact of intrinsic coding interest on STEM career interest. The larger goal of this study is to predict more coding-related antecedents of STEM career interest theoretically and help educators improve students’ STEM career interest practically on the basis of our findings.

2 Conceptual Framework

2.1 Theoretical foundations

The development of career interest is a complex process (McKenzie et al., 2021; Nugent et al., 2015) and can be interpreted through different theoretical lenses (Akosah-Twumasi et al., 2018). In STEM education contexts, one widely accepted and utilized theoretical framework to predict career interest is the social cognitive career theory (SCCT) (e.g., Abe & Chikoko 2020; Luo et al., 2021; McKenzie et al., 2017; McKenzie et al., 2021; Nugent et al., 2015). It was proposed by Lent et al. (1994), as a derivative of Bandura’s (l986) social cognitive theory. According to the SCCT, students generate their career interest by developing confidence in activities related to their interest and “by learning that outcomes for them are contingent on the effort expended” (McKenzie et al., 2017, p. 16). This indicates that career interest may be influenced by subject matter interest, subject matter confidence and outcome expectancy. When it comes to STEM career interest, Nugent et al., (2015) have clarified that “three key SCCT constructs—interest, self-efficacy, and outcome expectancy—represent underlying antecedents of STEM career choices and performances” (p. 1070). Specifcially, interest describes students’ “liking for” the subjects or skills in the STEM fields (Nugent et al., 2015, p. 1070), self-efficacy describes students’ confidence in the subjects or skills in the STEM fields (Nugent et al., 2015), and outcome expectancy describes students’ perceptions of certain STEM careers “based on their perceived monetary, social, and self-satisfaction outcomes” (Nugent et al., 2015, p. 1071). In particular, outcome expectancy can also be assessed by people’s perceptions of professionals (Abe & Chikoko, 2020; Nugent et al., 2015). Drawing from the SCCT, STEM career outcome expectancy (or perceptions of STEM professionals) and subject matter self-efficacy can be positioned as two mediators between subject matter interest and STEM career interest (Nugent et al., 2015).

2.2 Literature Review and Hypotheses Development

Over the past three decades, it has been found that a large number of factors will influence STEM career interest, including science interest, mathematics interest, science achievement, science self-efficacy, mathematics self-efficacy, technology self-efficacy, STEM career knowledge, STEM career opportunities and prospects, STEM stereotypes, problem-solving skills, computational thinking skills, attitudes toward inquiry, gender, influence of educators, family, and peer and so forth (e.g., Abe & Chikoko 2020; Blotnicky et al., 2018; Cairns & Dickson, 2021; Hava & Koyunlu Ünlü, 2021; Lamb et al., 2018; Nugent et al., 2015; Leyva et al., 2022; Luo et al., 2021; Sahin & Waxman, 2021). However, to the best of our knowledge, no prior research has examined coding-related predictors of STEM career interest. Considering that coding will be required in half of the STEM jobs (Kaczmarczyk & Dopplick, 2014; Peters-Burton, 2020), coding-related factors cannot be ignored when exploring antecedents of STEM career interest. Therefore, we apply the SCCT and identify three underlying coding-related predictors: intrinsic coding interest, coding self-efficacy and perceptions of coders. In this section, we describe the operational definitions of STEM career interest and its three coding-related influential factors (i.e., intrinsic coding interest, coding self-efficacy and perceptions of coders). We also propose five hypotheses to delineate the relationships among these four constructs. The four constructs and five paths make up our conceptual model.

2.2.1 Intrinsic coding interest and coding self-efficacy

In light of Kalyenci’s et al. (2021) definition, coding is “the process of writing the correct syntax regularly and sequentially and developing applications by using command sets in order to solve problems, provide human-computer interaction and perform a specific task by the computer” (p. 2). In recent years, emphasis has been put on how to simulate students’ coding interest in the K-12 curriculum (Kong et al., 2018). To be specific, the term coding interest describes “the liking of and wilful engagement in” coding activity (Dohn, 2020, p. 73). In particular, if students find coding interesting because of its novel nature or character, their coding interest can be considered as intrinsic (Amabile et al., 1994). Students with intrinsic coding interest are often intrinsically motivatedFootnote 1 (Dohn, 2020), and will engage in coding because they find that coding itself is interesting, engaging, or in some way satisfying (Amabile et al., 1994). Furthermore, they can also enjoy pleasure and wellbeing effects when undertaking coding tasks (Dohn, 2020). Given the importance of interest for students’ learning strategies, emotions, and outcomes (Grigg et al., 2018; Guo et al., 2020; Renninger & Hidi, 2015; Schiefele, 1991), the role of coding interest in students’ coding learning is also self-evident. Moreover, in the K-12 curriculum, for the benefit of coding learning, it is imperative for educators not only to trigger students’ coding interest temporarily but also hold it for an extended period of time (Dohn, 2020). As external factors usually determine extrinsic coding interest, it will not be as stable as intrinsic interest (Amabile et al., 1994). Therefore, to hold students’ coding interest for an extended period of time (Dohn, 2020), it is necessary to develop their intrinsic coding interest.

Self-efficacy is a motivational variable that always comes along with interest (Chen et al., 2016; Grigg et al., 2018). Stemming from Bandura’s (1997) social cognitive theory, self-efficacy is “people’s beliefs about their capabilities to produce designated levels of performance that exercise influence over events that affect their lives” (p. 71). In the coding domain, coding self-efficacy is defined as “a belief that one has the necessary skills and abilities to perform a programming task well” (Kong et al., 2018, p. 179). Many previous studies have found that domain-specific interest directly influences the corresponding self-efficacy (e.g., Chen & Hu 2020; Grigg et al., 2018; van Rooij et al., 2017). For instance, Grigg et al., (2018) have substantiated the positive impact of mathematics interest on mathematics self-efficacy. van Rooij et al., (2017) have confirmed the positive influence of academic interest on academic self-efficacy. Likewise, Chen & Hu (2020) have found that interest in information and communication technology (ICT) will positively predict ICT self-efficacy. However, almost no research has demonstrated that such a positive influence exists in the coding domain. We hypothesize that:

H1. Students’ coding self-efficacy (CSE) will be directly predicted by intrinsic coding interest (CI).

2.2.2 Perceptions of coders

The concept perceptions of coders, which is one kind of career perception, can be used to describe individuals’ beliefs regarding people who choose coding as a career (Sharma et al., 2021). It is well-documented that students have prominent misperceptions or stereotypes towards STEM professionals (Luo et al., 2021; Nguyen & Riegle-Crumb, 2021), not excepting those with technical jobs (e.g., coders) (Ardies et al., 2015; Cheryan et al., 2013; Sáinz et al., 2016). To be specific, technical professionals are stereotyped to be very smart but nerdy, boring, solitary, socially awkward and in possession of an unattractive appearance (e.g., having abnormal weight and dressing poorly) (Cheryan et al., 2013; García-Crespo et al., 2008; Sáinz et al., 2016).

It is reported that school students’ career perceptions are developed over a long period from childhood to adolescence and are usually influenced by their surrounding environment, especially the learning environment (Vela et al., 2020). Students with an inherent interest in STEM fields are more likely to enrol in STEM courses during pre-collegiate education (Fantz et al., 2011; Vela et al., 2020). In the STEM learning environment, they may develop their STEM career perceptions and diminish misperception (Mohtar et al., 2019; Vela et al., 2020). In this sense, student STEM interest may be a vital predictor of their STEM career perceptions. Since coding is one STEM element (Sun et al., 2021), this influence may also exist in the coding domain. However, it has been scantly examined before. Hence, we hypothesize that:

H2. Students’ perceptions of coders (POC) will be directly predicted by intrinsic coding interest (CI).

2.2.3 STEM Career Interest

STEM career interest is “individuals’ general interest in choosing STEM-related careers (such as careers as scientists, engineers, or technologists) in the future” (Luo et al., 2021, p. 3). The term STEM career interest has received special attention as it is directly linked to the future intention of pursuing a STEM career (Beier et al., 2019; Blotnicky et al., 2018). Prior studies have found that STEM career interest is significantly impacted by variables related to individuals’ personal motivation (Ahmed & Mudrey, 2019; Beier et al., 2019; Robnett & Leaper, 2013; Vondracek et al., 2014). Notably, interest is an important factor related to individuals’ personal motivation (Dohn, 2020; Renninger & Hidi, 2015). Actually, individuals with interest can often experience positive emotions when they do related tasks (Dohn, 2020; Schiefele, 1991), and psychologists have articulated that these positive emotions “play a key role in shaping” vocational developmental pathways (Vondracek et al., 2014, p. 69). In the STEM fields, Robnett & Leaper (2013) have claimed that if students find STEM subjects personally interesting, they are very likely to pursue STEM jobs. Ahmed & Mudrey (2019) have confirmed that STEM intrinsic value positively impacts students’ STEM career interestFootnote 2. Nowadays, coding is indispensable in many STEM jobs (Kaczmarczyk & Dopplick, 2014; Peters-Burton, 2020). Therefore, it is reasonable to assume that if students are interested in coding, they will experience positive emotions in STEM work and thus be interested in STEM careers. However, to date, very few studies have empirically confirmed this assumption. Accordingly, we hypothesize that:

H3. Students’ STEM career interest (STEMCAIN) will be directly predicted by intrinsic coding interest (CI).

Self-efficacy has also been considered a motivational factor (Bandura, 1997; Robnett & Leaper, 2013). A wealth of evidence has shown that self-efficacy is a strong predictor of vocational choices (Abe & Chikoko, 2020; Ahmed & Mudrey, 2019; Beier et al., 2019; Blotnicky et al., 2018; Clark et al., 2021; Ketenci et al., 2020; Lin et al., 2021; Luo et al., 2021; Robnett & Leaper, 2013; Kier et al., 2014) have pointed out that if students believe mathematics and science are too difficult, they will not be interested in STEM jobs. Likewise, Beier et al., (2019) have found that students with greater STEM skills efficacy are more eager to work in STEM fields. As coding is widely used in STEM professions (Arslan & Tanel, 2021; Boz & Allexsaht-Snider, 2021; Li et al., 2020; Weintrop et al., 2016), if students are not confident in their coding skills, they will not consider STEM jobs too. However, as far as we know, this assumption has yet to be examined empirically. Accordingly, our fourth hypothesis is as follows:

H4. Students’ STEM career interest (STEMCAIN) will be directly predicted by coding self-efficacy (CSE).

Career perceptions have been argued to be a fundamental element for understanding students’ career interests (Chan et al., 2019; Gottfredson, 2005). For instance, Chan et al., (2019) have demonstrated that students’ perceptions of engineers can significantly predict their interest in being engineers. Archer et al., (2013) have found that some students decline to consider science jobs because they misperceive that science professionals “just sit at the computer”, “don’t have a life” and are “like geeks” (p. 180). Likewise, Luo et al., (2021) have pointed out that students’ stereotypical beliefs regarding STEM careers negatively impact their STEM career interest. As coding will be involved in a large proportion of STEM jobs in the future (Kaczmarczyk & Dopplick, 2014; Peters-Burton, 2020), students may also decline to consider STEM jobs if they have misperceptions or stereotypes of coders. However, minimal research has explored the relationships between perceptions of coders and STEM career interest. To fill in the gap, we propose our hypothesis:

H5. Students’ STEM career interest (STEMCAIN) will be directly predicted by perceptions of coders (POC).

Based on the developed hypotheses, a conceptual research model is proposed to depict the impact of intrinsic coding interest on STEM career interest (see Fig. 1). This model, which is framed in the SCCT, indicated that intrinsic coding interest can not only directly impact STEM career interest, but also indirectly impact STEM career interest through coding self-efficacy or perceptions of coders.

Fig. 1
figure 1

The conceptual research model

Note. CI refers to intrinsic coding interest, CSE refers to coding self-efficacy, POC refers to perceptions of coders, STEMCAIN refers to STEM career interest

3 Method

This study was part of our larger project, whose goal was to investigate Chinese students’ attitudes and beliefs regarding coding and STEM. We adopted a quantitative cross-sectional survey method, a type of research design where quantitative data are collected using questionnaires from many individuals at a single point in time (Thomas, 2022). Methodologically speaking, a cross-sectional design can assist in investigating multiple variables and efficiently identifying the associations among the variables (Mann, 2003). Therefore, considering our study’s purpose, such a research design was considered suitable.

3.1 Participants

All of the respondents voluntarily participated in our research. They are from three randomly selected senior high schools in two cities in China. Two senior high schools are located in Shanghai, and one is located in XiamenFootnote 3. A total of 669 responses were included in the data set used for formal data analysis after incomplete ones were removed. Among them, 57.1% are male students, and 42.9% are female students. As coding is integrated into the information technology curriculum in these three schools, all our participants have coding learning experience. 273 respondents (40.8%) claimed that they had less than one year of coding learning experience, 117 respondents (17.5%) claimed that they had 1–2 years, 92 respondents (13.8%) claimed that they had 2–3 years, and 187 respondents (28.0%) claimed that they had more than 3 years. Particularly, 12.1% of respondents indicated that they would learn coding informally outside the information technology classrooms (e.g., access some news or information about coding on their mobile phones). This research obtained ethical endorsement before the questionnaires were distributed to the respondents.

3.2 Instrument Development and Data Collection

A survey questionnaire can be used as an effective data collection instrument (Burkell, 2003). The procedure for developing our research instrument is as follows. Firstly, we developed an initial English instrument based on existing literature (for its constructs, see Table 1). Secondly, we followed Guillemin et al.’s (1993) and Klarare et al.’s (2021) guide to conduct the forward- and back-translation to develop its Chinese version. Thirdly, language and education experts were consulted, and the instrument was revised and improved according to experts’ suggestions. Fourthly, we followed Slattery et al.’s (2011) suggestion to conduct a pilot test on 150 senior high school students. Those students were invited to add some additional personal comments about the questionnaire after completing itFootnote 4. It was pronounced that this initial instrument was too long for students. Therefore, we revised or deleted some items based on students’ comments to condense it. We also performed an initial statistical analysis and removed those items with low factor loadings (Hair et al., 2010). Accordingly, a shortened and improved instrument comprising a seven-point Likert scale consisting of four constructs with 29 items was developed (see the Appendix). Particularly, the construct of STEMCAIN was made up of four sub-dimensions: science career interest, technology career interest, engineering career interest and mathematics career interest. Sixthly, we conducted the formal data collection, where this shortened and improved instrument was used. Students were invited to fill the questionnaire, with teachers acting as gatekeepers. Our participants were clearly informed of the research purpose, their rights, and the personal information protection measures during the data collection. Last but not least, the formal research instrument was also validated with the data set containing 669 responses (see the Results section).

Table 1 The constructs of the initial instrument applied in the pilot test

3.3 Data analysis

We analyzed the data with SPSS Statistics 23 and AMOS 22 Graphics. Firstly, we validated our research instrument and its factor structures using the confirmatory factor analysis (CFA) technique. Secondly, we tested the research hypotheses and explored the relationships among CI, CSE, POC and STEMCAIN using a structural model evaluation. Notably, we also estimated the indirect effects of CI on STEMCAIN through CSE and POC, and bootstrapping was applied as a resampling method (5000 repetitions).

Figure 2 shows the procedure of instrument development, data collection and data analysis.

Fig. 2
figure 2

The procedure of instrument development, data collection and data analysis

4 Results

4.1 Validating the Research Instrument

To examine the validity and reliability of our research instrument, we tested the measurement model of CI, CSE, POC and STEMCAIN with four first-order factors of STEMCAIN by using CFA. For a start, we estimated a four-factor measurement model containing SCI, TECH, ENG and MATH with 19 items. The goodness-of-fit indices showed the four-factor measurement model fitted the data well (see Table 2). Subsequently, the second-order factor (i.e., STEMCAIN) was analyzed. It was confirmed that SCI, TECH, ENG and MATH, as first-order factors, were loaded under the second-order factor (i.e., STEMCAIN). Specifically, the second-order factor (i.e., STEMCAIN) was measured by SCI (β = 0.868, p < 0.001), TECH (β = 0.966, p < 0.001), ENG (β = 0.893, p < 0.001) and MATH (β = 0.858, p < 0.001). Among the four first-order factors, TECH was the strongest one. The second-order factor model also fitted the data well (for the goodness-of-fit indices, see Table 2). Based on the model results of the four-factor measurement and the second-order factor, we concluded that SCI, TECH, ENG and MATH were the first-order factors of the second-order factor (i.e., STEMCAIN). Next, we integrated this validated second-order factor (i.e., STEMCAIN) with the other three constructs (i.e., CI, CSE and POC) to examine the convergent and discriminant validity. The measurement model of CI, CSE, POC and STEMCAIN had a satisfactory fit to the data (for the goodness-of-fit indices, see Table 2).

Table 2 The goodness-of-fit indices of the measurement models

Table 3 presents the results of the convergent and discriminant validity of the measurement model of CI, CSE, POC and STEMCAIN. With regard to the convergent validity, we followed Hair et al.’s (2010) advice which was to examine whether each construct’s composite reliability (CR) was greater than 0.7 and average variance extracted (AVE) was greater than 0.5, respectively. As the minimum value of CR in our study was 0.792 and the minimum value of AVE in our study was 0.562 (see Table 3), the convergent validity of the measurement model of CI, CSE, POC and STEMCAIN was assured. With regard to the discriminant validity, we followed Fornell and Larcker’s (1981) advice and confirmed that each construct’s correlation coefficients to the other three constructs were less than the square root of its AVE in our study. Therefore, the discriminant validity of the measurement model of CI, CSE, POC and STEMCAIN was assured.

Table 3 The results of the convergent and discriminant validity

The Appendix also presents the values of standardized factor loading (Std.) for each item and Cronbach’s alpha coefficient (α) for each construct. All Cronbach’s alpha coefficients (α) were above Nunnally’s (1967) recommended threshold of 0.7 (see the Appendix). This meant that the construct reliability of the measurement model of CI, CSE, POC and STEMCAIN was assured.

The results mentioned above verified that our research instrument had sufficient validity and reliability.

4.2 Testing the Research Hypotheses

We tested the research hypotheses using a structural equation model (for the model results, see Fig. 3). The goodness-of-fit indices of our model were as the following: χ2/df = 3.860, CFI = 0.949, TLI = 0.944, RMSEA = 0.065, SRMR = 0.051, which indicated that it had a satisfactory fit.

Fig. 3
figure 3

The results of the structural equation model with standardized coefficients

Table 4 presents the hypotheses testing results. CI directly and significantly impacted CSE (β = 0.517, p < 0.001), POC (β = 0.530, p < 0.001) and STEMCAIN (β = 0.443, p < 0.001). Therefore, H1, H2 and H3 could be accepted. STEMCAIN was also directly and significantly influenced by CSE (β = 0.146, p < 0.001), POC (β = 0.379, p < 0.001). Hence, H4 and H5 were supported.

Table 4 The hypotheses testing results

Table 5 presents the testing results of the mediating effects. As for the indirect paths in our model, CI significantly influenced STEAMCAIN respectively through CSE (β = 0.075, p < 0.001) and POC (β = 0.201, p < 0.001). In other words, CSE and POC significantly mediated the relationship between CI and STEMCAIN. Besides, CI had total effects weighting of 0.719 (p < 0.001) on STEMCAINFootnote 5. Among them, the indirect effects were 0.276 (p < 0.001) and accounted for 38.4% of the total effects. Our model also accounted for 64% of the variance in STEMCAIN using CI, CSE and POC.

Table 5 The testing results of the mediating effects

5 Discussion

5.1 Theoretical contributions

This study affirms a new theoretical model illustrating the relationship between intrinsic coding interest and STEM career interest. This model shows strong predictive power as it can account for 64% of the variance in STEM career interest. By successfully applying this new model, for the first time, we substantiate the direct and indirect impact of intrinsic coding interest and STEM career interest and confirm the mediating roles of coding self-efficacy and perceptions of coders. This study contributes to the limited literature on the coding-related antecedents of STEM career interest.

Subject matter interest, subject matter self-efficacy, and outcome expectancyFootnote 6 are three key SCCT constructs that can be used to predict STEM career interest (Nugent et al., 2015). In other words, according to the SCCT, if students are interested and confident in some important subjects or skills in the STEM fields and have positive perceptions of related careers where those subjects or skills are frequently used, they will be more likely to choose STEM careers (Nugent et al., 2015). Based on the SCCT, prior studies have successfully substantiated several antecedents of STEM career interest, including science interest (Lamb et al., 2018), mathematics interest (Leyva et al., 2022), science self-efficacy (Sahin & Waxman, 2021), mathematics self-efficacy (Blotnicky et al., 2018), technology self-efficacy (Lamb et al., 2018) and STEM career perceptions (Luo et al., 2018). Different from those prior studies (e.g., Blotnicky et al., 2018; Lamb et al., 2018; Leyva et al., 2022; Luo et al., 2018; Sahin & Waxman 2021), we apply the SCCT to identify coding-related predictors of STEM career interest. One of the most important theoretical contributions of this study is that we confirm three antecedents of STEM career interest (i.e., intrinsic coding interest, coding self-efficacy and perceptions of coders) in light of the SCCT. To the best of our knowledge, this study is the first to statistically articulate the direct influence of intrinsic coding interest, coding self-efficacy and perceptions of coders on STEM career interest. Our findings add further credence to the explanatory power of SCCT to predict STEM career interest. In addition, on the one hand, this study echoes earlier findings that STEM career interest is significantly impacted by variables related to individuals’ personal motivation, such as intrinsic interest and self-efficacy (Ahmed & Mudrey, 2019; Beier et al., 2019; Robnett & Leaper, 2013; Vondracek et al., 2014). On the other hand, our findings also support Chan et al.’s (2019) and Gottfredson (2005) statement that career perceptions, as an important variable, is fundamental for understanding career interest. Moreover, the significant and powerful effects on STEM career interest exerted by coding-related factors indicate that the strong relationship between coding and STEM career in the present age of information technology has been realized by senior high school students, many of whom are potential STEM employees in the future. In this sense, our study calls for more attention to coding education in pre-collegiate stages.

SCCT suggests that outcome expectancy and self-efficacy mediate the relationship between subject matter interest and STEM career interest (Nugent et al., 2015). This study also detects the mediating roles played by coding self-efficacy and perceptions of coders between intrinsic coding interest and STEM career interest, which has never been examined before. Our findings demonstrate that the indirect effects of intrinsic coding interest on STEM career interest account for 38.4% of the total effects, which cannot be ignored. As our findings indicated, students with low intrinsic coding interest are very likely to first lose confidence in coding and have stereotypes regarding coders, and then choose not to pursue STEM careers. This also implies that coding-related beliefs, as a whole in which intrinsic coding interest is the core, may exert a significant effect on STEM career interest.

5.2 Practical implications

Facing a severe shortage of STEM workforce around the world (Corin et al., 2020; Luo et al., 2021; Mystakidis et al., 2021; Nguyen & Riegle-Crumb, 2021; Ketenci et al., 2020; Šimunović & Babarović, 2021; Yahaya et al., 2021; Vela et al., 2020) and the worrying dropout rate of top STEM students (Carnevale et al., 2011; Karahan et al., 2021; van den Hurk et al., 2019), our study provides some direction for developing practical solutions. First, it is very meaningful to stimulate students’ interest. For instance, game-based coding can be applied in coding education (e.g., Demirkiran & Tansu Hocanin 2021; Koupritzioti & Xinogalos, 2020). Second, nowadays, coding does not have the same status as other disciplines like mathematics and science in the K-12 curriculum (e.g., Pei et al., 2018). That means that students may not have as many opportunities to learn coding as they do mathematics and science. In this case, students may not be as confident in their coding abilities as they are in mathematics and science competence. To improve students’ coding self-efficacy, we recommend that more emphasis be put on coding education, and students’ coding skills should be effectively enhanced. For instance, students can be encouraged or guided to solve real-world problems by coding. Third, teachers and parents should help students know about coders and eliminate their misperceptions or stereotypes regarding coders. For instance, teachers and parents can introduce some role models in coding careers. Also, students can be invited to information technology companies to learn about coders’ work and life.

5.3 Limitations and Future Research

Notwithstanding the aforementioned theoretical contributions and practical implications, our study is not without limitations. First, this study is set out to confirm coding-related predictors of STEM career interest based on the SCCT. However, as Nugent et al., (2015) pointed out, other factors are not included in the SCCT (e.g., students’ knowledge). This exploratory study is an initial attempt to examine the coding-related influential factors of STEM career interest. Based on our model, further studies can explore more coding-related antecedents (e.g., coding knowledge) through other theoretical lenses and account for more variance in STEM career interest. Second, STEM career interest may be influenced by a considerable number of factors (e.g., Abe & Chikoko 2020; Blotnicky et al., 2018; Cairns & Dickson, 2021; Hava & Koyunlu Ünlü, 2021; Lamb et al., 2018; Nugent et al., 2015; Leyva et al., 2022; Luo et al., 2021; Sahin & Waxman, 2021). It is impossible to include all the underlying factors in a single quantitative model. Different quantitative models have analyzed the predictors of STEM career interest from different angles. However, these antecedents have yet to be summarized systematically, and more review articles are needed. Third, prior research has pointed out differences between male and female students’ STEM career interests (Happe et al., 2021). Also, children’s coding experience may change their gender-based stereotypes or perceptions of STEM careers (Bati et al., 2021). These previous findings indicate that gender may moderate the impact of coding-related factors on STEM career interest. However, detecting such a moderating effect is not included in the goals of our study. We will endeavour to focus on it in the future research of our larger project. Finally, coding and STEM education is strongly promoted in many big cities (Jiang et al., 2021a, b). This study was conducted in Shanghai and Xiamen, two of China’s most developed cities. Hence, our findings can resonate and provide insights into coding and STEM education practice in many big cities. However, our sample does not include students from remote and rural areas, whose coding experience is very limited (Jiang et al. 2021b). In this regard, we caution against generalizing our findings to students in remote and rural areas. In the future, if rural students have opportunities to participate in some coding curricular and experience coding, researchers can investigate their attitudes, opinions and beliefs and examine the potential differences with urban students.

6 Conclusion

In light of three key SCCT constructs (Nugent et al., 2015), this study employs a quantitative cross-sectional survey method and then identifies the coding-related determinants of STEM career interest, namely intrinsic coding interest, coding self-efficacy and perceptions of coders. Among them, coding self-efficacy and perceptions of coders can directly impact STEM career interest, while intrinsic coding interest can impact STEM career interest both directly and indirectly. Coding self-efficacy and perceptions of coders are detected as two mediators between intrinsic coding interest and STEM career interest. 64% of the variance in STEM career interest can be explained by the three coding-related determinants. This study expands the current knowledge regarding the relationships between coding and STEM career interest, and has several practical implications for improving students’ STEM career interest.