Good Language Choice For School Programming Test?
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?"
PHP for anything other than web stuff is a bad idea simply because PHP is just a horrendously bad language, it's truly awful. The only reason you'd use it on the web is because it's so well supported in terms of libraries and so forth, and generally available on cheap hosting options.
It doesn't have these advantages outside the web- the libraries aren't as common or well tested, and it's less available on say, desktop PCs than Java, .NET or native binary support is. Examples of problems with it are it's terrible hacked on OOP support, lack of proper namespaces, clunky syntax. Why would you put yourself through that when you can just use C, C++, Java, or one of the .NET languages? It's best to just leave PHP where it belongs.
C/C++ may be more than a little faster than Python certainly, but they're barely faster if at all than Java/JVM or C++,C#,VB,etc./CLR. See this site, which is now 6 years old (things have moved on even more since then) to better understand why C/C++ do not have much of an advantage in performance anymore, and have no advantage whatsoever when you factor in ease of development against performance:
http://www.idiom.com/~zilla/Computer/javaCbenchmark.html
The idea that things that require high performance are written in C/C++ is a little bit of a straw man. Games are written in C++ because it's the only langauge that's portable across the Wii, the PS3, the Xbox 360, the PC, Mac, Linux and because it's what companies have been using for decades and as such have millions of lines of libraries written for and have developer teams skilled up in. It's certainly not about performance nowadays, head to java.com and look up their case studies list for high performance computing for example. The fundamental problem is that when you compile C/C++ code you're generally compiling for a generic chipset so that's the best that the compiler can optimise for, with VM based languages like Java and the .NET languages, they use JIT compilation so that the bytecode is compiled into natively executable code and optimised for the specific abilities of the system on which it is being run- this gives it an inherent advantage in terms of optimisation because it does not have that disadvantage of needing to be generic enough to run on any compatible system like compiled C/C++ generally does. You could get the same benefits with C/C++ and allow it to keep it's slight edge by distributing an executable optimised for each type of AMD processors with 1gb, 2gb, 3gb, 4gb RAM and so on and then the same for Intel and other factors, but you get a combinatorial explosion of the amount of executables you'd need to distribute and the user would probably struggle to know which one to use.