Python prevails

9 downloads 884 Views 597KB Size Report
course for first year math and computer science students from Java to Python. ... Key words: Teaching programming to beginners, Python as a first language.
International Conference on Computer Systems and Technologies - CompSysTech’09

Python Prevails Vambola Leping, Marina Lepp, Margus Niitsoo, Eno Tõnisson, Varmo Vene, Anne Villems Abstract: In this article we describe why we changed the language of our introductory programming course for first year math and computer science students from Java to Python. We explain why we chose Python over the other languages, how we built up the course and how we ran it as an experiment with a small group (about 25% of students). The experiment itself lead us to decide to use Python with all the students starting the next, 2009/2010 study year. Key words: Teaching programming to beginners, Python as a first language.

INTRODUCTION The 6 ECTS course for fist year undergraduate students in the University of Tartu has been taught Java-based by the Computer Science Department for more than 10 years. The course is compulsory for all first year students of the Faculty of Mathematics and Informatics. However, there are many problems associated with teaching Java to students that are just beginning to learn programming. The authors of this article conducted an experiment by switching the teaching language of the first programming course to Python [12,17,15,16] for a small group of first year undergraduates in autumn term of 2008/2009 study year.The experiment gave positive results and was followed by the decision to switch to Python for all first year students. Our course was also accompanied by a smaller experimental course (3 ECTS) for students of physics that was also done in Python. Their faculty also decided to continue with that language. In this article we will describe, why we changed from Java to Python, why we chose Python and not some other language, how our course was built up, how we ran the test course and what decisions were made after the first, experimental year. NEED FOR THE CHANGE The choice of first programming language is known to have a profound impact on the students. It affects programming style, coding technique and code quality in many subtle ways. In fact, this issue is so important that there is a surprisingly large amount of literature available on the topic. [5,8,18]. As programming has been taught in our university from 1957, many languages have served as the first language. In the very beginning it was machine code, then symbolic code but high level languages like Algol have also been taught to the students. In 80-ties we used Pascal as the first language. Pascal was the most commonly used programming language in introductory courses at that time. It is made for learning. But as object orientation, function overloading, and polymorphism became more common, we started shifting to teach other languages such as C/C++ and JAVA which were becoming popular in the industry because of these features.. JAVA is relatively new but it has made substantial leaps in its recent history. It was designed bottom up to be a safe object oriented language with a very strong focus on "what to do" rather than "how to do it." Consequently, JAVA is highly standardized, strongly typed, and has a large standard API that make it easy to write programs. However, JAVA has many problems that make it unfit for a first language. First of all, it is quite verbose and you need to write a lot of code just to get the simplest functionality. Further, one needs to really understand object oriented programming to make appropriate use of JAVA as even writing a "Hello world" program requires you define a class and a public static main function. As the majority of our first year students have no prior programming experience,

IV.17-1 © 2009 ACM

International Conference on Computer Systems and Technologies - CompSysTech’09

introducing it to them with the long and cumbersome constructs of Java would rather seem to repel than to attract them towards programming. Despite these shortcomings we kept using Java as the first programming language for quite a long time. We even developed a new dialect for beginners Amadeus AlgJava [7] and taught it in parallel with Java. Amadeus AlgJava is a semi-graphical approach to Java with a goal of simplifying the syntax of Java for beginners. But we saw that Java and it's dialect are not good for all students. Amadeus AlgJava is still in development and is currently not yet ready to be used as an introduction to programming. WHY WE CHOSE PYTHON Many organizations have heralded their success with Python as a first programming language [2,11], claiming Python to be "an elegant, simple, and practical language". "One in particular, Python, seems nearly ideal" claims J.Zelle [19]. It has been successful even with lower secondary school groups [1] - an argument, which have brought some university teaching staff to a anti-python position. There are some concerns with particular aspects of Python like input, type handling, etc. which in some cases are confusing for beginners. Python has a clean and easy to read syntax [2], which is one of the strongest arguments in the process of choosing it as a language for beginners. The pedagogical influence of well chosen example programs is difficult to underestimate. Python programs are easy to read and really work as good teaching material. Python follows the "out of the box" ideology. It also has an additional advantage is possibility to use it as an interactive shell. We also agree with J.Zelle [19] when he says that: "Programming is hard, but we should strive to make it no harder than it needs to be". For teachers Python looks very appetizing as multi-paradigm language. It can be a good first language not only to future Java and C++ (e.i. object-oriented developers), but also for future Haskell and Lisp (i.e. for functional language) users. It should also be noted that Python is usually not the first or the second language for the teaching staff either and we too appreciate a new language which is easy to learn. Python is not a dead language as it is still constantly developing. And one dimension that is kept in mind in its development is its usefulness as a first language in teaching [3]. Python is free to download for everybody, which means that every student can use it on his/her own computer - a fact that helps learning a lot. And every university can follow it's no-stolen-software-in-our-organization policy. The last argument for teaching Python to future programmers, is connected to it's growing popularity in the private sector. The list of companies using Python in their developments is already solid and growing rapidly [13,14,4,10] HOW THE COURSE WAS RUN Our first programming course consists of three separate forms of teaching: Lectures, chalkboard exercise sessions and computer exercise sessions. The lectures introduced the students to the basic concepts of programming. Since the lectures were the same for both the two new Python groups and the old Java groups, both languages were used in the examples. Both exercise sessions were, however, separate for the two groups. The main goal of blackboard sessions was to teach students to think algorithmically. The students were given problems of simple algorithmic nature and then worked in groups to develop a solution. Essentially, flowcharts were used in the practice sessions but as the course progressed, the students were allowed to hand in Python code as well. Although similar blackboard sessions had been used in the preceeding years with Java groups, they were completely redesigned nearly from scratch for the new Python course. This was done

