scieee AI-readable full text Open interactive document viewer

Programming 1 and sustainability

Castro Rabal, Jorge,Cortadella, Jordi,Gabarró Vallès, Joaquim,Garcia Pujol, Albert,Vidal López, Eva María

Abstract

Computer programming is an essential skill for today's engineers, and sustainability plays a role of growing interest in any of the design phases of an engineering project. The fundamentals of sustainability, with basic concepts such as "carbon intensity", must be covered in any engineering curriculum. We propose a basic computer programming course in which the lab sessions incorporate exercises related to the computation of environmental impacts. For instance, an exercise might request the computation of the carbon footprint of the lab sessions during a whole year. Lab sessions use an automatic evaluation server, so called Jutge.org that assesses about the correctness of the programs submitted by the students. New exercises concerning sustainability topics are included in the Jutge.org course. The course involves the effort of a multidisciplinary team. First, lecturers on basic programming are required. An expert on automatic evaluation of computer programs is essential to prepare the statements and the test sets of the proposed exercises. Finally, the advice of economists and sustainability experts is crucial to guarantee judicious conclusions are drawn from each exercise. Forming a team with this profile is a challenging task. Our Computer Science (CS) department lectures basic programming courses to more than 1700 students/year. The success of this approach could bring a substantial social impact in our ecosystem.

Full text

