[Edu-sig] Using Jython to merge Python and Java for CS1

Kent Johnson kent37 at tds.net
Mon Oct 18 13:51:38 CEST 2004


Mike,

I think you may be expecting too much of Jython. 

Jython code is Python - it uses Python syntax. A program that runs in CPython 2.1 and uses only libraries supported by Jython will run in Jython as well.

What Jython does very well is integrate with Java libraries. For example a Jython program can use Swing for a GUI, or dom4j for XML access.

The part of your plan I don't get is "gradually increase the amount of Java in their code until they were eventually writing pure Java programs."

You can't mix Jython and Java in a single module. The Java pieces have to be separate from the Java pieces. You can write a Jython module that calls a class written in Java, for example. For a typical small class project I think this would be awkward.

To run Jython you have to have a basic understanding of how to run Java programs, too.

A better approach might be to start with CPython, then show the students how to do the same thing in Java. (I would expect groans of disbelief! Java is really painful compared to Python!) Then maybe you could show how Jython gives access to both worlds.

You could use Jython as a way to introduce the Java libraries. For example writing a Swing application is much more pleasant in Jython than in Java, and the Jython interactive shell is a great way to explore Java APIs.

Kent

> 
> From: "Michael S. Tashbook" <mtashbook at mailbolt.com>
> Date: 2004/10/17 Sun PM 10:57:23 EDT
> To: edu-sig at python.org
> Subject: [Edu-sig] Using Jython to merge Python and Java for CS1
> 
> Hi, folks,
> 
> I'm a long-time lurker, first-time poster. I'm in a bit of a pickle, and
> I think I may have found a way out, but I wanted to get some sage advice
> from you guys and gals before I do anything rash. Apologies in advance
> if this is a bit long-winded.
> 
> I'm currently in my first semester of teaching CS -- up till now, I've
> been a grad student TA, so I really didn't have any say in course
> design. One of my courses is CS1, which is taught in Java. Technically,
> there's a prerequisite course to mine, which is supposed to expose the
> students to very, very basic programming (in Java) before they hit their
> first "real" CS course. From what I can tell, though, and contrary to
> what I was initially led to believe, the students are still have
> virtually no programming experience. As you're no doubt aware, Java
> isn't really the best way for new programmers to cut their teeth. Java
> 1.5 will help somewhat, especially with console I/O, but there's still a
> steep learning curve.
> 
> While I pick up the pieces from this semester, I'm trying to figure out
> ways to do a better job in the spring. I'm a big fan of Python, and I
> sincerely believe that it's a better beginner's language than Java, but
> I'm limited by the constraint that subsequent CS courses (CS2 and CS3)
> expect the students to be proficient in Java.
> 
> It occurred to me that I might be able to get the best of both worlds
> using Jython. Ideally, I would spend the first half to two-thirds of the
> class teaching basic programming and OOP in Python, via Jython. The last
> part of the semester would then transition the students to Java --
> "Here's the Java way to do all the stuff we've been doing so far in
> Python." Since Jython is Java-based, I would expect that the transition
> would be fairly smooth, and the students could gradually increase the
> amount of Java in their code until they were eventually writing pure
> Java programs.
> 
> Has anyone tried this approach? If so, was it successful, or are there
> "gotchas" that I need to watch out for? Am I overestimating the feature
> set of Jython?
> 
> If possible, I'm looking for ammunition to use when I present this idea
> to the department chair. As I said, I'm still in my first year (and thus
> have to contend with my own inexperience and the fact that I only have a
> one-year contract at the moment), but I think that this would be a
> worthwhile experiment. In particular, my department (at SUNY Stony
> Brook) is looking to increase retention, and I think that a "kinder,
> gentler" approach to CS1 might help that goal.
> 
> I'd greatly appreciate any feedback or insight anyone has to offer...
> 
> Thanks,
> 
> Mike Tashbook
> mtashbook at mailbolt.com
> _______________________________________________
> Edu-sig mailing list
> Edu-sig at python.org
> http://mail.python.org/mailman/listinfo/edu-sig
> 




More information about the Edu-sig mailing list