I recently experienced an introductory programming course through the eyes of a first year student at another institution. The course was in Java and based around object-oriented concepts, so much so that the course’s title included the words “object oriented”. It honestly did not seem like a course I would advocate any novice programmer to undertake, and it solidifies the notion of why I think a lot of students taking introductory programming classes end up hating programming (and I mean non computer science students). I say this from an understanding of having taught first year programming for 15 years to a mixed class of CS, science, and engineering students (in C no less).
Only one phrase is needed – programming complexity. The class in question seems to want to do everything under the sun, except actually teach the fundamental concepts associated with programming. Then they commit two of what I think are the greatest mortal sins – adding OO, and using Java (oh, and hardware too). Let’s start with OO. For people who have never programmed before, OO is not something that should be taught. There, I said it. I know a good number of institutions advocate for “OO-first” and the arguments for and against it are almost as extensive as those relating to the choice of introductory programming language. But here’s the thing, OO is just a method of encapsulating the solution to a problem. If a novice programmer does not understand the fundamentals of problem solving, algorithm design, basic programming constructs and testing, then what’s the point of OO. Problems can much more easily be solved without it, *especially* in an introductory course. Why would anyone want to throw the likes of classes, objects, inheritance, abstraction, message passing, encapsulation, information hiding and polymorphism (to name but a few), at students who have *never* programmed before.
It is these far-flung concepts, and often mediocre, poorly chosen examples that lead many students to hate programming. When you introduce the basics of programming, OO just isn’t warranted. I know there are a lot of “objects first” advocates out there. The problem is that students get so absorbed into learning concepts related to OO, they never learn the fundamentals of programming. Then, there is Java. Java is good for somethings I guess, but it is not a language I would advocate for as an introductory language, or frankly to build any large system in. Why? There are better languages out there. Would I use Java to build an avionics system, or perform parallel computations? Certainly not.
But for novices programmers, a poor choice of language can have long-lasting effects (although few long-term studies have been done on this, because computer science pedagogy is funded by very few). Java adds complexity to introductory programming, in the same vein that C is not an optimal introductory programming language. Here’s an example of “Hello world!” in Java:
public class helloworld {
public static void main(String[] args) {
System.out.println("Hello world!");
}
}
A lot of effort to print out two words. Oh, but it gets better. In order to make the program do something, it has to first be compiled, using javac to produce a .class file, which can then be executed using java.
javac helloworld.java
java helloworld
And here lies the problem. Novice programmers spend so much of their time dealing with the intricacies of the programming language that they don’t actually learn about the concepts underpinning programming. What does it mean? Well let’s see how it could be explained:
- The first line of code indicates the name of the class, which is helloworld (long pause to explain what a class is). The class uses an access specifier public, which indicates that the class is accessible to other classes from other packages.
- The second line of code indicates the name of one method in helloworld, which is the main method. The main method is the starting point of a Java program. A long effort could be spent explaining what each part of this statement means.
- The third line of code, uses the function System.out.println(), to print the text enclosed by quotations onto the screen.
Yikes! Likely a lot of “don’t worry about this, we’ll cover it later”, largely because of the presence of OO. In this case even C is a better language (partially because it is not OO, and hence less verbose). Here’s the same algorithm in C.
#include <stdio.h>
int main(void) {
printf("Hello world!\n");
return 0;
}
But even here there are nonsensical terms (for the novice programming) like void, and even “return 0”. Printing “Hello world!” shouldn’t be this hard, and in some languages it isn’t. The overhead of languages like Java just adds to the cognitive load of learning to program. Here is the Python version:
print("Hello world!")
Here is the Julia version:
println("Hello world!")
Here is the Pascal version::
program Hello;
begin
writeln ('Hello world!');
end.
All are easy to understand, simple, and don’t involve OO. It is the complexity of languages, and abstract concepts taught that makes many novice programmers nauseous. A bad initial experience can lead students to avoid programming like the plague, which is especially problematic if they are working in fields that could benefit from the knowledge base programming provides.
The bottom line is that some methods of teaching programming in post-secondary institutions are not exactly optimal. Languages may be chosen because of faculty likes and dislikes, and not what is optimal for a learning environment. C was never meant to be an instructional language, and certainly not for non-CS students. Fortran and Cobol were discarded from teaching because they were “old”, but are today still amongst the most highly used programming languages. Notwithstanding the instructor who teaches a Java class in the guise of “OO” – students never learn OO, they learn the OO syntax of Java. There are many reasons why novice programmers end up disliking programming, but language choice, and complexity of instruction do tend to sit atop the stack.