Good Language Choice For School Programming Test? 407
An anonymous reader writes "The Australian Informatics Olympiad programming test is being run in a couple of months. I'm an experienced programmer and I'm thinking of volunteering to tutor interested kids at my children's school to get them ready. There will be children of all levels in the group, from those that can't write 'hello world' in any language, to somewhat experienced programmers. For those starting from scratch, I'm wondering what language to teach them to code in. Accepted languages are C, C++, Pascal, Java, PHP, Python and Visual Basic. I'm leaning towards Python, because it is a powerful language with a simple syntax. However, the test has a run-time CPU seconds limit, so using an interpreted language like Python could put the students at a disadvantage compared to using C. Is it better to teach them something in 2 months that they're likely to be able to code in but possibly run foul of the CPU time limit, or struggle to teach them to code in a more complicated syntax like C/C++ which would however give them the best chance of having a fast solution?"
English, but seriously (Score:2, Interesting)
English, Vulcan, or whatever the local human language is. Or just give everyone a translation device.
Oh, you mean the language for the programs. My bad, I thought you meant for the instructions and problem description, sorry.
But seriously....
Your first line is to see what eligible language the students mostly know already or what is taught in that school or school system and go with it.
Barring that, go with whatever is commonly used in most university college freshman programming classes. It may not give them the best chance to win but learning it will have practical value.
If you know the types of problems they will give, everything else being equal go with the language that is best suited for the problem type.
Language shouldn't push you past the limit (Score:5, Interesting)
If one of our entries was rejected due to exceeding the CPU limit, it was always due to a problem in our logic that the sample data hadn't triggered, but that the actual test data had.
Re:There's C then there's C written by newbies (Score:3, Interesting)
In a programming contest memory leaks and such are meaningless. In fact, algorithmic complexity is also nearly meaningless. O(n^3) solutions that you can code in 5 minutes win over the O(n lg n) solution that takes an hour to code up.
Pascal (Score:2, Interesting)
I would go with Pascal. And if not, Java.
Pascal has a is very simple and clear syntax and semantics. It has strong and static typing, making many errors very easy to catch at compile time. The case for Java is similar but the syntax and semantics are a bit more complicated.
C is terrible to teach, they'll have to deal with pointers all the time. Reading something from input? Pointers. Passing by reference? Pointers. Strings? Pointers. Sure you may omit that those are pointers but the segmentation faults will show up for regular reality checks. Same for C++. Python means working with dynamic typing. PHP dynamic and weak typing. Don't get me started on Visual Basic.
Ask them (Score:3, Interesting)
Re:I'm guessing the CPU limits are generous. (Score:3, Interesting)
Probably Java (Bleh) (Score:2, Interesting)
However... It's nigh on useless these days to have "Pascal" on your CV (I'm sure both the Pascal developers out there will disagree - Yes I'm looking at you Delphi devs...)
I did C, Pascal and COBOL at UNI and since then I have spent some 15 years writing VB (3->.Net), C, C++, C# etc. In the last 2 years I have been working mostly with Java. And I hate it. It's slow, memory hungry, it's tools are Sh*t (Matisse's creators are on drugs).
That being said, pick up your local paper (or go to Seek - also bleh) and look at the proportion of jobs advertised these days that require Java. It's quite significant. That's the sort of thing that you should be looking at when making your decision. Sure, you'll find a few that require any of your listed languages. And sure, when these kids have finished UNI and want to work in IT (poor bastards) Java will be dead and buried, but there'll be a million and one "Legacy" systems lying around that use Java.
Oh and teach them some database skills. The local UNI here puts out graduates that don't know anything but Cross joins and have no idea what a left join is...
Boy you're going to get lots of replies (Score:2, Interesting)
I read over quite a few already and find it funny people are saying things like python are the easiest of the bunch to learn. Command line easiest? really?
As much as I don't like MS, their VB is by far the easiest of the bunch to learn. And you won't have any speed issues at all to deal with, it executes extremely fast. It's an event-driven language also which makes it easier to compartmentalize things and avoid confusion for new users. Debugging in C can be a nightmare. VB does a great deal to force proper coding, it's hard to write something that compiles that doesn't run anything like it should, and with breakpoints and stepping, a higher level language like vb is very easy to debug. Strong typing is another plus.
Beware of people replying back with what's easiest for them. You're going to get a lot of that.
Re:Faster than you think (Score:3, Interesting)
As the summary says "Accepted languages" (presumably the competition rules), I would tend to agree. They're not going to ask your students to complete something that those languages cannot reasonably accomplish. Bad C++ code will be slower than halfway-decent Python code. Teach a good foundation, and let the chips fall where they may.
Agreed. I've done a couple of these programming competitions in my youth (heh :P ) and in my experience, the runtime limit is in place to force you to use a more efficient algorithm, not to force you to streamline your brute force approach. So there might be a problem that would take an hour to solve using brute force, or a couple of seconds using dynamic programming, for instance - choice of language isn't going to affect the performance appreciably compared to choice of algorithm.
For what it's worth, I too say Python. It's easy to learn, flexible, and executes fast enough.
Why no functional languages? (Score:2, Interesting)
The syntax viewpoint is an oversimplification. (Score:3, Interesting)
The difference between C++ and Python isn't simply that C++ has a more complicated syntax.
In C++, the kids will have to wrestle with the static type system and the lack of automated memory management. (Problems that can be partially overcome with a lot of "greenspunning" that requires significant C++ experience).
The number one factor in performance is the choice of algorithms. A Python program with good algorithms will beat a C++ program which uses poor algorithms, or which does stupid things like copy aggregate objects in order to avoid memory management difficulties.
It's sad that the list of languages includes only immature dynamic languages du jour like Python and excludes mature dynamic languages that have good compilers. Bad education!
It's just me (Score:4, Interesting)
or teaching a language to non programmers children and sending them to Informatics Olympiad after two months is pretending too much?
In addition to the language, you must first teach them very basic concepts like variables, loops, recursion...
As soon as they start to digest them and write their first "Hello World"... BANG! You send them to Informatics Olympiad!
The two months' learning time is the real limit. (Score:2, Interesting)
Consequently, Python will probably be a good deal *faster* than C, because its low-level stuff has already been optimized by people who know how.
If you use C, can you imagine getting new programming students, within two months, to the point where they are implementing hash-based associative arrays and a fast stable sort routine? I can't. In two months, working in C, you'll be lucky if they can remember how to copy a string.
No Perl? You've got to be f**ken kidding (Score:2, Interesting)
Do they realise how much of the world's systems run Perl? And given that it's pretty much built into every major OS (yes, Windows needs a download). Wow, this is mind-boggling. I still can't get over it. And the fact that simple Perl is just that - so simple. Hello World is a one liner. No classes to define, no libraries to import, no header files to include.
And you can write poetry with it! (bonus points?)
Avoid "object oriented" languages (Score:3, Interesting)
There is an incredible performance penalty for most object oriented code written by beginners: they aren't taught to avoid the layers of abstraction that eat away at your performance, and they often hide incredible errors behind layers of abstraction that make debugging a nightmare.
Python seems a good compromise: as a scripted language, it's quite portable. It has good text processing, there's a large base of small examples to teach students with, and it doesn't suffer from that horrid mass of badly written, interdependendent, unstable and unnecessary utilities known as CPAN that clutters a lot of Perl programming.
Slower yes, yet fast enough. (Score:3, Interesting)
However, the test has a run-time CPU seconds limit, so using an interpreted language like Python could put the students at a disadvantage compared to using C.
In my experience time limits are there to prevent students using primitive algorithms (the ones with exponential asymptotic performance).
N.B. I would have recommended Perl instead - but I'd refrain :)
Python should be and is in fact fast enough for most tasks. Taking algorithms into account, C gives only marginal advantage: bubble sort would suck even if you'd write it in assembler.
P.S. If that is still concern, one can allow interpreted languages to have e.g. twice more time compared to compiled languages.