August 1, 2009

Computer Science: Which Language To Teach?

Arguing about which language to teach is a favorite pastime of computer science teachers. This is one of those religious wars that will never go away, like Mac/Windows. It should be a language that:
  • Teaches fundamental object oriented programming concepts
  • Teaches functional programming concepts
  • Teaches algorithms and data structures
    Allows students to get results fairly quickly (with a relatively shallow learning curve)
  • Is widely used in industry
  • Allows students to create graphical user interfaces fairly quickly


This has been extensively discussed elsewhere on the web, and experts have offered varying opinions:

C/C++

Many modern languages derive their syntax from C, so learning C first makes it easy to learn other languages later. C supports pointers, recursion, and data structures, and introduces students to memory management. Higher level languages abstract away these concepts, but it's still important that students understand them. C++ is fully object oriented. Both are still widely used. The main benefit of using these languages is that they introduce students to core computer science topics.

On the con side, they have a steep learning curve and a cumbersome syntax. They are low level languages, which means that it take much more effort to create a working solution, such as a full featured GUI app.

Java

Java is fully object oriented and is a great language to choose if your goal is to teach OOP. It has some vocal critics who argue that students miss out on learning functional programming. It's platform independent and used all over the place. This is the language used in the AP Computer Science curriculum. I think it's a great place to start. Its major weakness is that creating GUI applications is very difficult in Java.

Another great thing about Java is that it is free and open source. There are many free editors and IDEs available as well.

C# .NET

Microsoft Visual Studio makes it easy for developers to create event-driven GUI applications. The language C# is very similar to Java. It's very widely used in the commercial sector. This would probably be my first choice, because it includes all of the benefits of Java with an easy to use GUI creator. The major downside is that Microsoft charges big licensing fees to use it. Some teachers don't like the fact that Visual Studio almost makes coding too easy, the way it automatically corrects errors as you type and gives you syntax hints along the way.

There are ways to code C# for free with the SharpEdit tool and Mono, but they're more cumbersome that Visual Studio

Visual Basic .NET

VB uses the same development environment as C# but has a different syntax which some say is easier for beginners to understand. However, learning Visual Basic first will make it more difficult for students to transition to languages with a syntax derived from C later.

PHP

PHP has many critics too, but I think it's a good choice, especially since version 5, which is fully object oriented. There are several reasons I don't use it in my classes:
  • It requires a deep knowledge of XHTML, which my students don't have.
  • The only types of programs it allows you to make are web apps (unless you also learn GTK)
  • Debugging is difficult
  • A semester course would give students just enough knowledge to create web apps but not enough knowledge to make SECURE web apps. I don't want students to hang themselves.

Python

I don't know much about Python other than the fact that it is becoming increasingly popular in high schools and universities.

Others: Ruby, Scheme, Haskell, Delphi/Pascal, Assembler, LISP

These languages have some great strengths but are missing a few bullet points on what I consider to be essential characteristics of a first programming language. They are either difficult to use, not used in industry, or have very limited scopes.

Conclusions

For now, Java is a great choice, but it will undoubtedly be displaced by something else in the future. C# has a lot of strengths, but it's expensive.

No comments: