Python is not the Language for APCS

Python+is+not+the+Language+for+APCS

It is a common belief that Python is the best language for entering the world of programming, and to some extent this is true. Python has a simple syntax, making it easy to learn the language by yourself, much easier than trying to learn Java. But in AP Computer Science (APCS), we don’t have to learn a language by ourselves; we have a teacher to move us through advanced concepts faster than one could do on their own. Python in a classroom setting would just drag everyone down.

One of the biggest problems with Python is that it has a loose structure. At the beginning, this is a blessing to any prospective coder, but as time goes on, the strict structure of Java makes the progression through computer science topics faster and more intuitive.

As an example:


Python:

————————————————————————

print(“hello”)

————————————————————————

Java:

————————————————————————

public class Hello {

public static void main(String[] args) {

System.out.println(“hello”);
}

}

————————————————————————-

As you can see, a task as simple as writing “hello” takes 5 times more lines than it does in Python; even the function call to print to console is long. But all of the verboseness in Java has a meaning. When a beginner looks at this code they may think, “What is public class, and what is public static void main, and what is System?” In APCS, all of these concepts are explained from the beginning and built upon throughout the year, creating a foundation that is extendable to all object-oriented languages. A great example of where using Java really helps is in inheritance. Let’s look at an example of this in both languages:

Python:

————————————————————————

class Cube(GameObject):

  def __init__(posx, posy):

Person.__init__(posx, posy)

  def gettype():

return “Cube”

————————————————————————

Java:

————————————————————————

public class Cube extends GameObject{

public Cube(int posx, int posy){

super(posx,posy);

}

@Override

public String gettype(){

return “Cube”;

}

}

————————————————————————-

Java certainly has its own oddities, such as the addition of annotations (@Overried), but overall this code is very similar to the first code. On the other hand, Python looks completely different. Now, we’ve introduced classes and functions which were omitted from the first example. This is not to say that Python couldn’t be taught in a way that introduced all of these concepts in the beginning, just as we do in Java, but Java’s constant reinforcement of object oriented principles through its strict structure makes progressing through advanced topics easy and without a need to backtrack.

There is no panacea language to teach Computer Science, and while I think Python doesn’t deserve a place in the APCS at Keystone, other languages do. Unfortunately at this point my knowledge of other Computer Science topics heavily breaks down, so from here on is pure speculation. Through my continuation of learning code through Dr. Stack, I have found that only learning in one language makes transitioning to other types of languages a challenge. One such example of this is Javascript (aka JScript, aka JS, aka ECMAScript, aka ES, aka ECMA-262). As you may have guessed from the varied amount of names for Javascript, it is not at all related to Java. For me personally, I found Javascript’s syntax and structure far enough away from Java that learning the basics of it could open the door to Computer Science topics that would just not fit in Java. Two examples of these topics that I have encountered are callbacks and functional programming. While these may seem like topics specific to JavaScript, after learning about them I have been able to use that knowledge to create better logic in other languages.

All in all none of this is to say that I found Keystone APCS inadequate in any way. This class has laid a critical foundation that has allowed me to continue to learn advanced topics on my own. If you have the chance, definitely take APCS with Mr. Lindsay. While Python is a hugely important language in our economy, it is not the only one. C, C# and Swift (Linux, Windows, MacOS respectively) are all C based languages that are required if you want to go into app development. Python mostly stands alone in its syntax, while Java concepts are extensible to all C based languages. Regardless of the language that you code in, taking a real class is critical to the full understanding of complicated Computer Science topics.