The Case For Replacing Java With Python In Education

Around 2003 all of the colleges and high schools in the United States switched from teaching Computer Science courses in C++ to teaching them in Java. The intention was to make it easier for students to pick up programming. Schools were finding that many students were struggling to cope with low level tasks in C++ like manual memory management and pointer references. Instead of learning algorithms, data structures and object oriented programming, students were stuck for hours trying to track down incorrect pointer references.

About four years after the education system made the switch to Java from C++, the whole software industry started complaining about the degrading quality of the Computer Science graduates in the US; which is a topic I explored recently. Ultimately, schools have made the switch away from C++, and they are unlikely to go back, nor do I think they should. Instead, what I want to discuss is why did we have to replace C++ with Java? I can see that at the time, it may have seemed the obvious choice, but looking around the language landscape now there are several choices that I think are better suited for the task. Namely, Python.

Java > Python How???

First, I want to really think about what advantage does learning programming with Java have over using a modern scripting language like Python? Python equally hides the things that make programming in C++ laborious and has many of the nice features that the JVM provides like garbage collection, unicode strings, and threads. The difference is Java is miserable for web programming (Java EE) and equally overly complex for building GUIs (Swing). As a scripting language, Python is far easier to pick and learn.

What CS students would lose from switching from Java to Python

What CS students will gain from switching from Java to Python

Overall, there is no big loss in Computer Science concepts when moving from Java to Python like there was when we moved away from C++. You trade static typing for dynamic typing and compilation for interpretation but everything else is just about the same and you gain Python’s simplicity.

One of the real problems with Java is that many students do not like to use it when programming for fun. Since the majority of students only become competent in Java, they only code they write is for their homework assignments. These are type A CS students. There is a second, type B, group of CS students. Type B students pick up another language like PHP, Python, Ruby, Clojure, etc. and are ones who spend time coding and creating cool things outside of their schoolwork. These students find programming on the side to be the most enriching and also the most educational. Employers often cite type B students, the self starters, as the ones they are most interested in hiring. If the only programming a student does while attending school is for their class projects, it is more than likely that they will continue this practice once leaving school, only writing code for their job. By making the switch away from Java in education, more type B CS students would emerge from American universities; enormously benefiting the software industry.

Comments

