Python vs Java

9 August 2012

I have to think about whether we’re going to use Python again next year for ICS3U or whether we’re going to revert to Java. The move to Python was initiated by Boy. He had polled some Comp. Sci. profs at Carleton U. They were pretty clear that they would prefer to see students coming in with Python. I was crazy busy at the time and just said  “Go ahead. Whatever.” I came to regret that (non) decision, however, when I was subsequently teaching the course myself and had to re-work all my powerpoints and assignments into Python – not to mention learning the language on the fly as I taught it. But that’s mostly done now. The only gaping hole in my Python understanding is in GUI stuff. That shouldn’t be too hard to remedy.

OK. So where do I stand on all this?

I can see why Python is a good intro language for programming. Students can get up and running pretty quickly. If they have a moderate degree of aptitude, they can do stuff fast. And that’s a good thing. Why should they be hobbled by the grunting mechanics of a language (declare before use, rigid data typing, etc.) when that’s not necessary.

Still, I ran into some problems going through the course for the first time in Python and they didn’t have anything to do with the P.I.T.A. of converting my stuff to Python and personally having to learn the language. In a way, Python is too powerful. It’s like teaching someone to drive in a Ferrari. They can do a lot quickly. That’s for sure. But they can go too fast, too quickly. I spent a lot of time sorting out issues having to do with data typing. Students create a variable that they intended to be an int but they would get a value for it from stdin using raw_input. Fair enough but you can’t then turn around and use the variable as an int without converting into an int first. (raw_input always returns a string.) In v. simple problems this wasn’t much of a problem to figure out. When the programs started to get longer then tracking down what was going wrong could get difficult. They wouldn’t have had this problem in Java. The compiler would have flagged  the issue right away.

The other big issue I had was that Python made it really easy to write disorganized programs. Liberal declaration rules made scoping problems easy to miss. Students had a really hard time seeing that myInt in the main program was different than myInt in a function they had written. And Python’s use-right-away declaration policy meant that initializations were spread all over the place. Indeed, the whole notion of initialization was fuzzy. Even in Python it helps to make a point of initializing variables  and using them later but it takes a lot longer to see the value of it.

One Response to “Python vs Java”

  1. Love the new pics. Melting snow and bridges to walk over could prove an interesting experience though… well if you’re walking over a patch which doesn’t have a bridge underneath it……. Come on

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: