<div class="gmail_quote">On Sun, May 8, 2011 at 6:10 AM, Peter Alexander <span dir="ltr"><<a href="http://peter.alexander.au">peter.alexander.au</a>@<a href="http://gmail.com">gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

The Google Code Jam is a programming competition where you have to solve algorithmic problems using whatever programming language you like.<br>
<br>
The stats of what programming languages were used in the first round were collected:<br>
<br>
<a href="http://www.go-hero.net/jam/11/languages" target="_blank">http://www.go-hero.net/jam/11/languages</a><br>
<br>
Some select figures for languages used to solve the first question:<br>
<br>
C++     5032<br>
Java    2321<br>
C#      628     <br>
C       532<br>
Haskell 100<br>
Clojure 13<br>
GO      13<br>
D       5<br>
Scheme  5<br>
<br>
(In previous 3 years, D had between 2-4 entries for the first question, so not much change, despite total contestant counts increasing quite dramatically)<br>
<br>
Generally, I believe people tend to use the language they are most familiar with, and for people that know more than one language they will choose the one that is most expressive. Stability of implementations could also be an issue.<br>


<br>
Obviously you can't draw too many conclusions from this alone, but more data is always better. Take what you will from it.<br>
<br></blockquote><div><br></div><div>I was one of the D users, although I wasn't really worried about competing. I just wanted to see how D would compare after doing so many programming contests in Java.</div><div>The main thing that frustrated me was that getting input in D wasn't anywhere near as straightforward as it is in Java. For the first problem, I'd do something like this in Java:</div>

<div>Scanner in = new Scanner(System.in);</div><div>int numTests = in.nextInt();</div><div>for(int test = 0; test < numTests; tests++) { //need the test index for output</div><div>int numSteps = in.nextInt();</div><div>

for(; numSteps < 0; numSteps--)</div><div>char robot = in.nextChar();</div><div>int button = in.nextInt();</div><div>//solve the problem!</div><div>}</div><div>//print the output!</div><div>}</div><div><br></div><div>
<br>
</div><div>In D, that looked like this:</div><div><div>string line;</div><div>int num;</div><div>stdin.readln(line);</div><div>formattedRead(line, "%s", &num);</div><div>for(int casen = 0; casen < num; casen++) {</div>

</div></div><br><div>...</div><div><br></div><div>In a few places, I could have used stdin.readf instead of readln/formattedRead, but not many because the number of items within a test is on the same line as the items.</div>

<div>I could have just been missing something, but something that was trivial in Java became brittle in D because I had to exactly match the whitespace for things to work. I suppose I could have read a line and used splitter to split on whitespace, but that would make me have to watch more state and would wind up looking like this:</div>

<div>string line;</div><div>stdin.readln(line);</div><div>auto split = split(line);</div><div>int num = to!int(split[0]);</div><div>split = split[1..$];</div><div><br></div><div>...</div><div><br></div><div>Actually... now that I'm looking at that, if I wrote a Scanner-like class based on this, is there any chance it could go into Phobos? Seems like between split and to, we could get something much less brittle working.</div>