IV.17-2 © 2009 ACM

International Conference on Computer Systems and Technologies - CompSysTech’09

because the teaching order of some of the concepts was changed in the new course and that had to be accommodated. The computer exercise sessions were meant to teach the students to actually program a computer using a Python interpreter. Students generally worked on their own with written practice session guides that contained explanations, examples and exercises. The role of the teacher was rather passive, mainly answering questions and helping the students work through their guides. Grading was also divided into three parts: Students could get points from two tests given in the blackboard sessions, from three tests given in the computer sessions and also from the final exam. Teachers of the exercise sessions were also allowed to give extra points for homework or for exceptionally good work in the sessions themselves. The exercise sessions could account for at most 65 points of the grade and students were required to get at least 40 of these points in order to get to the exam and not fail the course. This assured that pretty much everyone who was allowed to the exam also passed the course. This was, however, in complete accordance with the set goals as being able to get 40 points meant the student had to be able to write working Python code on at least an elementary level. The exam itself was more theoretical and mainly assessed the understanding of the terminology and concepts introduced within the course. As the main goal of the course was to teach programming, many of the questions in the exam were geared towards those reaching for a high grade and from whom we expected a more thorough theoretical understanding. RESULTS The course had 182 registered students in total, 42of which were taught Python and 140 Java. The results of the course are summarized in the following table showing the distribution of final grades in Table 1. Table 1. Distribution of final grades. Python Java Total

A 10 18 28

B 5 28 33

C 5 27 32

D 12 19 31

E 4 8 12

F 6 40 46

As we can see, the number of students who failed the course (ie. got the grade "F") was about two times lower in the Python group (14%, compared with 28% of Java). It is worth noting that all the students that failed the course did so because they did not collect enough points from the exercise sessions were not allowed to the final exam. The fact that a larger number of Python group passed can be, at least partially, attributed to its shallower “learning-curve”. It may also be due to the fact that Java and Python were taught by different people with different grading criterions, although attempts were made to at least make the grades partially comparable. The overall distribution of positive grades is similar both in Python and in Java. In Python, 42% of students with positive score got an excellent or a very good mark (grades "A" and "B"), while in Java it was 46%. In both cases, most of the students with high grades had at least some previous programming experience. The number of lower-end grades ("D" and "E") was 44% in Python and 27% in Java. This correlates well with numbers of failing students: in Python, most of the weaker students passed, but got a low positive mark at the end; in Java, about half of the weaker students failed and the rest got low marks.

IV.17-3 © 2009 ACM

International Conference on Computer Systems and Technologies - CompSysTech’09

