Follow Slashdot blog updates by subscribing to our blog RSS feed


Forgot your password?
DEAL: For $25 - Add A Second Phone Number To Your Smartphone for life! Use promo code SLASHDOT25. Also, Slashdot's Facebook page has a chat bot now. Message it for stories and more. Check out the new SourceForge HTML5 Internet speed test! ×
Australia Education Programming

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?"
This discussion has been archived. No new comments can be posted.

Good Language Choice For School Programming Test?

Comments Filter:
  • by Anonymous Coward on Sunday March 14, 2010 @09:04PM (#31476654)

    Python is faster than you think.

  • by squidgit ( 734454 ) on Sunday March 14, 2010 @09:07PM (#31476682)
    OK C could be a computationally fast solution, but I'd go for Python anyway. Why? Mainly this: How many new C programmers (i.e. less than 1 or 2 years experience) can write programs without obscure memory leak/access problems? How much time have slashdotters wasted looking for elusive segfaults in C code? I know I've wasted hours, days, chasing buffer overruns in school assignments. Or worse are the ones you don't see; they only trigger on the examiner's machine..
  • Psyco (Score:4, Informative)

    by headkase ( 533448 ) on Sunday March 14, 2010 @09:08PM (#31476696)
    For Python, can they use: Psyco [] as a library? That would help being practically a Just In Time compiler. It's x86 architectures only but that should be what they're running. As a side point I find it irritating that a language that is designed to be friendly and powerful is disadvantaged by counting CPU cycles: especially since in the real world those are plentiful compared to the scarce resources available for the hard work of debugging. And in Python if the CPU is your constraint - which it isn't in most programs - then you write that little bit of CPU code in C or C++ and call that one part from Python. This keeps the rest of the program easy to debug and portable.
  • by betterunixthanunix ( 980855 ) on Sunday March 14, 2010 @09:19PM (#31476804)
    That is not universally true, at least not in the college level contests I participated in as an undergrad. They used to test with very large inputs, to deliberately throw off solutions that leaked memory (they set a ulimit before running the code) or inefficient solutions (except in cases where they gave us NP complete problems)...
  • by WrongSizeGlass ( 838941 ) on Sunday March 14, 2010 @09:20PM (#31476816)
    I think you should pick something that would be the easiest for them to learn. Python is probably the best choice out of those languages (I'm not a Python programer and my exposure to Python has been limited - though I do code in C/C++, PHP & VB and I've coded and taught Java & PASCAL).

    You can't really worry about the runtime limit since it should be rather liberal for a student's competition and you'll never know what the system's config will be (so Python may be fast or slow).

    If you're going to be teaching new programmers, get them started on something they can use and something they can expand upon. Of the languages available to you I would say Python is the best choice.
  • by collywally ( 1223456 ) on Sunday March 14, 2010 @09:41PM (#31477012)

    I tried teaching my self some Python a while back and found it very easy. The only experience that I had before in any computer language is MEL (Maya Embedded Language). I bought a book called Game Programming (Publiser: Wiley, ISBN 978-0-470-06822-9) and over my two week Christmas break I was able to build a nice little top down shooter with programmer graphics.

    It uses the pyGame library for most of the heavy hitting (like writing to the screen and the like) but it also introduced me to Objects and Classes as well as how to think in small steps to help break down what I was trying to do.

    I always suggest this book to artists that I meet who wants to get into scripting. And most of them who have borrowed it end up buying it for themselves when thay have to give back my book.

  • by Nursie ( 632944 ) on Sunday March 14, 2010 @10:02PM (#31477188)

    For relatively simple programs (like a school programming test or competition entry), you can compile the C in under a second. Pascal has almost no commercial use these days and is not going to be a good thing to teach them from a skills perspective.

    That said - python would be a good choice, IMHO

  • by rwa2 ( 4391 ) * on Sunday March 14, 2010 @10:26PM (#31477384) Homepage Journal

    In college I wasted SO much time debugging C/C++ code memory errors. Python was such a breath of fresh air. I could think of something with a mildly complex structure, implement it, and have it work pretty much on the first go.

    I've spent days, DAYS debugging weird stack memory limitations in C++, where it would work right on a small data sample, but completely fail on a slightly larger set.

    I used psyco on my Master's thesis to greatly speed up my python simulation (10-100x with a simple import statement). Unfortunately it only works on 32-bit ix86. Supposedly other projects like pypy are supposed to reintroduce that kind of optimization to modern python, but I finished my thesis :P It's easy enough to link to C/C++ code for parts that really have to run fast though.

    So yeah, start them off with python. And maybe teach the advanced students how to link to C/C++ modules for performance-critical functions.

  • by cibyr ( 898667 ) on Sunday March 14, 2010 @11:35PM (#31477798) Journal

    Oh come on, Python was designed as a teaching language and in my experience students find it much easier to learn than Pascal (and it's much less limiting once you get past the basics).

    As far as speed is concerned, according to the Programming Language Game [] Pascal is at best 60x faster than Python, and these sorts of competitions usually give you a few orders of magnitude in margin - the idea is to make sure your solution is in the right complexity class, not to try and enforce the most efficient possible solution.

  • by Glonoinha ( 587375 ) on Monday March 15, 2010 @01:43AM (#31478454) Journal

    I took a few minutes to RTFA and the software equivalent of scholastic olympics today are pretty much the same as they were in 1984 when my team took second place at the state level. It is a medium low level software engineering test demonstrated via a few medium low level implementations.

    They are looking for two things:
    Can you read the requirements and come up with an appropriate algorithm?
    Can you implement the algorithm in their favorite language (pretty much any language in common use)?

    The CPU time limit is to keep people from using bogo-sort (ie, randomize the data and then check if it is sorted, repeat until it's actually sorted.) If the students understand how to break a problem down and implement it using a standard approach, they will beat the CPU time limit. Even if they use bubble sort.

    The real thing they are up against is the design and implementation time limit - I'm guessing they have three or four problems and four hours per team. The libraries they are allowed to use are basically nonexistent, meaning they software they are expected to write is going to be a software implementation of some algorithm, and they aren't going to be able to Google for syntax assistance so they need to be fluent in their language. They will have access to hardcopy manuals and manuals in electronic format, but that will just slow them down.

    Given the limit on imported packages and code complexity (not to mention source code size - no more than 40,000 characters (which is ultra-overkill - it would take a week to hand write 40k worth of source code for an application that actually needs 40k worth of source code)) compile time will be negligible. A few seconds tops. Don't worry about compile times for this competition, worry about the time to actually come up with the algorithm and then to implement it in the correct syntax.

    They aren't doing any serious object oriented coding because everything is in one class, and because they're allowing Borland's Pascal (well technically Delphi but they are using is as a super powerful Turbo Pascal. This means implementing simple algorithms.

    If you want your kids to succeed in this arena, here's the best toolset to train them. Two piece of paper, a pencil, and a few crayons. Verbally describe a simple problem for them. Explain it only once. As you are explaining it to them, have them take notes on one piece of paper and capture the requirements. On the second piece of paper, using the crayons diagram their solution. A sort can be diagrammed by drawing boxes and arrows showing how things move around. String manipulation or array manipulation can be diagrammed by drawing a word with numbers below it and arrows above it showing how the elements are moved around. Teach them to understand the problem, come up with a practical approach, and then code it in the basic syntax in any language.

    Because I expect the problems to have solutions that would be simpler if the language has iterators, and since they are disallowing pretty much all of the good Java external packages to do those things - I'm going to suggest a language with simple pointers - either Pascal or C/C++. Rearranging arrays (of characters, structures, or whatever) is trivial in either of those languages, and rearranging or iterating over an array is the perfect example of algorithm design and implementation typical of this type of challenge.

  • Teach them C++ (Score:3, Informative)

    by AlgorithMan ( 937244 ) on Monday March 15, 2010 @05:13AM (#31479408) Homepage
    teach them C++, because
    • Most software (iirc 80% or so) today is written in C or C++
    • C++ is the mandatory language for nearly all well paid programming jobs
    • C++ makes it easy to learn Java (but not vice versa), which is also popular with employers
    • C is C++ for masochists. C++ has everything C has, but not vice versa
    • forget turbo pascal! that's an educational language, which is hardly used in the real world (esp. because of the lack of object orientation)
    • google dijkstras comment on BASIC
    • Python is OK, but not so widely used AND it's an interpreter language (automatic deduction of points)
    • I wouldn't use PHP, since it makes it hard to execute (you need to run a webserver with PHP support and browse to it) and PHP will be dead as soon as the http & html+js+css+flash+AJAX+... mess is cleaned up...
  • Re:Teach them C++ (Score:4, Informative)

    by dunkelfalke ( 91624 ) on Monday March 15, 2010 @08:24AM (#31480510)

    forget turbo pascal! that's an educational language, which is hardly used in the real world (esp. because of the lack of object orientation)

    How does it feel living at least 22 years behind the rest of the world? I am asking because Turbo Pascal supports OOP for that long.

  • by Unequivocal ( 155957 ) on Monday March 15, 2010 @02:39PM (#31485344)

    Just curious - what other language besides Python is dynamically typed with significant whitespace? I've only run across Python in this category.. Thanks!

"The eleventh commandment was `Thou Shalt Compute' or `Thou Shalt Not Compute' -- I forget which." -- Epigrams in Programming, ACM SIGPLAN Sept. 1982