File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Teachers' Lounge and the fly likes Python as a first language Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Books » Teachers' Lounge
Bookmark "Python as a first language" Watch "Python as a first language" New topic

Python as a first language

John M Morrison

Joined: Jul 25, 2005
Posts: 21
We have been using Python as a first language at the North Carolina School of Science and Mathematics for five years. Anyone else out there doing that?
Rusty Shackleford
Ranch Hand

Joined: Jan 03, 2006
Posts: 490
The school I go to recently made Python the language used in the first programming course. Sadly, the next 4 courses use Java to explain the concepts. I think within 3-4 Python will replace Java in those courses.

"Computer science is no more about computers than astronomy is about telescopes" - Edsger Dijkstra
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17417

You can start some wonderful academic fights over what language to use for teaching purposes - and, in fact whether or not to use a "practical" language or a contrived one.

For myself, I'm not entirely happy with the idea of Python as a teaching language for the same reason I don't hold with BASIC. A major reason is the very reason why both are so popular - they make it entirely too easy to get in and start hacking.

This is academia. "Git-R-Dun" shouldn't apply here. If you want to form good habits, it's usually considered better to learn the rules first and then learn how to break them. Bad habits are hard to get rid of.

Java is a strongly-typed language with early bindings. Python is not. It allows you to concentrate on the code, but not on the data. Not everyone thinks that the data deserves to be treated so lightly. Remember that classic work "Algorithms + Data Structures = Programs"?

Python is a useful skill to have, but it's intended to show results quickly without the need for detailed analysis and planning. In the business world and the Hacker world, that can be a good thing, but when the goal is to master a discipline, development speed isn't the main issue.

An IDE is no substitute for an Intelligent Developer.
Rusty Shackleford
Ranch Hand

Joined: Jan 03, 2006
Posts: 490
That assumes on the idea that Python is a weak language. To compare it to BASIC is ludicrous, as is the idea that Python teaches bad programming habits. Python has been proven to be a solid language in real world apps. From the web to the desktop, to system scripts, python is being proven everyday.

It is also more orthogonal and elegant than Java. The fact that java is strongly typed isn't a teaching advantage at all. If an instructor wants he can restrict a single variable to a type throughout an assignment. Strongly typed languages are not inherently "better".

What data structure is not used in Python? I fail to see how your arguments match up with Python at all.

With your criteria C or better yet an assembly language should be the starting language as Java hides many of the important details that makes a good programmer. Even Java and Python programs benefit greatly by programmers who understand what is going on at the opcode level.

This is definitely not specific to Java but I see too many programmers that can't implement anything unless it is simple without relying on a library for it. So perhaps teaching assembly, then C, then OO concepts, then maybe a functional language concepts would produce more real programmers as opposed to API monkeys that come from academic programs that start out with Java or Python.

At this level students are learning the basics of how looping constructs and simple DS work and are given assignments to write their own programs implementing DS like linked lists, hash tables, and AVL trees. Writing these programs in Java(or C++ or C) can take a lot code, considerably more than Python. The ability to write a correct AVL tree faster is a huge benefit in academia since that means more time can be spent getting into the nitty gritty details and proper uses.

The elegance of Python vs the relative clunky-ness of Java is an advantage of students in departments that use Python first. In fact, I can see Java going away in these departments or at least being moved to an elective class like C++ often is.

In academia, students are taught concepts not languages. Using an elegant, easier to use language that stays out of the students way makes learning these concepts easier, not harder. For example teaching sorting and searching in Java requires stopping the class to cover the basics of interfaces and now generics which are fairly Java specific. Python is also great for teaching software design and implementation. It is not uncommon to see ~15 lines of Python code that would take 100+ in C++ or Java. Which is better in terms of concentrating of the concepts, avoiding, finding and fixing bugs?

In my opinion each class in core CS programs should use a different language, I have seen the effect of spending the first two years in mainly one language has on the ability of students to effectively learn other languages. Students who spend the better part of their first two years using java have a hard time moving into other languages because they think in java and not in programming basics. At least with a language like Python it is easier to move to other languages because it doesn't have quite so many language specific features that are core to using the language.
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Have a look

The Perils of Java Schools
College Advice

John M Morrison

Joined: Jul 25, 2005
Posts: 21
Do not get the impression I have a language bias. I am a language agnostic. The reason I like python for beginners is that, in a fairly short period of time, the students can see that computing can help them to accomplish real work and enable them to do significant tasks. It seems to be that this language is in the "Goldilocks sweet spot;" i.e. that the level of abstraction is "just right." Python is an effective tool for engaging the students' enthusiasm and interest. At this early stage of the ballgame, this is very important. If you frustrate your students with excessive abstraction or with operating at a very low level at an early stage, they don't go on and they don't develop, and they choose other fields.

It is a deliberate decision of our program for students to be exposed to more than one language. Our introductory course teaches procedural programming using Python. This is the first third of the year. The other two thirds focus on event-driven application development and on object-oriented data structures. We like for our students in each class to write a nontrivial application that applies the concepts they learned in the class. The switch from Python to Java shows the students early-on that different languages have different architectures, but that they do many of the same things. We place a strong emphasis on our students being able to read documentation and on being able to apply it to solve some problems they are working on. We are not producing "API Monkeys," but resourceful people who know how to scrabble out the solution to a problem. We develop the attitude of "use wheels, don't reinvent them." However, it is sometimes necessary to invent a new technique to solve a problem; our students learn to be resourceful and handle those situations as well. As we all know, there is no neat connection between existing code-bases and the new things we wish to accomplish.

In our second-year classes, we often program in C. By the time the students are to this level, this experience is meaningful and not frustrating. Our approach has bene successful. We have a program that is growing and we sending an increasing number of students off to the university who major in computer science, computer engineering, and related fields. Many of our students do co-op experiences at local companies, and their experience has been good. The are clever enough to be doing real work pretty quickly.
I agree. Here's the link:
subject: Python as a first language
jQuery in Action, 3rd edition