ABOUT THE SMALL COURSE For several years, the “big” (6 ECTS) programming course (based on Java) was compulsory to the first-year students of Physics, Chemistry and Materials Science. Since the curricula change last year no programming is taught to the students of Chemistry and Material Science and a „small“ (3 ECTS) programming course replaces the larger one in the curricula of Physics and that of Computer Engineering (new specialty). The 3 ECTS course is named “Introduction to Programming“ and consists of 16 hours of computer exercise sessions and 16 hours of chalkboard exercise sessions. The course based on Python. As first steps in Python are more accessible than in Java it seems to be good choice for the small introductory course. The course uses basically the same materials as the larger course but is somewhat modified to better fit into the smaller format. Beside other aspects, the (LOGO-like) turtle graphics is remarkable in its usefulness. We use the turtle graphics in case of the topic of recursion, for example.

FUTURE Since the experiment with Python was a success, the first course is going to be fully taught in Python starting from the next (2009/2010) year. This will remove the need to use two languages in the lecture and will thus hopefully raise the quality of teaching even further. However, students also going on to take the second course in programming will now have to learn Java during that course which means it has to be rebuilt to accomodate that. However, since some of the students in the experiment also took the second course this year, we already encountered the problem and it seems that it can be overcome with relatively few complications. In the end, the students will recieve the benefit of being exposed to two different languages by the end of their first year. This will hopefully teach them that learning a new programming language is not hard and thus prepare them better for their further careers in which they probably need to learn a new language every few years anyways just to keep up with the changing world. REFERENCES [1] V. Ceder,N.Yergler Teaching Programming with Python and PyGame http://tech.canterburyschool.org/pycon/teaching_pygame.pdf [2] T.Donaldson Phyton as a First Programming Language for Everyone http://www.cs.ubc.ca/wccce/Program03/papers/Toby.html [3] N.Efford, On Teaching Programming With Python 3.0 http://www.comp.leeds.ac.uk/nde/papers/teachpy3.html [4] Google Application Engine http://code.google.com/appengine/ [5] Diwaker Gupta, What is a Good First Programming Language? http://www.acm.org/crossroads/xrds10-4/firstlang.html [6] Hadjerrouit, S. JAVA as First Programming Language: A Critical Evaluation. ACM SIGCSE Bulletin, Volume 30, Number 2. 1998. pp. 43-47. [7] J.Kiho, R.Ustitch, M.Tudre. Designing Computer Texts with AMADEUS. Software Technology. Proceedings of the Fenno-Ugric Symposium FUSST'99. Technical Report CS 104/99. Institute of Cybernetics at Tallinn Technical University. Tallinn 1999. Pp. 151-162. [8] McIver, L. The Effect of Programming Language on Error Rates of Novice Programmers. School of Computer Science, Monash University. [9] J.D.Oldham, What happens after Python in CS1? JCSC, vol.20 nr.6 (June 2005), p.7-13 http://portal.acm.org/citation.cfm?id=1060408 [10] Organizations Using Python http://wiki.python.org/moin/OrganizationsUsingPython

IV.17-4 © 2009 ACM

International Conference on Computer Systems and Technologies - CompSysTech’09

[11] H.Patterson-McNeill, Experience: from C++ to Python in 3 easy steps, JCSC, Vol.22, nr.2 ( Dec.2006) p.92-96 http://portal.acm.org/citation.cfm?id=1181901.1181919&coll=GUIDE&dl=GUIDE&C FID=29900695&CFTOKEN=54320081 [12] Python documentation http://www.python.org/doc/ [13] Python success stories, Python Business Forum, http://www.python-inbusiness.org/success/ [14] Pythonology http://www.pythonology.com/success [15] G. van Rossum, Personal Homepage http://www.python.org/~guido/ [16] Rossum, G. van: "Computer Programming for Everyone", revised DARPA funding proposal, August 1999, http://www.python.org/doc/essays/cp4e.html [17] J. Shuttleworth, Sarah Mount, Russell Winder Python for Rookies http://www.pythonforrookies.org/ [18] Wexelblat, R. L. The Consequence of One's First Programming Language. In Proceedings of the 3rd ACM SIGSMALL Symposium and the First SIGPC Symposium on Small Systems.Palo Alto, California, 1980. pp. 52-55. [19] J.M. Zelle Python as a First Language (Watburg College) http://mcsp.wartburg.edu/zelle/python/python-first.html

ABOUT THE AUTHORS All authors work in the Computer Science Department, University of Tartu, phone +3727375445, fax: +3727375468, e-mail for correspondence: [email protected]. Additional affiliations: Margus Niitsoo also works part-time in Cybernetica AS. Varmo Vene works part-time in the Institute of Cybernetics in Tallinn.

IV.17-5 © 2009 ACM