Best Language for Beginner Programmers? 448
jahardman asks: "I work at a High School that has recently seen a decline in the number of students that want to take our entry level-programming course in Visual Basic. We have been toying with the idea of having the introduction course be in PHP or Ruby on Rails; but are not convinced that they lead well into higher level languages. Does anyone out there have suggestions as to what would be a better language to start students with? Ideally one that might be more 'enticing' as well?"
Re:My answer (Score:5, Interesting)
python! (Score:3, Interesting)
python is a good beginning (Score:5, Interesting)
You can start small by using the interpreter as a calculator, then move the caculations to a script and executing that. After a while you can gradually introduce variables, comments, functions and modules. After that, you could introduce the standard library and show how to print the contents of a file or download a web page. Or you could introduce the OO concepts of classes, encapsulation, polymorphism and inheritance. It's really up to you and how well your students are going.
Advanced students should also be able to create simple GUI or command line interfaces. Python has a great base class for command line programs that takes away most of the tedious parts. It also has some simple and easy database modules if you want to teach relational databases and SQL as well as programming.
But don't forget that the most important thing to do is to teach them how to teach themselves. Show how to look through the standard library for something new, or how to find and install new modules from the net.
When everyone has become comfortable with the language (and if you have the time) you can introduce a similar language for contrast. I've found that people who have experience with a wider variety of languages tend to be able to "grok" programs a bit easier than those who haven't.
Ruby or Scheme perhaps (Score:2, Interesting)
PHP or Ruby on Rails; but are not convinced that they lead well into higher level languages.
Uhm, PHP and Ruby shouldn't be mentioned together like that. Ruby *is* a higher level language compared to PHP.
But that's not really important to a *beginning* programmer. What you really want to do is first teach the basics, then immediatelly teach about "best practices", like keeping code simple and clean, writing *TESTS*.. unit testing should be taught AS SOON AS POSSIBLE in my opinion. Ruby makes it easy and doing it "test first" (write the test first, then write the code) makes it even easier.
If you want to them to understand the basics of functions and programs teach them Scheme. You can do some cool stuff with DrScheme. Then when they get to Ruby (or PHP) they will see how it's a "downgrade".
But yeah you'd probably be better off with a language that gives them room to grow like Ruby, rather than locking them in the little space that PHP offers.
Logo? (Score:3, Interesting)
I also remember learning Logo when I started at high school. That little turtle that pottered about on the floor was really cool, and it had all of the concepts that a programming language needs.... loops and conditionals! Having a real-world output from the program was a good way to inspire students to learn it - everyone really enjoyed it.
There are some gizmos now called the MicroMouse or somesuch. It's a little PIC powered rover that is similar to the Turtle. You program it up with a simple dialect of C, and download the code into the PIC. The development environment comes with all the libraries to make things like starting motors and reading switches easy from the C code. That might be a good way to teach the basics without boring students that otherwise don't see a use for it
Those that enjoyed it enough went on to study the more advanced stuff in later years of school.
Of course, my days in Logo were back when the BBC 8-bit micro was new and powerful.
Making a reasonable case for PHP (Score:2, Interesting)
When I learned programming, it was painful to get past the strange things I didn't understand in C, C++ and Java's "Hello World" program.
Header files, main(), etc. It was intimidating to me, and I am far from the most intimidated by new concepts person I can imaging.
The reason I like PHP for a programming teaching language:
Lots of people are saying, TEACH THEM C! IT'S GOOD FOR THE LITTLE BLIGHTERS!
But really, as someone who has taught a lot of programming informally, the biggest obstacle is people: a) seeing that programming is useful and b) seeing that programming is something THEY could actually DO.
At the beginning it's SO easy to feel like it's just a whirlwind of details you'll never be able to keep straight. If you can just teach selection (if...else) and iteration (foreach) and get it to stick that problems can be solved this way, yes, even by ordinary humans, then it's really not that hard to graduate people to Java or some such.
At that point you're just adding the concepts of namespaces, data typing, OO as a deeper part of the language....and the syntax and basic concepts are already there and familiar.
I hear people worried about generating bad habits, but I just don't think this is the primary concern when FIRST introducing people to programming.
Re:Noooooo! (Score:3, Interesting)
Frankly, I think Pascal or Python or Scheme or Modula or Eiffel or Smalltalk would be a much better choice for an introduction to programming, but I certainly don't see the point in switching to an obscure language that is vaguely derived from BASIC just because it still has the string "Basic" in its name, especially since you should be moving away from anything named "Basic" as rapidly as possible.
I'd probably recommend ADA before I recommended RealBasic, and I'm not a huge ADA fan. But it is (like RealBasic) a much better language than its reputation would suggest.
SEGA Genesis programming all the way. (Score:2, Interesting)
http://devster.retrodev.com/sega/basiegaxorz/
It's BASIC, but it compiles to work on SEGA Genesis emulators and, given the right tools, a real SEGA Genesis. Easy to do, but sure to give them a real spark of "wow, holy crap this is cool!"
Re:Python (Score:3, Interesting)
Feedback from students has been quite good. The biggest complaint now is when we switch to Java in the next course: "Why do we have to use Java? Everything so so much harder."
From my point of view, Python is well structured and has all of the language features I'd ever want while introducing programming (and arguably, all I'd ever want period). Students seem to pick up relatively good habits (of course, some will find ugly ways to do things no matter what the language encourages).
More importantly, students can spend more time thinking about their program, and less time fighting with the language. Python seems to do its thing and get out of the way. More "serious" languages tend to be more complex--that complexity adds more overhead for the students, which means more to learn before they can actually get much done.
For example, in Java you have to learn about classes, methods, references, and related stuff earlier in your journey. In Python, a lot of this can be ignored and introduced later. All the same concepts are there, but you can hold off and introduce them on your own terms, not because they're needed to write the next program.
If you are interested in teaching Python, I have some course materials I can share--both mine, and collections of other resources that I point students to.
What is the goal? (Score:3, Interesting)
Back in high school, when I was first learning to program, I wanted some level of instant gratification. This is the basis of languages like Logo, where a core set of commands give a visual representation. But we can get similar results today in other domains.
losman mentioned [slashdot.org] UnrealScript, which I generally like, but still has some drawbacks. First, is the cost of the handful of Unreal licenses and the hardware to run them. It also assume the developers are on Windows (at least until UT2007), which may not be true for students at home. But beyond such technical issues, are you going to handle the distractions/complications of the additional media assets? As a teacher, if you're up to the challenge, you can take advantage of this to drawn in more students and allow students to follow their own interests within the environment. Ideally, students can group around projects where they all contribute based on their interest. Lastly, can you handle the parents (or tax payers in a public school setting) who see violent video games as inherently evil.
Web apps can offer similar instant gratification. The pitfalls here include maintaining a server that allows server side scripts and teaching HTML (and probably basic browser compatibility) along the way. Again, you need to decide whether hooking into additional media is going to be an advantage or distraction in the classroom.
One problem both of these share is the difficulties in tracing the stack. Their unique run contexts can make it hard to debug problems, which can be as frustrating for your students as it is for you trying to help them as project dues date approach.
That said, it is possible to bring the engagement of a game to other development platforms. A small top down arcade game can teach several core concepts, from simple data structures (lists of actors, multi-dimensional arrays of terrain, variables like position and health, event handlers from input or actor collision). Build an outside level editor and you can teach GUI development, file I/O, and string manipulation.
If you go the GUI and graphical route of a game, Java seems like a good match. I believe it works well in classroom scenerios. At the basic level, the virtual achine it free and platform independent. Several good IDEs are available, and I believe there is work on an Eclipse plugin geared toward students. The APIs are stable, self-consistant, and well documented, although exceptionally broad and thus easy for a novice to get lost in without guidance. And if you target applets, students have a simple way to show off their work.
I'm sure C# has basically the same benefits, but I don't know enough to comment on it. Given an MS grant for a Visual Studio lab, I wouldn't rule it out.
Python is also an option, but I would choose wxWindows over tkinter anyday. Being a dynamically typed language, you loose the support of a context sensitive IDE, but you gain the easy access to a shell-like evaluation environment, useful for allowing students to interactively test thier code fragements (actually, integrating Beanshell into a java app is both easy and useful). I've never found a debugging environment for Python I liked, but at least they exist.
Several other scripting languages could be mentioned here, but again I am not familar enough to comment on them.
Other posts have mentioned C, C++, and assembly. While I think they are all critical for a complete CS education, I am not convinced they are ideal for a high school introduction course.
However, if the target audience is more advanced, I would put C on the table before the others, especially if taught in an object oriented way to mimic modern programming practice. This is a great way to show what that C++ compiler or that Java or C# VM are doing on the metal.
Anm
What a load of rubbish (Score:5, Interesting)
BASIC was grungy, useful, widely available, and offered a fast edit-run loop - key ingredients in getting a lot of kids hooked on computers.
What is the end goal? (Score:1, Interesting)
For example: If your school wants to 'produce' software engineers, get them on Lisp as soon as possible (using SICP as instruction book), and do not worry too much about dropout rate.
If your school wants to give its students a feeling for what programming entails, get them onto something to which they relate, for instance MS Word macros, or possibly MS Access (end year project: write something that produces a list of all MP3s/addresses in you address book on your PC that are not backed up on the PC of your friend)
Re:Noooooo! (Score:2, Interesting)
How about teaching these kids some assembly? Something nice like 68k assembly, you could get a load of old 68k based systems (my vote is for Atari ST's) and teach them simple things, like how to manipulate bitmaps on screen, which leads nicely into the writing of little games, and nothing motivates kids more than games. Assembly isnt that hard really, especially on a nice big endian CISC like the 68k, and it'll give them serious insight when they come to learn C ("ah-ha, so a for loop is just a dbra!").
Re:Noooooo! (Score:3, Interesting)
Noooo! Why would anyone teach students using Pascal instead C/C++. Does anyone think the BEGIN/END is really more straightforward than {/}? As students, they are going to have to *learn* things when they program, and curly-braces are the least of it.
Is 'record' and clearer than 'struct'?
If you don't want the students to have to deal with memory management, then use a garbage collection library with your C compiler. If you want to CYA, tell them that they are using a GC library. If you teach them Pascal, and don't explain that Pascal does GC, then they will be hosed when they get to a C/C++ course and don't understand why they have to manage memory.
Re:Java? (Score:4, Interesting)
I once was an adjunct professor at USF [usfca.edu] and introduced programming to MIS students. The first time that I taught that class, I presented a simple, console based balance checkbook example in Java. I watched as the class recoiled in horror at all those curly braces.
For the next class, I presented the same program only this time written in Python. That class was much more comfortable with the Python sample code than the previous class was with the Java sample code.
Integrate with other parts of the curriculum (Score:2, Interesting)
The rules for differentiation could be coded up in
the programming language. For Common Lisp it might
look like
(defparameter plus '+)
(defparameter times '*)
(defun differentiate (form variable)
(typecase form
(number 0)
(symbol (if (eql form variable) 1 0))
(list (case (first form)
(+ (list plus
(differentiate (second form) variable)
(differentiate (third form) variable)))
(* (list plus
(list times
(differentiate (second form) variable)
(third form))
(list times
(second form)
(differentiate (third form) variable))))))))
(differentiate '(* x x) 'x) => (+ (* 1 X) (* X 1))
But why are those the rules, rather than some other rules? Well it is supposed to agree with
the numerical version
(defun numerically (function argument difference)
(let ((left (funcall function (- argument difference)))
(right (funcall function (+ argument difference))))
(/ (- right left)
(* 2 difference))))
(defun square (x)(* x x))
(numerically (function square) 7 0.001) => 13.998031
And indeed
(defvar x 7)
(eval (differentiate '(* x x) 'x)) => 14
Notice the wider vision: students are taught a programming language to give them a language in which to talk about procedures, including procedures that they are expected to master in other parts of the curriculum.
Re:Java? (Score:2, Interesting)
Re:My answer (Score:3, Interesting)
Besides the obvious concerns of having to teach HTML at the same time, Ruby on Rails uses *way* too much magic for beginning programmers. There are all sorts of domain specific shortcuts that Rails uses. How are you supposed to teach iteration when the Rails uses something like collection_select [rubyonrails.com]?
Re:Python Isn't Elegant (Score:2, Interesting)
I base my opinion of Python on this...
When I look at a Python program, it seems pretty obvious what it does. There are very few special-case syntax elements. The program is clear and to the point. When I have examined Ruby programs, it was not nearly so immediately clear how they worked. There seem to be a number of special case syntaxes related to lists, strings and blocks of code used as arguments that render Ruby code much less readable.
Perhaps it is my ignorance of the language. Or maybe Python is closer to other languages I'm used to. But, I was able to pick up and understand a Python program when I was first learning Python much more quickly than I was able to pick up and understand a Ruby program.
That is why I hesitate to recommend Ruby as a beginner's language.
Developing Games in Java (Score:1, Interesting)
Re:Noooooo! (Score:2, Interesting)
I started (at about 10 years old) playing with QBasic examples from a kids programming book. I would type them in exactly, and then modify them.
When I was about 11, my father created a web page for me, and required me to maintain it myself. I made all changes by hand, through trial and error. No fancy GUI tools at that age!
Rant:
{
}
When I was a sophomore in HS (would've preferred starting programming as a freshman, but they made me take a computer application class as a pre-req), I learned the basics of MS's Visual Basic 6. I liked the quick results, which are essential if you want to get someone's interest long enough to actually teach them something. Most of the kids were there because the description in the course selection book basically said "Create cool programs by dragging icons onto a form". I actually helped teach this class. (By the way, it took six months of annoyed programming before I figured out that "End if" was a statement, not a condition. Nobody had bothered to explain it, they just told me I had to have it there because the compiler demanded it.)
My junior year, I learned the basics of C++. We spent almost the entire time making basic command line programs. This was good, because I actually had to learn structure and the importance of good code and documentation, rather than making a mess because I was in a hurry. I also was forced to learn the importance of planning, rather than the dive-in method.
Now, I am getting into PHP, which is relatively easy for me, because it is very similar to C++, and I already understand HTML. It also helps that there are lots of tutorials out there for it, and it is fun to play with.
My case was a little different than most kids these days, because my father is a programmer, and I had been exposed to computers all of my life, and had been required to fix my own problems, with guidance from him only when I really needed it. My oldest brother was formatting floppies from the DOS command line at 5. We had all built at least one computer and did all setup (format the hard drive, figure out why DOS refused to install, etc.) on it by the age of 10.