What programming language to teach?

I just found out I’m teaching a high school Intro to Programming class. The previous teacher used python, but I’m thinking of using Ansi-C or Java.
In today’s world, what would be a good language for a student to learn?

See recent thread “What’s the best language to learn programming with?”, perhaps.

I’d say it depends on the crop of students you’re going to get. If you’re going to get people who aren’t already technologically inclined or just want to be able to make things, go with Python. If the class tends to get people who really want to be engineers or software engineers, or else people who really want to understand programming and the computer go with C. While I have my favorite languages that I think might be best at a purely philosophical, they’re not popular. I think C and Python meet a healthy intersection of having sound concepts and being popular enough to be useful.

I would lean toward Python, upon doing some straw polling and talking to some faculty, I’ve been finding that at a college level people with backgrounds in C tend to drop out or struggle more when exposed to OO languages compared to those that start with Python, Ruby, or C. If you want to do C I’d actually lean towards teaching the more C-like subset of C++ (e.g. treating it as C with Objects). C# may also be a good choice, depending on whether or not you’re already familiar with it.

I vote for Python. It’s a great language to teach as an introductory language, and its actually used in quite a bit of scientific applications.

Java is not a bad choice either, as far as utility goes, but it’s a lot more difficult to teach introductory programming with it.

  1. Something free for the students.

I will guess that students willing to fulfill an elective taking a computer programming class are going to be more computer-savvy than those who choose to take, say, intro to Excel.

Python/C#/VB maybe Java.

One edge I will give to Java over C is the ease of integrating visualization tools. While I don’t like classes that teach Swing to beginners (especially because Swing is kinda bad anyway), I’m really biased towards showing beginners what their programs do. And showing them what they do in a way other than just passing test cases. I do like the idea of essentially having the class write plugins. E.G. write a backend for Dice Wars, but force students to write the undirected graph implementation that allows the game to figure out who is next to who. This also gets them used to implementing code in somebody else’s framework, so they have to return things in a certain format – not just format things however they feel like it. (And, of course, at the instructor’s discretion additional constraints can be imposed – e.g. you must use an adjacency matrix in your implementations)

Obviously this needs to be mixed up so that students write a few programs with an entry point so they’re exposed to main functions and console interaction like printing, and you have to be careful that they’re not bogged down in your framework. In other words, your framework should rely on their code returning the correct things, their code should have to call your code as infrequently as possible (excepting utility functions that make things easier for them).

I think Python also has relatively simple visualization too, doesn’t TKInter do something similar? (You have to install it separately, but it’s platform independent and easy to set up and work with).

Of course, this all depends on how much time the instructor is willing to spend developing project backends.

What about Ansi-C to start out then move to Python and Java to give them a taste of the more modern options?

I’d go the other way, start with Python and then move to C to show them what’s going on under the hood. C is cool, but I’d consider managing memory leaks and dangling pointers to be “intermediate”.

I’d suggest spending some time on Windows Script Host. Tie it into Python with PythonScript.

I think students would get more out of learning to manipulate windows through scripts. It’s more hands on, practical application that they can actually use outside class.

Yes, It really depends upon what the cohort is, and what the expectations are.

I have had the argument about undergraduate teaching languages many times over the decades. But that argument is about what to teach future professional programmers with. A high school intro class is a very different problem. It reminds me of taking chemistry at high school. I never took it any further. I did take physics further, but my last formal chemistry was at high school. I still use that knowledge in day to day life, but nothing more complex than maintaining a pool, and generally applying simple principles to everyday matters. I don’t earn any money that depends upon professional application of knowledge of chemistry. But there were other students in the class at school who did take chemistry at uni level. I don’t think any became professional chemists, but there were doctors, a biologist, and quite a few engineers in the making.

If you want to give a cohort of students a flavour of what is possible, Python is great. You can do a wide range of interesting things quickly. But if you have aspirations of teaching a set of skills that feed into a career, it might not be the best. But given the level and range of outcomes needed, I would be hard pressed to think of a better language.

As for teaching future professionals, there is no single language. They all have issues and compromises, many of them intrinsic to the nature of their target use. Personally, if I were creating an undergraduate course I would teach a combination of C and Python.

That assumes all the kids have Windows, though. It’s a decent enough bet, but I’ve certainly known Mac families and even Linux families. It would be a pain to force one or two kids to have to come into the lab to do homework.

Bash scripting is a bit more portable, since you can install environments that interpret Bash on Windows relatively easily (though this is only “relatively” easily, I still wouldn’t recommend making them set up cygwin or msys).

The current AP computer science curriculum is based on Java, and so are most college-level introductory programming classes. As much as I personally dislike Java, I think you’d need a pretty good reason to teach something else.

It all depends on the purpose of the high school course. I can see just focusing on introducing programming to teens. Give them some useful skills they can use outside class. Theres no reason to structure the class for CS majors in college. Maybe if they enjoy the class then some of the students may consider a CS degree, but most probably won’t.

The AP course outline includes these words (bolding mine):

Personally I see this as a problem, not a cure. Unless there is a specific desire to present a course that will garner credit at tertiary level going down the standard CS pathway is the wrong thing to do. It really is a difficult question. It may be that teaching such a CS course at secondary level is what the world should do, but one needs to be quite clear about the objectives that the course provides, and what the students need.

Basing wanting a CS degree off a programming course (even AP Comp Sci) is folly anyway. I knew several people who did that who ended up dropping out of the major (or perhaps more accurately: only going for a minor) because CS is so math heavy (and mostly proof-riddled discrete math, which is also incredibly different from high school mathematics). Sure, if you hated your high school programming course CS probably isn’t for you (unless it’s just because you hated your instructor) – but in my opinion high school “CS” courses basically never prepare you for what a CS degree entails.

Now, a software engineering degree is another thing entirely – but a lot of places don’t offer those.

Moved to IMHO from General Questions.

samclem, moderator

FORTRAN is as good today as it ever was, and it was good enough for me!

Lordy, I haven’t seen that in a very long time. :smiley:

But I did get a very harsh reminder of it a week or two ago. Debugging a C++ program written in Fortran IV. It really was. Right down to the author indexing arrays starting at one. Compiled as C++, written as Fortran IV. Worked, astoundingly.

Modern Fortran, in F95 or later form is not a dead language, and is exactly the right tool in some cases.

I’d suggest staying with python.

Python, as an interpreted language, is by far the easiest for beginners. You can just open up the interpreter and start typing in commands!

>>> x = 4
>>> y = x*3
>>> y
12
>>> L = [x,y]
>>> L
[4,12]
>>> print “My list has %d elements” % len(L)
My list has 2 elements

Can’t get more basic and immediately useful than that.

Most kids who are taking a high school programming course are not going to become CS majors. You want to show them some basic concepts without scaring them away with manual memory management © and the One True Object Oriented approach (Java).

I’m going to throw out an oddball to consider. How about Groovy?

It has the advantages of Python in that it is a scripting, dynamically typed language. You can open the groovy interpreter just like the python example right before this post.

However, Groovy is also based on Java. It runs on the java VM, you can type java code and run it as Groovy, and you have full access to all the Java libraries to call from your code.

So you can start with a simple interpreted language and gradually add complexity during the semester until you’re doing full OO code which is Java with improvements.