50th Annual Conference in September 2022 1041 Jorge Castro, Jordi Cortadella, Joaquim Gabarro, Albert García and Eva VidalProgramming 1 and Sustainability - 10.5821/conference-9788412322262.1261 doi:10.5821/conference-9788412322262.1261 PROGRAMMING 1 and SUSTAINABILITY Jorge Castro, Jordi Cortadella, Joaquim Gabarró CS Dept. Universitat Politècnica de Catalunya, UPC, Barcelona, Spain, [email protected], [email protected], [email protected], 0000-0002-1390-1313, 0000-0001-8114-250X, 0000-0003-3771-2813. Albert García Comissió d'Economia i Sostenibilitat, Col.legi d'Economistes de Catalunya, Barcelona, Spain, [email protected] Eva Vidal University Research Institute for Sustainability Science and Technology, Universitat Politècnica de Catalunya, UPC, Barcelona, Spain [email protected], 0000-0001-8533-2271. Conference Key Areas: Sustainability. Sustainable Development Goals (SDG). Keywords: Programming, Sustainability, Carbon footprint, SDG, Automatic Evaluation. ABSTRACT Computer programming is an essential skill for today's engineers, and sustainability plays a role of growing interest in any of the design phases of an engineering project. The fundamentals of sustainability, with basic concepts such as "carbon intensity", must be covered in any engineering curriculum. We propose a basic computer programming course in which the lab sessions incorporate exercises related to the computation of environmental impacts. For instance, an exercise might request the computation of the carbon footprint of the lab 50th Annual Conference in September 2022 1042 sessions during a whole year. Lab sessions use an automatic evaluation server, so called Jutge.org that assesses about the correctness of the programs submitted by the students. New exercises concerning sustainability topics are included in the Jutge.org course. The course involves the effort of a multidisciplinary team. First, lecturers on basic programming are required. An expert on automatic evaluation of computer programs is essential to prepare the statements and the test sets of the proposed exercises. Finally, the advice of economists and sustainability experts is crucial to guarantee judicious conclusions are drawn from each exercise. Forming a team with this profile is a challenging task. Our Computer Science (CS) department lectures basic programming courses to more than 1700 students/year. The success of this approach could bring a substantial social impact in our ecosystem. 1 TEACHING PROGRAMMING AND SUSTAINABILITY Sustainability principles are playing an increasingly important role in our society. Nowadays, the environmental impact of any major business, social or policy initiative is always examined. In the task of promoting sustainable behaviours, universities must play a prominent role and teaching sustainable development must be part of the curricula. For students motivated in the subject, books on sustainability like Bill Gates’ [1] or William Nordhaus’ [2, 3] can be recommended. Basic programming courses are common in science and engineering majors. Introducing fundamental concepts of sustainability in programming assignments is a way of disseminating this knowledge to many students. While keeping traditional learning goals, we propose a first computer-programming course that considers, besides standard lab exercises, assignments concerning the computation of environmental costs. This approach is close to the one described in [4], where the pedagogical results of a programming course that introduces a list of sustainability-themed assignments are reported. The novelty of our course is to integrate this type of assignments in an automatic evaluation server, so called Jutge.org [5], which assesses about the correctness of submitted programs. The exercise statements in Jutge.org have to be short, clear and self-contained. More importantly, they also need to be easily understandable without prior knowledge on sustainability. New sustainability lab exercises need to be carefully designed, involving the effort of a multidisciplinary team. First, lecturers on basic programming are essential to assess the suitability and understandability of the new proposals. Second, a Jutge.org expert is required to incorporate the new exercises 50th Annual Conference in September 2022 1043 and test cases to the evaluation platform. Third, experts on ecology, sustainability and economics are required. A multidisciplinary team with combined expertise contributes to design meaningful assignments with convincing outcomes. Our CS department lectures basic programming courses to more than 1700 students/year. In the long run, the approach we propose can have a significant impact on the environmental awareness of students. 2 THE JUTGE.ORG APPROACH For fifteen years, our CS department is using Jutge.org [5], an automatic evaluation platform, in several programming courses. Jutge.org has an extraordinary amount of exercises organized in lists and courses. Each programming exercise consists of a statement and several test cases. Public tests shown in the problem statement improve global readability and help students to find a correct solution. Additional private tests, not visible to the user, are included to evaluate the submitted programs. From our experience, we think Jutge.org provides an invaluable help to student progress. The immediate feedback about submissions allows student self-learning at any time and place. During lab sessions, instructors can focus on aspects Jutge.org cannot assess, like program readability, coding style, and basic principles of algorithm efficiency. Beyond immediate feedback, the use of the evaluation platform is a way to develop an active learning approach. 3 BASIC PROGRAMMING COURSES Courses taught by the department consider specific School circumstances, but lab sessions are always an unavoidable course part. 3.1 At Computer Science School The first programming course is a very basic course. As a typed approach is considered, C++ is used. Sequential decomposition and case analysis are first introduced. After that, item sequences are considered to deal with loops. Emphasis is placed on sequential treatment schemes: treat-all and searching. Later, procedures and functions are shown. Vectors and Tuples (Structs) are also taught. No more data structures are introduced. The schedule is 2 hours/week of theory lectures on fundamental programming concepts and 3 hours/week guided lab. 3.2 At Engineering School As the introductory course will be the only general programming course for most students, more programming features are taught but in a less depth way. Python is the programming language and lists and dictionaries are the main data structures. The schedule is 2 hours/week of theory lectures on fundamental programming concepts and 2 hours/week guided lab. 50th Annual Conference in September 2022 1044 3.3 School influence on jutge.org courses Specific School requirements translate to specific Jutge.org exercises. This should be considered when we deal with sustainability topics. 4 SUSTAINABILITY CONTENT IN PROGRAMMING EXERCISES A computer program processes a data set to obtain new results. Two crucial points when proposing a new exercise are to provide right input data and to formalize, unambiguously, the questions the program has to answer. Regarding these points, a number of issues arise when writing new exercises with sustainability content. Some of these difficulties are described below. The main problem faced by the team is: programming exercises designers are not experts on sustainability. They follow suggestions about possible exercises of the team's experts; they ask questions and get answers. The dialog is fruitful, but it takes time, sometimes a lot of time. Following two aspects of such difficulties. 4.1 About input data Lack of intuitive meaning of big numbers and data reliability are the main concerns about program input data. Lack of intuitive meaning of numbers. What does 51 gigatons of Co2 per year mean? [1] That is 51 ∗109 tonsCo2/year. As Bill Gates points out, this number means nothing intuitively for most of the people. In order to get some insight, let us compute the ratio per capita. The world population is 7.93 ∗109. Therefore, the number of tons per capita is 51/7.93 = 6.43 tonsCo2/human. It seems that 6.43 tonsCo2/human looks both, more understandable and very impressive! Data depends on the source. At https://www.worldometers.info/co2-emissions/ we found the ratio per capita 4.79 tonsCo2/human. At least it seems to be of the same order of magnitude. Another example, looking for the Co2 emitted by a query on the Web, we found 0.2 gCo2/query for a Google search (look at https://searchengineland.com/calculating-the-carbon-footprint-of-a-google-search- 16105) but we also found 0.09 gCo2/query (look at https://www.altaviagroup.com/en/green-web-needs-to-happen/). As 0.2/0.09 = 2.2, there is a degree of uncertainty about data. Even working with uncertain data and unintuitive numbers, the topic is so important, that makes sense to introduce sustainability concepts in basic programming courses. 4.2 Issues working with rough numbers Imagine that you would like to prepare a lab exercise on the number of trees needed to absorb the annual CO2 emissions. After asking an expert, you assume that one tree absorbs an annual average of 24 kgCo2. As a first idea, you will work with rough numbers. From Bill Gates book [1] you assume an annual emission of 51 billion tons Co2 = 51 ∗1012 kgCo2/year. From https://www.gotreequotes.com/how-many-trees-in-world/ we find that the number of trees in the world is 3.04 ∗1012. 50th Annual Conference in September 2022 1045 As 51 < 24 ∗ 3.04 you may conclude, that trees will absorb all Co2 emissions and thus, there is no problem. This reasoning is quite incomplete and shows a lack of knowledge about the carbon cycle. Computer scientists without expert’s advice can make big mistakes. A way to avoid this type of mistakes consists on working with an interdisciplinary team. Having members with depth knowledge in ecology and sustainability is fundamental. 5 SUSTAINABILITY IS A HUMAN PROBLEM As we are in an Engineering University, we are familiar with units like kgCo2/kWh. It could be tempting to think that all sustainability problems can be solved through good engineering improvements. From our point of view this is a big mistake. Of course engineering is fundamental to improve the situation [1] but according to Nordhaus [2, 3], the problem is motivated by human society. Therefore we have to consider human aspects. Most relevant ones are described as global goals in the United Nations collection SDGs. Sustainable Development Goals (SDG, https://sdg-tracker.org/) are a list of seventeen goals designed to be a plan for a better and sustainable future. A straightforward way to encode SDGs as a data structure is by a dictionary, a resource available in Python as basic structure: dic_SDG = {"Goal 1": "End poverty in all its forms everywhere", "Goal 2": "End hunger, achieve food security and improved nutrition and promote sustainable agriculture", … , "Goal 17": "Strengthen the means of implementation and revitalize the Global Partnership for Sustainable Development"} Taking dic_SDG as data structure, we can design exercises to introduce SDG to our students. In Engineering Schools dictionaries appears in the program and there is no problem. As in CS school dictionaries are not in the basic course but we can develop exercises through the targets of the goals. Do not forget economic aspects. The economic activity (figure 1 on pag 10 of [2] and figure 5 -1 of [3]) is at the core of the problem. Some exercises, need to face this. According to Brundtland Commission [6] a sustainable development “meets the needs of the present without compromising the ability of future generations to meet their own needs”. We need to compare today consumption with tomorrow consumption. This implies to discount the future to valuate into the present. This is an old problem (chapter 11 of Keynes [7]). Having an economist in the team is also fundamental. Biodiversity. Topics like biodiversity (chapter 11 on [2]) are even more challenging. 50th Annual Conference in September 2022 1046 6 PROGRAMMING EXERCISES 6.1 On the mechanics of designing an exercise It all started with a meeting between a CS member and a sustainability expert. This meeting was fundamental in two aspects. First, it provided to CS members team with a list of links to start working. Second, the expert strongly emphasized the need to give a concrete meaning to the big numbers. After that, the team start planning exercises for Jutge.org. The development of exercises for the Jutge.org takes much more time than expected. Even if some of the CS members has an informal knowledge on sustainability [1, 2, 3]; this knowledge was too general to be transformed into exercises. They go through the links over and over, talk and talk with sustainability experts, reread the books and slowly tentative ideas for exercises appears. As Tony Hoare point out years ago over ambition was the problem for CS members. Following we give an example. 6.2 Example of Jutge.org Exercise: Co2 to Trees Statement. Co2 is one of the most important greenhouse gases. Trees extract CO2 from the air and convert it into oxygen and plant material through photosynthesis. Browsing the web, we got the following data. First, the annual average kWh_consumption, denoting the household energy consumption (due to electricity): ● France: 4760 kWh ● Germany: 3149 kWh ● Ireland: 4200 kWh ● Spain: 3487 kWh Second, considering how electricity is produced we get different conversion_factors: ● France: 0.059 kgCo2/kWh ● Germany: 0.181 kgCo2/kWh ● Ireland: 0.292 kgCo2/kWh ● Spain: 0.209 kgCo2/kWh Finally, from https://www.encon.be/en/calculation-co2-offsetting-trees let us assume that the average annual CO2 offsetting_rate is 24 kgCO2/tree. For a given country, we ask to compute the number of trees by household needed to absorb the Co2 generated in a year. Write this number with 2 decimal places. Input. The input is formed by a non-negative integer n followed by a sequence of n triples. Each triple consists on a country name (string), a household energy consumption (double) and a Co2 conversion factor (double). Output. For each country in the input sequence, a line with the number of trees by household to offset its Co2 emissions. Follow the format in the example below. 50th Annual Conference in September 2022 1047 Public test cases. Input 4 France 4760 0.059 Germany 3149 0.181 Ireland 4200 0.292 Spain 3487 0.209 Output France: 11.70 Germany: 23.75 Ireland: 51.10 Spain: 30.37 6.3 List of Programming Exercises. Following the list of currently available exercises in the Jutge.org a Co2 emissions by activity b Co2 to Trees c Carbon intensity of electricity generation d Life expectancy e Income inequality f Carbon emission reduction Most of the proposed exercises, a, b, c and f are related to the carbon emissions. The exercises d and e are inspired in SDGs. Currently some topics are missing on the list. Exercises based on economy are missing. Should appear exercises based on Carbon Tax or Green Premium. In addition, exercises that relates the present versus the future should appear. We could do that through the idea of present value. Some of the missing exercises are under construction. Others will need much more reflection and time. 7 POSSIBLE COURSE ORGANIZATIONS Jutge.org offers facilities to create new courses and also to update the list of exercises on existing courses. This offers different possibilities. 7.1 First year programming course. We plan to update the introductory programming courses of our Department with sustainability exercises. In fact, we start doing that. In the first Control, of CS students, it appears one exercise of the list. Doing that we expect to catch the feeling of the CS students about this kind of exercises. 50th Annual Conference in September 2022 1048 7.2 Transversal first year sustainability course. This is a very ambitious project because it is difficult in our University to offer new courses. This course should offer the possibilities to our students to get basic knowledge about sustainability. It should consider, both, engineering aspects but also human aspects. The course could be seen as a guide for self-study and active research. As basic readings along the course, we consider Bill Gates book [1] and or William Nordhaus book [3]. Several topics could be considered in this course with the corresponding links. ● Co2 and trees: Encon: from emissions to trees. https://www.encon.be/en/calculation-co2-offsetting-trees ● On ways to produce electricity. ourworldindata.org: primary energy versus consumed energy. https://ourworldindata.org/energy-substitution-method electricityMap: conversion of kWh into Co2. https://app.electricitymap.org/zone/ES?solar=false&remote=true&wind=false ● SDG https://sdg-tracker.org/ ● Co2 and streaming videos. idea: carbon footprint of streaming videos. https://www.iea.org/commentaries/the-carbon-footprint-of-streaming-video-fact- checking-the-headlines Programming possibilities: To have a guide on programming exercises you can take any one (or both) of the following choices: ● Jutge.org https://jutge.org/ ● Jeffrey Stone projects: 9 topics each one with a self-contained video. https://sites.psu.edu/sustainabilitycis/active-projects-cpp/ 8 SUMMARY AND ACKNOWLEDGMENTS We have introduced our efforts to deal with sustainability in first-year programming courses. J. Castro, J. Cortadella and J. Gabarró have been financed by: Proyecto PID2020- 112581GB-C21 financed by MCIN/AEI/10.13039/501100011033. E. Vidal has been supported by the Spanish Ministerio de Ciencia, Innovación y Universidades, the Spanish Agencia Estatal de Investigación (AEI), and the Fondo Europeo de Desarrollo Regional (FEDER), from study design to submission, under grant number RTI2018-094982-B-I00. 50th Annual Conference in September 2022 1049 REFERENCES [1] Gates, B, (2021), How to Avoid a Climate Disaster. The solutions We Have and the Breakthroughs We Need, Alfred A. Knopf, New York and Toronto, [2] Nordhaus, W, (2013), The Climate Casino. Risk, Uncertainty, and Economics for a Warming World, Yale University Press, New Haven and London. [3] Nordhaus, W, (2021), The Spirit of Green. The Economics of Collisions and Contagions in a Crowded World. Princeton University Press, Princeton and Oxford. [4] Stone, J, (2019), A Sustainability Theme for Introductory Programming Courses, I.J. Modern Education and Computer Science, Vol 2, pp 1-8. [5] Petit, J, Roura, S, Carmona, J, Cortadella, J, Duch, A, Giménez, O, Mani, A, Mas, J, Rodríguez-Carbonell, E, Rubio, A, de San Pedro, J, Venkataramani D, (2018), Jutge.org: Characteristics and Experiences. IEEE Trans. Learn. Technol. 11(3): 321-333. [6] Brundland, G. H, (1987), Our Common Future. The World Commission on Environment and Development. Oxford University Press, Oxford. [7] Keynes, J. M, (1935), The General Theory of Employment, Interest and Money. With an introduction of Paul Krugman. Reprint Palgrave Macmillan for the Royal Economic Society, 2007, Palgrave.