34 Responses to “The Case For Replacing Java With Python In Education”

  1. Rob Olson on January 27th, 2009 10:11 pm

    If you are wondering why I am pushing Python when my language of choice is Ruby. While I think Ruby would be equally suitable, I think it is more realistic to get Python adapted in academic institutions. In addition, Python seems more mature as a language, whereas Ruby’s pioneering community is more liable to make major changes to the language in the future.

  2. Nathan Esquenazi on January 28th, 2009 6:44 am

    All I can say is I definately agree with the sentiments here. Python would be well-suited to use as an introductory language in computer science.

    The language is mature with comprehensive library support, pleasant to use and a much more likely language to inspire students to explore outside the school curriculum.

  3. Jeff on January 28th, 2009 7:41 am

    “In addition, Python seems more mature as a language, whereas Ruby’s pioneering community is more liable to make major changes to the language in the future.”

    You forget that Python 3000 is not backwards compatible due to a somewhat large change in the language design.

    As for the current education system, you and I have talked about it a lot and I’ve come to the conclusion that the language doesn’t matter. Yes our CS education system is terrible but it’s not because we switched to Java, it’s because the institutions saw a need to dumb down the curriculum.

    Reflecting back on CS61A, I think it was a brilliant introductory course considering the topics it covered. Scheme as a language enabled us to learn the different programming paradigms without having to worry about memory management and data types and what not.

    The real problem is that the things you encounter in the real world are swept under the rug in academia so that you can learn the theory behind it. Classes do not exist to teach you about good memory management and efficient typing. The closest that comes to this is Programming Languages and Compilers and even then it was a very small fraction of the course.

    So what we have is institutions sweeping the complicated things under the rug and less students learning about them (except for those “B” students). When they get out into the real world, they’re not prepared to deal with all the skeletons that pop out and we’re left with less than satisfactory quality software.

    People tend to bash the trade schools that focus on training a person and throwing them into industry, I have no idea if it’s effective or not but it’s clear that the current academic situation needs overhauling.

    I guess the main difference the distinction between software engineering and programming. Programming is merely blue collar labor, no different than that of a secretary. Software engineering is about designing how things should be implemented and understanding how it will be used. Programming is a subset of software engineering focused on the execution phase. At this point I don’t think we’re training/educating enough of either category.

    Eventually programming languages will evolve so that everyone can program and the entry level programmer position is the equivalent to a modern day McDonalds worker. Until then, we just have to wait for those smart people to design that magical language that any idiot can use…hopefully we’ll have some smart people being produced by our education system.

  4. Sam Kaufman on January 28th, 2009 8:19 am

    I wish I could write a longer reply, but to be brief:

    I think that most (engaged) computer science educators agree with you. Certainly nobody thinks Java is a good teaching language; Java is taught for compatibility with the AP CS tests in light of tight bureaucracy and resources.

    One strain of thought is that the language matters more to the instructor than the student, but where it doesn’t, the main decisions to make are: – functional or imperative programming? – microworlds, media computation, or traditional curricula? It seems like dynamic typing and interpretation, while handy in the real world, don’t matter much to novices.

    A few teachers are using Ruby, but most who’ve tried send along bad notes after bad experiences with whatever libraries they’re interested in—microworlds, SDL, that sort of thing.

    This is my interpretation from following SIGCSE discussions and speaking with lecturers here, at high schools, and abroad. Grain of salt.

  5. Mario on January 28th, 2009 5:28 pm

    I share your point of view. Python could be a good introductory programming language.

    Here, in Mexico, the main university (UNAM) still uses C as the language for Introduction to Programming, even Pascal, some times.

  6. Rob Olson on January 29th, 2009 4:50 am

    “Java is taught for compatibility with the AP CS tests in light of tight bureaucracy and resources.”

    If I recall, during the switch from C++ to Java, the universities switched to teaching Java first and the AP CS test followed suit later. Certainly College Board does not control the college curriculum. It is the other way around.

    In my opinion if schools successfully able to make the switch from C++ to Java they can also handle switching from Java to Python.

  7. Mark K on January 29th, 2009 5:42 am

    I’m uncertain how using Python as an introductory programming language for Computer Science majors would produce more Type B CS majors than using Java as an introductory programming language does now. Couldn’t an argument be made that the cause of Type B is inherent to the person, and not to the first language a person uses?

  8. Mark K on January 30th, 2009 12:52 am

    As a followup, I recently checked on the requirements of the introductory programming courses at the other two institutions of higher learning.

    Both programs exclusively use C++ for the first year, just like they did when I attended those places. It’s not a lost cause! Some places are still trying to fight the good fight!

  9. Rob Olson on January 30th, 2009 9:22 pm

    @Jeff-

    I actually did not forget that Python made that brazen change in Python 3000 and I commend them for that. Breaking backwards compatibility is a tough thing to force on the hundreds of thousands of people who use your language. However the change was (to my knowledge) fairly cookie cutter, so much so that a automated 2to3 coverter program is available.

    Ruby 1.9 also breaks backwards compatibility with Ruby 1.8. From what I’ve seen the changes are not so straightforward that converting can be fully automated.

    “Scheme as a language enabled us to learn the different programming paradigms without having to worry about memory management and data types and what not.”

    I considered addressing topics like Scheme in this post but decided against it. In an attempt to keep the post short and straightforward I wanted to just talk about replacing Java with Python. But I of that same opinion that Scheme can be used very successfully as a starter language. Be that as it may, even programs that teach Scheme like UCI, use it for the first couple courses and than switch to Java for the meat of the curriculum.

    Finally, certainly switching from Java to Python is not going to fix everything that is broken about CS education. I was not even trying to claim that. But it would be progress and is something to consider.

  10. Jeff on February 1st, 2009 7:54 am

    I think I originally had a point in mind when I was writing but then I got distracted and started rambling.

    But I believe my main point was that switching languages does not matter and the language itself does not matter as long as you are not restricting yourself to what you can achieve.

    I just think that CS in regards to academia and industry are heading in opposite directions.

    You’re still going to have the people that enroll in CS thinking it will get them into a high paying blue collar job, they’re not going to make the effort to learn about cool stuff, they want their degree and a salary that they think they deserve. I think we should kick all these people out into a trade school like ITT.

    And you have the people that truly enjoy CS that will take the extra effort to learn things on their own. These are the people that you want in higher education CS programs so that they can go on and contribute to academia through research.

  11. Sam Kaufman on February 8th, 2009 6:21 pm

    @Rob: You really don’t think this isn’t a reflective process? Most teachers sitting on the AP CS board are mid-to-top-tier college professors. These are coordinated switches.

  12. Sam Kaufman on February 8th, 2009 6:22 pm

    @Jeff: I think you’re onto something. Also, I’m not sure when the last time I heard knowledge work called “blue-collar.” :-)

  13. Matthew on February 19th, 2009 9:28 pm

    “I would also wager that even the ones that do can be solved in a satisfactory manor with Python.”

    It should be noted that most students in higher education live in flats and shoebox apartments. Their ability to program at home could be compromised if Python requires such upscale accommodation.

  14. Zach on February 20th, 2009 3:59 am

    I’d personally way rather learn Python then Java. But if you have to pick one to teach at a high school, having a Java foundation is more likely to get you a job than a Python foundation.

  15. Tony Morris on February 20th, 2009 8:12 am

    “nearly everyone who programs dynamically typed language for a while finds out that the type safety provided by static typing is unnecessary and more often gets in your way than it helps you”

    Nearly everyone who programs dynamically typed languages, and has a sound grasp on type theory, is well aware of how incredibly important and necessary a static type system is.

    Java is an awful teaching language, but let’s not replace it with more junk. Type system theory is an absolutely essential undergraduate requirement – if for no other reason that they stop making slip-ups like this one!

  16. Steve on February 20th, 2009 10:49 am

    I’m not sure the choice of language matters. Once you’re competent in one high level language, picking up another is pretty simple (I should say I’m not including C as a high level language).

    That said, we did Java at university and I can’t see any advantage in it that I wouldn’t have got from another object oriented language.

    Given the wide variety of languages and the different ways that they can be used (for gui programs, for games programming, for web programming) I wonder if it might be better to teach just a sample of a few that serve different purposes (PHP, Python and C++ for example) and then give students the choice of one depending on what sort of career interests them the most, then they can be streamed into a language most suitable for that.

  17. Oziel Jose on February 20th, 2009 2:02 pm

    i think that is a place for all languages, and also c++, after all you should know how the memory gets manipulated because if you go deep in the languages that are garbage collected, you end up having to understand memory usage after all to get the best performance.

  18. Michael on February 20th, 2009 2:08 pm

    “The difference is Java is miserable for web programming (Java EE) and equally overly complex for building GUIs (Swing).”

    Are you serious here or did you just never had a decent teacher?

    First and foremost: I love python just as much as the next guy – it’s ‘cute’.

    That being said I can’t really say schools have finished making the switch and your proposing another switch? While some have nailed down the curriculum somewhat, you can’t just get new teachers. A company moving to a new language takes time – with schools it much worse. This is because teachers teach, which is simply not the same as ‘doing the work’. As such teachers aren’t exposed to the language as much. Many teachers I see today are still ‘clumsy’ and end up send students down a path of pain because there knowledge is not up to date. Like teaching jsp without teaching jstl (there are better examples)

    Anyways switching again without big advantages isn’t something I opt for. Your listed advantages aren’t too convincing.

    “But I believe my main point was that switching languages does not matter and the language itself does not matter as long as you are not restricting yourself to what you can achieve.”

    Which is why switching to java made sense as also noted in the article. As a higher language doesn’t take you away from the concepts too much. Switching from java to python and the bumb that it would remove is absent if not marginal at best.

    As for the actual java vs python I’ll leave the IDE support aside – java’s documentation and it being at your fingertips is something…

    Also python already has his place in AI courses alike if I’m totally mistaken and it does have huge added value – it will ‘spread’ accordingly.

    any active effort to switch doesn’t really make sense to me however I slice it.

  19. Terry on February 20th, 2009 3:04 pm

    I think Python would be good as an introductory language but C++ still needs to be taught in schools. Students need to understand that garbage collection, memory management, and pointers are not magic. Also, the academic curriculum is too theoretical doing students a HUGE disservice when they get out into industry. Students in their senior year need to build applications as a team,use version control systems, continuous integration and using/writing unit tests,etc. Accepted industry practice shouldn’t be a mystery to graduating students.

  20. Steve on February 20th, 2009 4:34 pm

    The purpose of a Bachelor’s degree should guarantee gainful employment + add value that the trade school doesn’t give. It certainly needs to do at minimum what the trade school provides…

    Higher level degrees like Master’s + PhD should delve more into the theory.

  21. Yusuke on February 21st, 2009 8:28 am

    Texas A&M University has made the switch back to C++ from having a Java intensive curriculum, but Bjarne Stroustrup is now a dept chair there, so it is to be expected.

  22. Paddy3118 on February 21st, 2009 9:44 am

    I think you are half right.

    We could employ students with Python and C experience. Not C++ – it’s too large, but you need the C experience to teach the low level.

    Don’t teach them seperately, teach how to profile a Python program, how to explore different algorithms, and how to write performance critical sections in C and access the C from Python.

    • Paddy.
  23. Elliotte Rusty Harold on February 21st, 2009 2:19 pm

    I have to challenge your initial claims and consequent causality. Perhaps a few universities had switched from C++ to Java circa 2003, but most that switched at all switched years earlier. (Of course, there are still some using C++, Haskell, Scheme, and other languages.) In any case, I don’t think you can tie a purported switch in 2003, to complaints about the degrading quality of the Computer Science graduates four years later.

    And now that I think about it, I’m not sure I buy the claim that there’s an increase in such complaints lately either. I’ve noticed no such increase in complaints, and I do recall these complaints going back about 20 years. I’m not sure there’s any actual effect here to tie the switch in languages to.

  24. Elliotte Rusty Harold on February 21st, 2009 2:29 pm

    That said, there may well be a good case to be made for switching into programming from Java to Python. However, you’re going to have to make that case on grounds other than the inevitable fact that businesses complain that universities are not providing vocational training tied to exactly their unique needs.

  25. Arya Asemanfar on February 22nd, 2009 12:37 am

    The problem, if there indeed is one, is two-fold.

    Programming languages are tools

    When you have a hammer, everything looks like a nail. But let’s be honest, not everything is a nail. Students who only utilize classrooms as a source of programming knowledge are only taught to use a hammer thus don’t see the opportunity to write a Python script to periodically scrape starcraft2.com/faq.xml for a release date (god dammit Blizzard); read that again, it was a run-on (but hey, I’m CS not English).

    As a consequence, hammer-equipped students are essentially classically-conditioned (yay psychology) that programming solves a certain type of problem and get stuck that way. By exposing students early to different tools, they learn to see solutions to building skyscrapers, tree houses, modern architecture, and fixing faucet leaks.

    That said, given that most college students are more likely to have the need for a small convenience script, or a blogging engine, or a web application they should at least be taught to use Python, Ruby or PHP. And for some obligatory evidence, it was Mark Zuckerberg (controversy aside) who wrote some PHP codez to form Facebook and these two cool cats named Sergey Brin and Larry Page who used Python (and Java) when starting this small company named Google, you may have heard of it. Yes, at some point they started using more Java and C++ and there are plenty of examples where Java was used from the start, but the point is that Java is not the only tool, and other languages should be taught so students can solve a greater variety of problems.

    Sorry for the overused analogy, it just fit so damn well for what I wanted to say.

    What is your job?

    I don’t care what your job is actually, but I know what professors at research universities’ jobs are: research. An significant chunk of universities are research universities, including the university of this blog’s author. As a consequence, few professor are concerned with students’ needs and what would help the best for when they graduate.

    I’ll leave it at that, if you want more about how research universities as a whole are flawed as an education system, Google it (which btw probably hits platforms written in many languages, not just Java).

  26. Paul King on February 22nd, 2009 10:10 pm

    You could throw Groovy into the mix. It is very Python like but uses Java-style syntax so it would set students up to move in either direction.

  27. Michael on February 23rd, 2009 6:07 am

    To add:

    “When you have a hammer, everything looks like a nail. But let’s be honest, not everything is a nail. Students who only utilize classrooms as a source of programming knowledge are only taught to use a hammer thus don’t see the opportunity to write a Python script to periodically scrape”

    Can you actually back this up in any way.. I mostly see this behaviour with ppl that learned a language outside of school in their childhood. Go to school where they start learning a new language reject it because they start out to basic etc.

    People who learn it there first year at school are much more open minded and start mapping languages based on concepts and not how well or easy it does compared to the language they already know.

  28. Rob Olson on February 23rd, 2009 5:41 pm

    @Paul King- I concur about Groovy. I read the first chapter of a learning Groovy book in our library and was very impressed by what I saw.

  29. blick black on February 24th, 2009 2:08 am

    I disagree with both Java/Python being taught in schools. My main problem with both of the languages are the high use of available packages. Yes c/c++ is a bitch to learn. But, once you know c/c++ you can pretty much hop on any other language and pick it up with ease.

    Wasting time tracking down a memmory leak? Good. Better to spend time in college learning these things than in a work environment.

    c/c++ being low level and closer to the actual machine code is a huge boon in learning what is actuall happening with each line of code. Some will argue that you don’t need to know this, and high level languages are the future. I would highly disagree. Weather the job you will have in the future will care about memmory is not the issue. When these issues are in you head you take them into account unconsiously and write better code.

    I’m tired of everyone trying to make programming in college “easier” so more people can learn it. I think the problem are the teachers, not the language.

    I would rather be put through the trenches in college when I can afford to fail multiple times and learn then get fired because I couldn’t figure something out. The students are the losers here unfortunetely. In the end I’m glad I know c/c++ and chose to follow it in school.

    It’s taught me flexibility and learning languages like python and java come with relative ease. The hardest part is learning all the libaries that are included with both languages.

  30. Arya Asemanfar on February 24th, 2009 8:32 am

    @Michael

    Can you actually back this up in any way.. I mostly see this behaviour with ppl that learned a language outside of school in their childhood. Go to school where they start learning a new language reject it because they start out to basic etc.

    I can confidently say that I learned a language or two before college, and came out knowing more about most languages than a majority of my fellow classmates.

    People who learn it there first year at school are much more open minded and start mapping languages based on concepts and not how well or easy it does compared to the language they already know.

    And, can you actually back that up in anyway? You’re pretty much calling people who take initiative to learn something they’re interested in closed minded, that’s quite the leap.

  31. Software Quality Digest - 2009-02-25 | No bug left behind on February 25th, 2009 8:02 pm

    [...] The Case For Replacing Java With Python In Education – “Overall, there is no big loss in Computer Science concepts when moving from Java to Python like there was when we moved away from C++.” [...]

  32. Dmitri Arkhipov on February 26th, 2009 9:45 am

    While not coming from a particularly authoritative source, I tend to disagree with your suggestion that java has better performance than python. I have been running many compute intensive algorithms these days in both python and Java. For example Naveen and I ran Dijkstras and bellman-ford on both sparse and dense networks of several thousands of nodes with python resoundingly beating Dijkstras in most cases. Furthermore I have recently run some pretty complex code using multiple modules in python to perform linear minimization on a substantive scale. I did similar tests in java. All of these experiences and some others showed me that python performed much more quickly than java at an equivalent task.

  33. ASM on March 13th, 2009 3:35 am

    Instead of teaching a single language, students should be required to program in multiple languages, thus internalizing the concept that programming languages are merely tools and they need to be facile enough to choose the best ones for the job from a growing toolbox.

    From a one-liner in awk for processing lists to a one-pager in Python (and the same assignment n Perl, for the fun of it), to a device driver in C. Why not?

  34. Nervous Cat on March 30th, 2011 5:47 pm

    Sorry to narcopost, but Java is an improvement over Pascal which was defacto 25 years ago when I was in college. C was new and considered an elective course. I preferred C but the profs like Pascal in the 1980s, and then Modula-2 in the early 1990s.

Leave a Reply