Slashdot Mirror


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?"

67 of 407 comments (clear)

  1. Many good choices by DoofusOfDeath · · Score: 4, Funny

    You don't want a test that favors kids who have studied that particular language in the past. I suggest the Turing-complete language LaTeX. It's the only way to be sure.

  2. There's C then there's C written by newbies by squidgit · · Score: 2, Informative

    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..

    1. Re:There's C then there's C written by newbies by mdf356 · · Score: 2, 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.

      --
      Terrorist, bomb, al Qaeda, nuclear, yellowcake, kill, assassinate. Carnivore is dead... long live Echelon.
    2. Re:There's C then there's C written by newbies by betterunixthanunix · · Score: 4, Informative

      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)...

      --
      Palm trees and 8
    3. Re:There's C then there's C written by newbies by oldhack · · Score: 3, Funny

      Actually, I take this back.

      Go with C++. If not, in 20 years, some of these kids will come after you for ruining their lives by seducing them into the nasty painful world of programmers. It's a nasty way of life. Scare them shitless off it - teach them Perl and make them debug each other's code. Tell them all the grownups use Perl.

      --
      Fuck systemd. Fuck Redhat. Fuck Soylent, too. Wait, scratch the last one.
  3. English, but seriously by davidwr · · 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.

    --
    Knowledge is how to play a game, intelligence is how to win, wisdom is knowing what game to play.
  4. I'm guessing the CPU limits are generous. by Jason+Pollock · · Score: 5, Insightful

    I'm guessing that the CPU limits are generous and are more about filtering out bad algorithms than bad languages.

    For example, someone using stooge sort instead of quicksort...

    While the language used would increase the budget, the algorithms used will very quickly swamp any language gains.

    When I did programming contests, they were more bound on thought (how quickly you can come up with an algorithm) and then implementation time. Rarely did compute time come into it.

    1. Re:I'm guessing the CPU limits are generous. by Anonymous Coward · · Score: 2, Insightful

      I agree. Some problems in programming competitions could be solved with a simple exhaustive algorithm. The main point of the CPU time limit is to make people use better and more creative algorithms, i.e. if you solve it correctly CPU time shouldn't be an issue in any language.

    2. Re:I'm guessing the CPU limits are generous. by bill_mcgonigle · · Score: 4, Funny

      Right, the OP says that Python is an accepted language, so it's only sensible to assume that this isn't a sneaky trap set by the Ruby Mafia intending to disqualify testers for using it.

      The Navy research showed Python is a good language for learning OOP and if programming contests today are anything like what they were when I was in ACSL, boy would having a scripting language be handy. I wonder how anybody could compete in c (but perhaps that's a built-in test - picking the right language for the job is an important skill).

      --
      My God, it's Full of Source!
      OUTSIDE_IP=$(dig +short my.ip @outsideip.net)
    3. Re:I'm guessing the CPU limits are generous. by zach_the_lizard · · Score: 2, Interesting

      Some algorithms are better suited for some languages or paradigms than others. Quicksort, for example, relies on mutability to be efficient. A language like Haskell, where the list to be sorted would be recreated a bunch of times, would not be well suited. Even with the same algorithm, it would run slower. Sometimes the language dictates the algorithm that would be best to use, or what data structures make sense. That said, I think I would have to recommend, of the languages listed, Python because of its general reputation for being easy to learn. Plus, it has decent support for several paradigms. Want to be OO? Cool. Want to functional? We can do that too. It opens the mind to more ways of thinking about a problem than more single paradigm languages, and that can be very useful in this sort of contest.

      --
      SSC
  5. Psyco by headkase · · Score: 3, Informative

    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.

    --
    Shh.
    1. Re:Psyco by dougmc · · Score: 2, Insightful
      Of course, that's for perl 6 -- which hasn't been released, and it's hard to tell when or if it'll ever be released.

      Personally, I think a lot of the perl hate comes from the perl users getting stuff solved fast and (often) ugly, when the perl haters spend far more time creating their (often) far prettier solutions. If the programs need to be written quickly, I'd say perl would be the language to use (except that it's not permitted, of course.) If the programs need to execute quickly, C -- but it'll take longer to write them. In most cases (real world and contests!), time to write the program is more important than execution time -- though I'm not familiar with this contest.

  6. Language shouldn't push you past the limit by EEBaum · · Score: 5, Interesting

    Having competed in a handful of collegiate programming contests about 10 years ago, the CPU time limit was never even a passing concern. Granted, we were coding in C++, but even in Python, any solution that hits the CPU limit on these contests is quite likely an unnecessarily complex algorithm. I always considered the CPU limit to be a safeguard against programs with infinite loops or REALLY slow solutions, so that the teams wouldn't claim "no, really, it works!" and drag the contest on for hours insisting that the right answer will reveal itself shortly. If your solution works, but has complexity of O(n!), I'd have a hard time calling it acceptable.

    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.

    --
    -- I prefer the term "karma escort."
    1. Re:Language shouldn't push you past the limit by Zillidot · · Score: 2, Insightful

      I have competed in both the informatics olympiads and the ACM collegiate programming contests, and in my experience there was a much greater emphasis on algorithms in the informatics olympiad. Whether your algorithm was O(n^3) or O(n^4) did make a difference to the results.

      That said, the choice of programming language only adds a constant factor to the runtime, so your point still stands.

    2. Re:Language shouldn't push you past the limit by verdante · · Score: 2, Insightful

      Having competed in a handful of collegiate programming contests about 10 years ago, the CPU time limit was never even a passing concern. Granted, we were coding in C++, but even in Python, any solution that hits the CPU limit on these contests is quite likely an unnecessarily complex algorithm.

      Python makes for much faster coding and debugging and works on many problems. But there's a whole range of contest problems bomb out in Python:

      1) Large inputs or outputs and short time limits. Python's "print" statement is simply not fast enough for large-output problems.

      2) Billions of booleans. In C++ you would use bitboards and bitarrays, maybe a 100MB worth. Using native Python data structures the memory can run into gigabytes. Using numpy, the bit-twiddling will still be many times slower.

      3) Some problems with tight loops and a time limit is set at a couple times the speed of the author's C or Java solution. Python being 10x slower on such loops takes it over the time limit.

  7. Pascal by jadrian · · 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.

  8. Go With Your Gut by Bob(TM) · · Score: 5, Insightful

    Unless these kids already have a programming proficiency, go with your gut.

    The exercise is as much about allowing them to test the programming waters as it is about them winning. If you are starting with a blank slate, that means you need to create an environment that is intriguing. If YOU think Python is the thing, you'll be passionate ... and that is a lot of what makes a good coach/tutor in an olympiad.

    Further, I think you could do a lot worse than Python. It is really a great language and is popping up in a lot of disciplines as the scripting tool of choice. It will perform well and has great characteristics that make it well suited for someone learning the ropes. Plus, the language is modern enough to be relevant should they desire to pursue IT further.

    I would stay away from C/C++. In the hands of novices in a timed activity, I would wager it would be more trouble than it's worth.

    --

    The little guy just ain't getting it, is he?
  9. Re:Faster than you think by WrongSizeGlass · · Score: 4, Informative

    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.

  10. If Python is an allowed choice then... by Frequency+Domain · · Score: 3, Insightful

    Any CPU limits should be generous enough to accommodate correct solutions in any of the permissible languages.

  11. Re:Too easy... can't resist... by WrongSizeGlass · · Score: 4, Funny

    It's the whole "4 out of 5 doctors ..." scenario. Any kid who picks Java will be taken away to be deprogrammed and then reintroduced to programming society once they're ready to be released into the wild.

    Born free, free as the wind blows ...

  12. Python will give you th least problems by gweihir · · Score: 4, Insightful

    C, C++ and Java are not an option. They all need years to master and have numerous non-obvious pitfalls. Pascal is pretty limitad and definitly a historic design. PHP is obscure in palaces. Visual Basic still is a bad joke, confined to just one platform and wioth numerous design problems.

    On the other hand Python is fine, with the only thing to master the indention. Not on the list, but Ruby would also be nice. And for a minimalistic, yet powerful language, loot at (again not on the list) Lua.

    --
    Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
    1. Re:Python will give you th least problems by Samah · · Score: 2, Insightful

      And for a minimalistic, yet powerful language, loot at (again not on the list) Lua.

      You beat me to it. Lua is ridiculously easy to pick up and will give the students a chance to worry about actual algorithms and lateral thinking rather than jumping straight into OOP. For the uninitiated: Lua does not natively support a polymorphic OO environment but it is very easily implemented with metatables.

      Disclaimer: I'm a Lua fanboy. :)

      --
      Homonyms are fun!
      You're driving your car, but they're riding their bikes there.
    2. Re:Python will give you th least problems by dunkelfalke · · Score: 3, Insightful

      Pray tell me how a modern Pascal dialect (as used by Free Pascal Compiler for example) is "limitad".

      --
      "It's such a fine line between stupid and clever" -- David St. Hubbins, Spinal Tap
    3. Re:Python will give you th least problems by gweihir · · Score: 2, Insightful

      Well, scripting is not about execution speed, but development speed. You are of course right on the developer angle. Language, process, design method, etc. cannot cause incompetent developers to create good software. That is just the vision by incompetent management (of which there is a lot), because they would like to treat developers as exchangeable components, not individuals that are, on to bottom line, possible worth a lot more than they are.

      However, language can stand in your way, making development more complicated. For compentent, experienced developers, this will just increse development time and increase the number of bugs. For inexperienced developers, it can be catastrophic.

      --
      Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
    4. Re:Python will give you th least problems by obarel · · Score: 2, Insightful

      I'm also a Lua fanboy, but for motivation and inspiration I'd use Python and not Lua.

      Just think about this problem: how do you get a directory listing in Lua?

      Lua doesn't have an immense standard libraries. Even though it's extremely powerful, the power is in the flexibility, not in the environment. Of course, there are many many libraries that you can pretty much download and use (depending on OS, of course), but it still doesn't come "batteries included" like Python.

      Also, Lua is very simple to learn, but even then you have to know a bit before you can have some fun. Compare:
      Lua: for _,v in ipairs(list)
      Python: for x in list

      Even for basic loops you have to call a function.

      Compare:
      Lua: print(string.format("Your age is %d", age))
      Python: print("Your age is %d" % age)

      Even for basic output you have to call a function.

      Lua is fantastic, I've used it in many projects - at work and at home. But in my opinion Python is better for "get something working quickly" (i.e. the modern, much much better, equivalent of BASIC as a first language). As my "scratchpad" / calculator / quick eval-print-loop I always use Python.

  13. Ask them by igotmybfg · · Score: 2, Interesting

    Explain the situation to your students; give them the options available with pros and cons for each; and let them decide for themselves.

  14. Re:No option of Fortran? by Stephen+Tennant · · Score: 2, Funny

    But then he must add a module for maintaining neckbeard

    --
    I spend most of my time in bed, darling.
  15. Python would be my choice by collywally · · Score: 2, Informative

    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.

  16. Probably Java (Bleh) by pookemon · · Score: 2, Interesting

    When I first read the list I thought "Pascal". The reasons are that it's a structured language, it is very easy to use and it's able to teach extremely useful concepts like linked lists, recursive algo's etc.

    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...

    --
    dnuof eruc rof aixelsid
  17. No Perl ? by Anonymous Coward · · Score: 2, Insightful

    Probably because there would already by a module that solves the problem.

  18. Re:Strange limitation by godrik · · Score: 3, Insightful

    The contest has a cpu time limit which seems to be reasonnable for a programming contest.

  19. How about the simplest of languages?... by javabandit · · Score: 2

    Brainfuck.

  20. Re:Faster than you think by gd2shoe · · Score: 4, Insightful

    You can't really worry about the runtime limit since it should be rather liberal for a student's competition...

    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.

    (And I too vote Python, by the way.)

    --
    I won't join Slashcott. OTOH, If Beta goes live, I just won't be back until it's fixed. Sorry Dice.
  21. Perl !! by QX-Mat · · Score: 3, Insightful

    Perl is very simple to learn (check out "Robert's Perl Tutorial"). Perl allows the programmer to do what he wants - regardless of the style. There's even English.pm. Perl has many upsides ie: it's a powerful parser and indispensable toolkit... and highly embeddable. If there was ever a seed language to learn, it's Perl.

    There's also the fact that Perl programmers are real unix men - and let's face it, you'd rather have real unix graduates than Ruby fannies?

    1. Re:Perl !! by LodCrappo · · Score: 3, Insightful

      I'm a big fan of Perl myself but I wouldn't recommend it for new programmers. The phrase "enough rope to hang yourself" doesn't begin to describe it. It's also probably a bad choice in this scenario because it isn't on the list of accepted languages, although if you were decently skilled I'm sure you could write one liner to translate your perl source into any one of the accepted list.

      --
      -Lod
    2. Re:Perl !! by palegray.net · · Score: 2, Funny

      although if you were decently skilled I'm sure you could write one liner to translate your perl source into any one of the accepted list

      Not necessary, just do this:

      #!/usr/bin/python
      import os
      lulz = os.system('perl myprogram.pl')


      Look, it's in Python! :)

  22. Hello World by gd2shoe · · Score: 4, Funny

    On the plus side, you could make a really spiffy "Hello World".

    --
    I won't join Slashcott. OTOH, If Beta goes live, I just won't be back until it's fixed. Sorry Dice.
  23. Python or Java by M.+Baranczak · · Score: 3, Insightful

    I assume you want something that'll give the kids an advantage in the competition, and be useful if they want to start programming seriously.

    Pascal - it was nice back when Reagan was in the White House and Michael Jackson still had his nose, but it's obsolete.

    PHP is for writing dynamic web pages. It's good at what it does, but it isn't really a general-purpose language.

    C and C++ are faster than interpreted languages. That is, sometimes they're slightly faster. And they're almost always harder to write in.

    VB? Go fuck yourself.

    So that leaves Java and Python.

  24. Re:Go with an Interpreted Language by Nursie · · Score: 2, Informative

    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

  25. Re:Strange limitation by Charan · · Score: 4, Insightful

    I'm sure the CPU time limit would be generous enough that it won't matter if your programming language is interpreted 10x slower than hand-tuned assembly. They want to make sure you aren't using a brute-force O(n^3) algorithm when a linear one would work well enough.

    Plus, the judges need a rule to allow them to terminate programs that may be stuck in infinite loops. Otherwise, a contestant could delay the results of a competition indefinitely.

    (Imagine: "This competition was rigged! The judges killed my program before it had a chance to finish. It was working fine, and I was the first one to submit answers to all the problems. What? So it has a long start up time. You don't have a rule against 100-hour programs.")

  26. Re:Faster than you think by rwa2 · · Score: 2, Informative

    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.

  27. surely not; Pascal was meant for this by r00t · · Score: 5, Insightful

    We can sort of classify the languages into "slow" and "not slow" in various ways.

    • Learning: Pascal is fast. C++ is horribly slow. The rest are moderate.
    • Compiling: While it can't beat "no compile", Pascal is shockingly fast for people used to something like C or Java. C++ is horribly slow.
    • Start-up: Pascal again does fine. Here it's joined by C and C++. The interpreted stuff is typicallly an embarassment.
    • Run-time: Pascal again does fine. Here it's joined by C. C++ can be fast if you treat it like C or if you're a God-like expert in compiler/library details that normal mortals don't understand. The interpreted stuff is typically an embarassment.

    This should come as no surprise. Pascal was intended as a teaching language. None of the other languages was designed for teaching, unless you somehow equate Visual Basic with BASIC.

    The second choice is probably C, but you'll have some issues teaching about declarations/definitions (inside out) and string-related stuff. The meaning of '=' is also not compatible with normal math notation.

    The third choice is probably Java. You get most of the trouble of C, less speed, and greater need for boilerplate sourcecode bloat.

    1. Re:surely not; Pascal was meant for this by cibyr · · Score: 5, Informative

      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.

      --
      It's not exactly rocket surgery.
    2. Re:surely not; Pascal was meant for this by Glonoinha · · Score: 4, Informative

      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.

      --
      Glonoinha the MebiByte Slayer
  28. Re:Faster than you think by fractoid · · Score: 2, 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.

    --
    Rampant carbon sequestration destroyed the Dinosaurs' tropical paradise. I'm here to help repair the damage.
  29. Re:Faster than you think by Larryish · · Score: 5, Funny

    LOLCODE would be easiest to learn for the cellphone-texting rugrats of today.

    Example of Hello World program:

    HAI
    CAN HAS STDIO?
    VISIBLE "HAI WORLD!"
    KTHXBYE

  30. Why no functional languages? by Jeff+Satterley · · Score: 2, Interesting

    Teach the kids Scheme! Seriously, it's a better transition from pure math to programming. (http://www.teach-scheme.org/)

  31. The syntax viewpoint is an oversimplification. by Kaz+Kylheku · · Score: 2, 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!

    1. Re:The syntax viewpoint is an oversimplification. by Just+Some+Guy · · Score: 2, Funny

      It's sad that the list of languages includes only immature dynamic languages du jour like Python

      I think you meant "du last two decades", as Python's first release was in 1991. What qualifies as "mature" in your opinion? Is it OK to start using ALGOL yet?

      --
      Dewey, what part of this looks like authorities should be involved?
  32. Re:My $0.02 by Joce640k · · Score: 2, Insightful

    C shouldn't even be on the list, neither should Pascal.

    C++ is my favorite language but there's no way you can learn it in that time scale.

    VB is almost obsolete and too much tied into to MS APIs.

    That really only leaves Python or PHP.

    Python is cute but it's not really very good for writing software that has to be published/deployed.

    I'd go with PHP because it's much more useful for getting jobs, etc., after the competition.

    --
    No sig today...
  33. Things you might want to consider by sydneyfong · · Score: 4, Insightful

    I've participated in local and regional Informatics Olympiads, and went to the IOI once. I was involved in training local students a few years ago, so I know quite a bit of the ins and outs of these competitions.

    All the languages have pros and cons, but PHP and VB obviously aren't suitable (if only for their encouragement of crappy coding practices). Java offers little advantage over C/C++, and it forces OOP onto you so it adds an unnecessary layer of complexity for the students.

    The "industry standard" of competitive programming is C++, since it offers near-C speed with the power of various algorithms (eg. sort) and data structures ( maps, sets, priority queues ). Those who intend to take the competition seriously should be using C++ as their primary language. But then judging from your requirements the vast majority of your students won't fall into this category, so I wouldn't recommend C++, at least not at this stage.

    Python generally is a good first language for its simplicity and power. There are a few problems with using python for competitive programming though. First, speed can become a problem for *some* contests, which have rather tight runtime constraints. The contests that cater for a wide range of languages are usually better in this respect, but a lot out there are primarily C/C++/Pascal/Java. Secondly, the fact that python supports a range of built in advanced data structures and algorithms means that you may lose the chance to teach them how to implement the basic stuff, eg. using a binary search tree to implement a map (typing `` mymap = {}; mymap[foo] = bar; '' is surely easier than implementing a BST yourself). You might ask why learn to reinvent the wheel when most modern languages provide these features, but these data structures and algorithms is the core of informatics olympiads, and one needs to learn from the basics. That being said, if the timeframe is just 2 months, I think teaching python might be most rewarding for the students.

    C and Pascal are basically on the same league. C is a bit more "archaic" than Pascal in terms of the way it does things, but feature-wise they are roughly equivalent. The languages are simple, fast, and bare bones enough to force the user to implement the basic stuff. In the long term they are good languages for teaching data structures and algorithms, but require a bit of patience on the part of the student since you need to know quite a bit before you can do anything "flashy" with them.

    My experience with most average students is that they usually struggle to form precise ideas on what to tell the program to do, and then when they do have rough ideas they then fail to write a syntactically correct program, and if they really do write a syntactically correct program the program usually fails on correctness for most inputs, or simply do the wrong thing. Running time shouldn't be a concern before the students actually get a correct program, and my experience is, unless you have really really bright students, most of them probably won't be able to come close to writing a correct program within competition constraints, so don't worry too much about running time.

    In short, I recommend python, but in the long term you might want to think about using C/Pascal. And if you restrain yourself to a subset of C++, it might work too.

    --
    Don't quote me on this.
  34. Re:Too easy... can't resist... by binarylarry · · Score: 3, Funny

    C++ is definitely the best language in the world.

    My god

    --
    Mod me down, my New Earth Global Warmingist friends!
  35. I also recommend Python by O('_')O_Bush · · Score: 2, Insightful

    Even though I do 99% of my work in Java, C/C++, VB, or shell scripts, the few times that I have written in Python, it was an absolute pleasure.

    The libraries that I used kicked Java/C++ library asses, to the extend that what was going to be a "short" 500 line program in Java dealing with parsing images, turned into an 80 line program in Python.

    The best part is, it was extremely easy to debug as I wrote, since just about any line I dropped into the source file, I could check with the interpreter.

    It also only took half an hour to pick up from other OOP languages.

    I <3 Python

    --
    while(1) attack(People.Sandy);
  36. Frameworks are more important than language by u.hertlein · · Score: 3, Insightful

    * Learning: Pascal is fast. C++ is horribly slow. The rest are moderate.
            * Compiling: While it can't beat "no compile", Pascal is shockingly fast for people used to something like C or Java. C++ is horribly slow.
            * Start-up: Pascal again does fine. Here it's joined by C and C++. The interpreted stuff is typicallly an embarassment.
            * Run-time: Pascal again does fine. Here it's joined by C. C++ can be fast if you treat it like C or if you're a God-like expert in compiler/library details that normal mortals don't understand. The interpreted stuff is typically an embarassment.

    What I find interesting is that no one has mentioned that what's actually more important than the language itself is the available libraries/toolkit/frameworks that it comes with.

    Let's face it, after you've learned a few languages it pretty much comes down to "what is printf called this week?" when you pick up a new language (functional languages aside). Getting familiar with frameworks is actually what takes the most time.

    C++ and C are pretty bad in this department. STL is nice but only gets you so far. Threads? Nope (not yet). Sockets? No. XML/encryption/whatnot? Sorry. You have to write an awful lot of code to come up with this or find (and learn!) a support lib that does this. (I do C++ for a living.)

    So I'd say: Python. Or C#/Mono (but that's not on the list, why?)

    --
    Geek by Nature - Linux by Choice.
    1. Re:Frameworks are more important than language by cbhacking · · Score: 5, Insightful

      Python, Java, and VB (one must assume it's VB.NET, and thus has the same libraries as C#) are definitely what I would suggest on the basis of libraries. OK, you can do C++ with the CLR and CLR libraries, but C++ is *not* a good choice for a first language.

      There's a lot of hate on /. for VB, perhaps because not many Slashdotters have tried any version of the language from the last 8 years, but it *is* a good first language - static and strong typing (by default now, I believe), either procedural or OOP (full support for inheritance, unlike legacy VB), BASIC-style syntax (intuitive and quick to pick up), fully memory managed (real GC, not just ref-counting), structured exception handling (no, it's not On Error Goto anymore), and all the .NET/Mono libraries available (before you ask, yes Mono has a VB compiler/runtime, and once you compile it all down to CIL the libraries are usable by any language).

      Java has about half those advantages plus a lot of silly restrictions (although at least Scanner makes getting keyboard input a lot less retarded than it used to be), but it's still a popular choice for learning a first language, and a practical choice for those who want to make a career of programming (though they should learn multiple languages anyhow). Python is a better choice, and possibly quicker to learn, although I'm not a fan of dynamically typed languages with significant whitespace.

      --
      There's no place I could be, since I've found Serenity...
    2. Re:Frameworks are more important than language by Unequivocal · · Score: 2, Informative

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

  37. Re:My $0.02 by pem · · Score: 2, Insightful

    Python is cute but it's not really very good for writing software that has to be published/deployed.

    I can only respond to this statement by quoting Wolfgang Paul: "Not only is it not right, it's not even wrong!"

  38. assume they don't get it right the first time by r00t · · Score: 3, Insightful

    This is a student's programming contest, right? Why are you even concerned about compile time or "startup" time?

    Normally there is a time limit during which the competition runs. The faster your tools are, the more time you have to write code.

    A kid might need 50 tries to get his program right.

  39. Re:My $0.02 by smash · · Score: 2, Insightful
    Eve online has stacks of code written in python. If that isn't "published" enough for you, then Civ4 runs a stack of python code as well.

    PHP is not really what I'd suggest as a good choice. Unless you're doing web development it is fairly unused. And even if you ARE doing web development, its had plenty of bugs and major language changes from release to release.

    PERL would be a better choice from a pure "usefulness in getting a job" standpoint. It can be used for web development, and a whole heap of other tasks.

    But having seen the range of things python has been used to implement, and what I've heard about how easy it is to learn (i'm not a python coder at the moment), I'd agree with the GP that it is a fine choice.

    --
    I run: Windows, OS X, Linux, FreeBSD. Just because you have a hammer, doesn't mean everything is a nail.
  40. Java != slow by Vapula · · Score: 3, Insightful

    Well, it's true that the JVM may take some time to start... but once it's running, JIT and other make it run quite fast... You see game servers hosting hundred of players on a "normal" machine (not 8-CPU 4-core or similar), web sites using JSP, ...

    And if you don't start to use the latest API (reflexion and similar) and stick to "standard" java, it'll make you create clean code...

    But I agree that starting the JVM is rather slow... Even slower if you start it in "server" mode (but then, you'll get a speed increase while running the code)

  41. Teach them C++ by AlgorithMan · · Score: 2, Informative
    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...
    --
    The MAFIAA is a bunch of mindless jerks who will be the first up against the wall when the revolution comes
    1. Re:Teach them C++ by dunkelfalke · · Score: 3, Informative

      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.

      --
      "It's such a fine line between stupid and clever" -- David St. Hubbins, Spinal Tap
  42. It's just me by Exitar · · Score: 3, 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!

  43. The two months' learning time is the real limit. by jonadab · · Score: 2, Interesting

    The CPU time limit is less important in this instance than the two months you have to teach them. In that amount of time, starting them from scratch, you won't likely get to the point of teaching them algorithm analysis and optimization anyway, much less benchmarks and profiling.

    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.

    --
    Cut that out, or I will ship you to Norilsk in a box.
  44. No Perl? You've got to be f**ken kidding by DavidApi · · 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?)

  45. Avoid "object oriented" languages by Antique+Geekmeister · · Score: 2, 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.

  46. Slower yes, yet fast enough. by ThePhilips · · Score: 2, 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.

    --
    All hope abandon ye who enter here.