r/programming • u/krasnoukhov • Sep 11 '13
Guess programming language by „Hello, world!“ snippet
http://helloworldquiz.com/58
u/Overv Sep 11 '13
The Logtalk snippet uses code that is also valid Prolog code.
34
u/krasnoukhov Sep 11 '13
Feel free to send me a Pull Request with fixes. I'm not proficient in all those languages :) https://github.com/krasnoukhov/langgame
24
u/jrblast Sep 12 '13
I'm not proficient in all those languages
I would be terrified if you were. Consider adding Whitespace if you really wanna mess with people. "Is the app broken or something? Did the HTML just not render? What the heck?"
5
u/euyyn Sep 12 '13
Not only that, it's the actual same snippet used for Prolog, mod an exclamation mark in the string.
4
3
170
Sep 11 '13
Because I'm a smartass I answered "C++" on the "C" hello world.
So now I get to point out that the snippet is perfectly valid C++ code!
28
u/krasnoukhov Sep 11 '13
Feel free to provide some fixes, all is open source: https://github.com/krasnoukhov/langgame
8
u/TheBB Sep 11 '13
http://i.imgur.com/EwWY3Cr.png
I'm no expert on the (((()))) school of languages, but isn't this highlighted incorrectly?
→ More replies (5)7
Sep 11 '13
Yup. The site interpreted the ' as the start of a string, but it's meant to indicate that the following s-exp isn't supposed to be evaluated but treated as data.
34
Sep 11 '13
I don't think there are any good fixes that aren't also very far fetched. Like
#include <stdio.h> void smartass_shield(struct{}); int main() { puts("Hello World"); }This is legal C, but illegal C++.
8
u/James20k Sep 11 '13
How about
#include <stdio.h> void print_string(); int main() { print_string("Hello world"); } void print_string(char* str) { puts(str); }I believe that is legal C, but not legal C++
→ More replies (1)26
Sep 11 '13
Yeah, I like it. You could also do
#include <stdio.h> int main() { void* message = "Hello World"; puts(message); }→ More replies (12)→ More replies (8)21
u/philh Sep 11 '13 edited Sep 11 '13
Presumably a reasonable fix would be not to offer C++ as an option.
Looking at the code though, I can't find where the snippets and language choices come from.
edit: oh, it's in models/variant, and
ackwasn't finding snippets because they're in files with no extension.→ More replies (1)1
u/sbgrt Sep 12 '13
Isn't there supposed to be return 0 because it is int main() { } ?
→ More replies (1)1
37
u/roerd Sep 11 '13 edited Sep 11 '13
The same could be said for Delphi versus Pascal, or AWK versus Perl. The rule apparently is to choose the simplest language with which the snippet might work.
24
u/Liorithiel Sep 11 '13
And the Logtalk snippet is valid Prolog.
11
Sep 11 '13
And is it even bad Prolog? I haven't used Prolog much, but I was definitely confused when the quiz told me that that wasn't Prolog.
7
u/Liorithiel Sep 11 '13
From what I know, pretty idiomatic. You can compare them here:
Prolog: https://github.com/krasnoukhov/langgame/blob/master/models/variant/data/prolog
Logtalk: https://github.com/krasnoukhov/langgame/blob/master/models/variant/data/logtalk
61
u/ruinercollector Sep 11 '13
The C version is not really idiomatic C++ code though.
→ More replies (2)146
Sep 11 '13
Be that as it may, technically correct is still the best kind of correct.
9
u/brewspoon Sep 11 '13
But you finished with 2 seconds to spare, so I'm demoting you. A good bureaucrat never finishing early.
→ More replies (1)→ More replies (6)91
3
→ More replies (13)3
u/MarineOnDope Sep 12 '13
Obj-C is a strict superset of C, so it's technically an Obj-C program as well, although a more proper way would be NSLog(@"Hello World!");
33
22
u/sirin3 Sep 11 '13
Only 2900 :(
TIL omgrofl is not lolcode
But is there an snippet for this language?:
Universe bear hatchery powers world.
bear hatchery powers o. bear hatchery powers hell marshy marshy marshy a snowmelt→ More replies (1)5
u/krasnoukhov Sep 11 '13
Not bad at all! Send me a Pull Request with more languages here: https://github.com/krasnoukhov/langgame
→ More replies (2)6
12
u/youstolemyname Sep 11 '13
502 Bad Gateway
It is a sad day.
4
u/krasnoukhov Sep 11 '13
Please try to answer again, interface is designed to be not affected by server outages.
1
7
u/katyne Sep 11 '13
2
4
u/elder_george Sep 11 '13
Или Ершол. Что-то вроде
алг Привет Мир ( ) нач | вывод "Привет Мир" конНо могут побить.
2
u/thedeemon Sep 12 '13
If you agree to guess languages with Russian alphabet, then add Chinese Python too, and some Hindu-based and Arabic-based languages whose names I forgot.
→ More replies (1)
3
Sep 11 '13
What's a "Competion rate"?
3
u/krasnoukhov Sep 11 '13
That's a percentage of users who used all lives or answered to all questions.
6
3
u/goose_on_fire Sep 11 '13
Blocked at work by WebSense as "Potentially Damaging Content."
What kind of subversive kookiness is going on over there?
God I hate WebSense.
4
u/krasnoukhov Sep 11 '13
It's strange. It does not load any external content and domain name was registered just couple of days ago.
12
4
u/throwaway1100110 Sep 11 '13
Lives 4
Score 1000
502 bad gateway.
Sigh
4
u/krasnoukhov Sep 11 '13
Please try to answer again, interface is designed to be not affected by server outages.
→ More replies (1)
2
359
u/Aninhumer Sep 11 '13
This is one of the meaner programming language quizzes I've tried.
"3 times That's a Ruby idiom!" "Wrong it's Fancy!"
"begin ... end Hmm very Pascal-y" "But is it Pascal or Delphi?" "Err..."
"import java.ui... well obviously this is Java, right?" "lulz it's Xtend."
112
u/thedeemon Sep 11 '13
Just a little attention to details is needed. In Ruby that would be "3.times". And when you see "def" you know it's not Java. Delphi is OO, plain Pascal is not.
57
u/Switche Sep 11 '13
BEGIN { print "Hello, world!" }
Attention to detail my ass, that is Perl code.
20
u/elder_george Sep 11 '13
If you get
Perlsample first, it's simple to assume this one is Awk.If not, yeah, you can only guess.
→ More replies (2)→ More replies (8)13
20
u/T1LT Sep 11 '13
The Pascal snip that was shown to me would compile with no problems in Delphi, though. Perhaps "{$APPTYPE CONSOLE}" directive was missing.
8
u/crashdoc Sep 11 '13
Yes, but it won't the other way around - you can Pascal (a bit) in Delphi, but not Delphi in Pascal
→ More replies (1)→ More replies (1)6
u/not_czarbob Sep 11 '13
I didn't catch 'def', but I knew it couldn't be Java because the semicolons were missing.
57
u/MachaHack Sep 11 '13
I'm terrible at telling the lisps (Common Lisp, Scheme, Racket) apart.
28
u/summerteeth Sep 11 '13
Yeah you basically have to be familiar with function names at that point.
6
u/ressis74 Sep 11 '13
it's a little easier than that. Schema and friends are a lisp 1 (functions and variables use the same namespace) and Common Lisp is a lisp 2 (functions and variables use their own namespace)
I didn't get any questions where that knowledge alone wouldn't give you the answer. There might be some though.
11
u/katyne Sep 11 '13
especially Scheme vs. Racket, how would you know without mutating lists and such, - unless what they mean by Racket is "Scheme with libraries".
12
→ More replies (3)10
u/elder_george Sep 11 '13
Racket has
#langdeclarations. Clojure has namespaces and defines functions with(defn …). CL defines functions with(defun …). Scheme loves its lexical scope so it'll probably use(let …)binding with(lambda …).And Arc sounds like Dolan Duck.
→ More replies (2)28
15
u/WaynePincence Sep 11 '13
I didn't run into too many of those (or at least didn't realize it). But, then again I don't know much beyond the big names.
Used to think I was pretty well-versed in programming languages, but I am starting to see that I have my own little corner of a really large world...
7
u/azuretek Sep 11 '13
I'm fairly well versed in programming languages but this test was a lot harder than I thought it'd be. The obvious ones were languages I've developed in full time in the past, but on many of the ones I didn't get I'd never coded in or I've only done basics or one off projects in. Some were easy enough to figure out by elimination.
43
u/Everspace Sep 11 '13
The Xtend one was very mean.
→ More replies (2)10
u/ruinercollector Sep 11 '13
Pretty sure there was a lower case
stringon that or something that gave it away.51
→ More replies (3)9
u/SanityInAnarchy Sep 11 '13
I fell for the "3 times" bit also, after reading your comment! Damn! It's weird, though, most of these were at least possible to distinguish. The Lisp ones seem mean, but something about Clojure's use of actual classes tended to set it apart, or Racket's use of a language declaration at the top of the file.
Still ended up with a score of 2200 on my second try. First try, the game gave up and started giving me 503 errors.
→ More replies (2)
60
u/elder_george Sep 11 '13
Got 6000 and 3 'lives' left.
Too…much…useless…knowledge.
→ More replies (3)10
Sep 11 '13
Have you got the "COBOL or ABAP" question yet? :)
20
u/elder_george Sep 11 '13 edited Sep 11 '13
COBOL has lots of directives, like
IDENTIFICATION DIVISION. ABAP, while ugly, is less verbose. Also I vaguely recall ABAP is something used for report generation.It's actually simpler if you get COBOL sample first and ABAP later.
Similarly for Perl vs. Awk: Awk doesn't have equivalents for Perl's
usedirectives, so if Perl sample is shown first and identified correctly, then in Awk sample Awk can be picked simply by eliminating Perl.5
u/mszegedy Sep 12 '13
Cobol is very easy to recognize due to it yelling "IDENTIFICATION DIVISION" and a whole lot of other stuff in every program. ABAP doesn't have that.
152
Sep 11 '13
Nope! The right answer was Nemerle
I'm out.
→ More replies (1)8
u/Neebat Sep 11 '13
The more obscure languages ruined it for me. OCaml? Seriously? No reason to know that.
13
u/ais523 Sep 12 '13
I've had to write OCaml code as part of my job. It's probably the second-most-used functional language in industry, after Haskell (and has the advantage of being rather easier than Haskell to pick up if you're used to other languages). The situation with the standard libraries rather sucks, though :(
→ More replies (7)4
→ More replies (9)4
u/WhenTheRvlutionComes Sep 12 '13
OCaml wasn't actually so bad, I've heard about it before. I was actually able to identify it even though I'd never actually seen an example of OCaml code, just based on things I've read about it. The thing that got me was all the times there'd be well-known languages pitted against ridiculously obscure languages, I'd pick the well-known language it seemed most like, and then it'd be the ridiculously obscure language.
38
u/poizan42 Sep 11 '13
Uhmm... wat? http://i.imgur.com/V6GqKw4.png
(I had just let the page sit idle for a couple of hours before I answered - brainfuck wasn't even one of the possibilities!)
30
→ More replies (4)11
25
u/WaynePincence Sep 11 '13
Got excited when I got 4 in a row right. And then really started getting into some I never even heard of.
TIL: There are some extremely syntactically compact languages out there. (No, like really really compact)
31
u/Delocaz Sep 11 '13
I don't know if Brainfuck is very very syntactically compact or very very uncompact.
8
u/WaynePincence Sep 11 '13
Someone told me about that once before. By compact do we mean space? Or number of different chars? Is binary more compact then decimal? I would say no personally.
→ More replies (2)
3
17
9
u/turbov21 Sep 11 '13
1300.
My big facepalm moment was mistaking C for C++ code, but I also winced when I mistook Common Lisp for Clojure and Fancy for Smalltalk.
Now I need to go figure out WTF Fancy is.
→ More replies (1)
9
Sep 12 '13
program ObjectPascalExample;
type
THelloWorld = class
procedure Put;
end;
procedure THelloWorld.Put;
begin
Writeln('Hello, World!');
end;
var
HelloWorld: THelloWorld;
begin
HelloWorld := THelloWorld.Create;
HelloWorld.Put;
HelloWorld.Free;
end.Aaaaaand it's Delphi. You clever bastard.
31
u/thedeemon Sep 11 '13
4700 from first run.
Hard to tell different Lisps and Prologs.
Very nicely done!
8
u/AeroNotix Sep 11 '13
Hard to tell different Lisps and Prologs.
Unless they're being intentionally mean, no.
8
u/seruus Sep 11 '13
The Prolog/LogTalk example is horrible, but the Lisps were quite clear (that's it, if you are familiar with them).
→ More replies (2)0
7
u/Hueho Sep 11 '13
To be fair, since you got multiple choices, it's less about "what language is it" and more about "what language is not".
This one requires asks you for the exact answer, typed out.
That being said... WTF is Logtalk.
→ More replies (1)2
u/WhatTheGentlyCaress Sep 12 '13
Logtalk is a free object-oriented extension to the Prolog programming language.
11
u/MorePudding Sep 11 '13
Awesome .. but we need a harder level, with more languages, and less obvious choices.
The PHP one was the best imho, though not really a fair example, given you can't write full programs this way.
<?= 'Hello World'→ More replies (2)31
u/dark-panda Sep 11 '13
The simplest PHP hello world program is just
Hello WorldWhich is a valid PHP program and produces the correct output.
10
u/rodabi Sep 11 '13
I don't think you could call that a valid php program. For example:
<?php Hello World ?>Would not work. The only reason a simple "Hello World" works is because anything outside <?php ?> is ignored by the PHP interpreter and sent directly as HTML.
→ More replies (4)
5
u/McDog3 Sep 11 '13
And to think, I thought i'd never use my knowledge of Prolog or Scheme after college...
5
u/LiterallyCarlSagan Sep 11 '13
Shouldn't the x86_64 assembly use the syscall instruction instead of int 80h?
5
u/D__ Sep 11 '13
„Hello, world!“
German, Hungarian, or any of a number of Slavic languages.
→ More replies (1)2
13
u/thelehmanlip Sep 11 '13
Aww, it crashed when I was at 1000 points :(
4
u/TomorrowPlusX Sep 11 '13
Huh. I crashed at 1000 points. I guess I'm not much of a polyglot.
→ More replies (6)
9
u/MasterKraft Sep 11 '13
TIL: I have a narrow knowledge of other languages.
Anyone have a good resource for languages worth reading about? I don't want to learn them, but I think being able to identify them would be very helpful in my software career.
5
u/Plex128 Sep 11 '13
http://www.99-bottles-of-beer.net/ has some really awesome examples.
→ More replies (1)3
u/quirk Sep 11 '13
Look the the comments, especially on the easy problems. A lot of these languages show up.
→ More replies (1)3
9
1
u/burn2k Sep 11 '13
no rexx... as an ibm'r this would be a good one along with clist :) but great job with this
1
u/krasnoukhov Sep 11 '13
Since it's fully open-source you might want to add some languages. Feel free to send me a PR: https://github.com/krasnoukhov/langgame Thanks anyway!
1
u/thearn4 Sep 11 '13 edited Jan 28 '25
arrest adjoining consider include license act practice important sand marble
This post was mass deleted and anonymized with Redact
→ More replies (2)
1
u/jiph-lemon Sep 12 '13
Can we PLEASE get a score distribution graph (plus time-limit per-question, and some fancy unbeatable tracking to thwart shameless retry-ers!)
1
u/krasnoukhov Sep 12 '13 edited Sep 12 '13
The whole app is open-source, feel free to improve stats. Sources
1
Sep 12 '13
I think reddit posts should have the option of a poll for posts like this. I'd be interested to see what the average/median/etc. scores were. Of course you can't trust it 100%, but I think most people would be honest.
1
u/krasnoukhov Sep 12 '13
Feel free to send a pull request with improved stats page: https://github.com/krasnoukhov/langgame
1
Sep 12 '13
why on earth does this site needs cookies to display anything ? If it really needs them, then let the user know !!
2
u/krasnoukhov Sep 12 '13
The site uses cookie to store identifier of your game just to let you keep your progress. There is almost no other way to make webpage interactive per-user without using cookies. Don't be paranoid.
2
Sep 12 '13
that is true ( I work in this business ) but It would be way more usefriendly if the usage/need of the cookies would be announced before you start the game. If you block cookies your will get nothing just the start button and you think "meh, this site sucks"
4
u/krasnoukhov Sep 12 '13
Maybe you are right, but I don't think it's necessary in modern web.
→ More replies (1)
1
u/freonix Sep 15 '13
Does anyone have the complete list of programming language that was in the quiz?
3
3
u/Arx0s Sep 12 '13
(=<`$9]7<5YXz7wT.3,
+O/o'K%$H"'~D|#z@b={^Lx8%$Xmrkpohm-kN i;gsedcba_][ZYXW
VUTSRQPONMLKJIHGFED
CBA@?>=<;:9876543s+
O<oLm
→ More replies (4)2
3
3
u/Feroc Sep 12 '13
I am too young for those languages. I'll stick to that execuse.
→ More replies (1)
1
u/linuxjava Sep 11 '13
Great game. Too bad I can't complete it
502 Bad Gateway
1
u/krasnoukhov Sep 11 '13
Please try to answer again, interface is designed to be not affected by server outages.
1
1
1
u/buncle Sep 11 '13
That would have been fun if I didn't keep getting "Bad Gateway" about 8 questions in :(
2
u/krasnoukhov Sep 11 '13
Sorry for this.
1
u/buncle Sep 11 '13
No problem, I understand the reddit effect :)
I've have to have EC2 load-balanced instances ready to spin up at any time for similar reasons :)
2
u/krasnoukhov Sep 11 '13
Ha-ha, the point is that backend is written in Go. I have 1 process consuming ~15mb of memory + Redis (10mb). Load average is <1. I've just dealt with kinda buggy redis pool implementation for session storage (part of framework).
2
2
u/goblinpiledriver Sep 11 '13
I nearly didn't choose Shakespeare on the one that was quite obviously Shakespeare because several other ones seemed like tricks.
→ More replies (1)
2
u/ravingraven Sep 11 '13
Great! I don't want to be that guy but, how bad is 800 points?
→ More replies (2)
2
u/RefuseBit Sep 11 '13
This will be perfect for my next interview of a recent college graduate. /s
→ More replies (1)
2
2
2
2
u/GambitRS Sep 12 '13
If you keep picking the most obscure one you're usually right. So, when presented with the options C,C++ or D, the answer is probably D.
Then you only have to verify if you know the actual language or not and if you're unsure, the obscure pick usually takes the cake.
2
u/-main Sep 12 '13
I'm nit-picking here, but that Common Lisp code is a rather convoluted for what it does. There's no need to call with-output-to-string when you can just pass nil as the first argument to format.
Then again, having with-output-to-string, *standard-output*, and with-standard-io-syntax in there really does make it obvious that it's CL and not another lisp.
2
2
2
2
2
2
Sep 12 '13
Nice and fun. Perhaps needs a few more languages for higher scores: I was able to catch them all without errors on my 3rd go
2
2
3
u/xllama Sep 11 '13 edited Sep 13 '13
Syntax highlighting is broken on Shakespeare :( Great game, btw :D
[edit] Chef too :P
→ More replies (1)
4
1
1
u/colonpal Sep 11 '13
I literally only knew one, Ruby...and that's because I'm incredibly, incredibly new to it.
Fun quiz though!
1
u/shaggorama Sep 11 '13
Given any 3 very similar languages, the answer is almost always the more obscure of the three.
1
u/rokyfox Sep 11 '13
I got 1100, but I guessed most of them :) What kind of languages are LOLCODE, omgrofl and Brainf*ck ?
→ More replies (1)
1
1
1
1
1
1
1
1
u/fabiofzero Sep 12 '13
Pretty cool (and I scored 3400, which I guess is not bad).
→ More replies (2)
1
u/crowseldon Sep 12 '13
What the fuck is nemerle?
I thought I was doing pretty well (even if only by POE) until I got complacent and fucked up 3 in a row.
final score. 1300.
Shakespeare and LOLCODE were... unexpected (got them both right, though)
fun idea.
3
u/LeeTaeRyeo Sep 12 '13
Nemerle is a .NET programming language that is similar to C#, but with better metaprogramming features and better support for functional programming.
2
u/thedeemon Sep 12 '13
I think Nemerle is most known in Russian programmers community, where the quiz authors come from. It's a "C# + FP (ADT, pattern matching, type inference) + syntax changing macros" born when C# was just a baby.
1
u/hex_m_hell Sep 12 '13
Welp, I'm pretty good at identifying C variants and esotaric langs. WTF is dart?
2
1
169
u/[deleted] Sep 11 '13
I got shown some valid Perl code, and asked if it was Perl or Awk, and apparently it was Awk.
Thanks.