programming for the fun of it

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

Static Typing – The difference between an Integer and a Float is harder to understand when you do not have to declare variable types.

Compilation – In my opinion this is not a big deal. They are still going to learn how to debug runtime errors which is where the substance is. Advanced IDEs like Eclipse are making dealing with compiler errors almost a thing of the past in Java. Additionally, the upper division compilers class will still be there to teach them the ins and outs of compilers.

Performance – This is a moot point. I only put it down because it is what most people think of first but very rarely do the projects assigned in a classroom require serious computation. I would also wager that even the ones that do can be solved in a satisfactory manor with Python. If anything it will force students to be more creative about their solutions instead of just relying on brute force.

What CS students will gain from switching from Java to Python

Dynamic Typing – There are tradeoffs to both approaches but as 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 (ex. Casting).

Interpretation – Becoming familiar with interpretation is just as important as compilation. Interpretation opens several doors for you when programming and is becoming more common. In addition it gives you helpful tools like an interactive console.

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.

Post navigation

37 thoughts on “The Case For Replacing Java With Python In Education”

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.

“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.

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.

“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.

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?

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.

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.

“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!

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.

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.

“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)

“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.

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.

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.

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.

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).

“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.

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.

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.

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.

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?

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.

I learned Scheme at the University of Minnesota, after I already had a couple of years of programming experience in C and Assembler, plus several years of college projects in Java.

I think Scheme is a horrible language, dreamed up by a clique of hackers many decades ago, and patched here and there over the years, not by an internationally recognized authority, like Java and C++, but by themselves or other like-minded hackers. Yes, I know that it now has a “seal of approval” now, but that is beside the point. It wasn’t created from the outset to be a secure, strong language like Java with a lot of lessons learned from past language flops, but is nothing more than a hacker’s crank language that now has a “seal of approval” upon it.

In Scheme, you don’t learn a basic principle of OO, which is code re-use; instead, you learn how to write throwaway code that is used only once, which is a principle that I have been told seemingly endlessly since I started in software in 1997 is a very bad thing.

Everything that I learned in the Scheme class I could have learned just as well using Java, and I would have been learning a language that I could actually USE in my software career instead of a DIAPER that would be thrown away when it was no longer needed, and then have to go on and learn an OO language anyway, when I could have done that right from the start!!

If people are actually using Python for something in the workplace, I think it is a fine language to learn, but it is a fringe language; not mainstream; and therefore I think Java should remain the mainstream training language for colleges. Having said that, it is also important to have a good mix of languages to learn in college, not just Java. Python could and probably should be part of the mix.