Nice idea, but the quality and/or the breadth of languages it knows about leaves much to be desired.<p>The first language I tried was Forth. I have yet to find a piece of code that it recognizes as such. For example the example from <a href="http://c2.com/cgi/wiki?ExampleForthCode" rel="nofollow">http://c2.com/cgi/wiki?ExampleForthCode</a> gets a 'VHDL, could also be VBSCRIPT'<p>My next attempt was PostScript. I copied <a href="http://www.science.uva.nl/~robbert/ps/bluebook/program_01.html" rel="nofollow">http://www.science.uva.nl/~robbert/ps/bluebook/program_01.ht...</a> (which starts with the giveaway line "%!PS-Adobe-2.0"), and it says 'RUBY, could also be MEL'<p>I guess that the thing would look better of with some kind of thresholding that allows it to say 'I don't know, but if I had to guess, I would say RUBY or MEL' instead.
<script>
var str="hello world";
</script><p>This looks like xml. It could also be django, though. I'm not completely sure.
//---------------------
How come Django is a programming language?
I put this:<p><pre><code> with Ada.Text_IO;
procedure WTF
is
type X is array (Positive range <>) of Integer;
procedure Print (N: X)
is
begin
for I in N loop
Ada.Text_IO.Put_Line
(File => Ada.Text_IO.Standard_Output,
Item => Integer'Image (N (I));
end loop;
end Print;
begin
null;
end WTF;
</code></pre>
And it can't recognize Ada :)
Even when you use standard library.
"This looks like VHDL."
"It could also be a VBSCRIPT, though I'm not completely sure"
Impressive that it doesn't just take the best guess; it also informs you of its alternative hypotheses:<p><a href="http://i.imgur.com/wITwa.png" rel="nofollow">http://i.imgur.com/wITwa.png</a><p><i>Update:</i><p>Reading your blog post, I see that this is a wrapper around highlight.js, which is doing the language-guessing (including the second-best guess): <a href="http://softwaremaniacs.org/wiki/doku.php/highlight.js:api" rel="nofollow">http://softwaremaniacs.org/wiki/doku.php/highlight.js:api</a>
Just tried it out with brainfuck(<a href="http://en.wikipedia.org/wiki/Brainfuck" rel="nofollow">http://en.wikipedia.org/wiki/Brainfuck</a>)!<p>++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.<p>XML or django. then again this could be anything.
:P
<p><pre><code> int main(int argv, char **argv) {
return 0;
}
</code></pre>
Doesn't look like CS and can't even be java. Adding a printf changes the top suggestion to perl. Adding an include changes the top suggestion to vala.<p>The idea to reduce language recognition to syntax highlighting is a nice idea, but doesn't seem to work.
Its a neat idea but seems to struggle - misidentifying PHP as BASH, and struggling with Haskell, Go, Clojure, and told me Bash was PERL. I pulled some test code from the What's That Programming Language site which appeared on HN a few weeks ago <a href="http://wtpl.heroku.com/" rel="nofollow">http://wtpl.heroku.com/</a>.
Doesn't seem to be familiar with factor:<p><pre><code> : foo ( seq -- nseq ) [ 1 + ] map ;
</code></pre>
"This looks like ruby.
It could also be lua, though. I'm not completely sure."<p>I would have expected a guess at forth, but I really don't think it looks like ruby...
Input (Go):<p>-----------------------<p>package main<p>import "fmt"<p>func main() {
fmt.Println("Hello, 世界")
}<p>-----------------------<p>Response: "This looks like actionscript. It could also be haskell, though. I'm not completely sure."<p>FAIL
Might mention that it sees Scala as Ruby or Python (ouch!). But I did just type in, "bunch of stuff, some programming stuff" and it thought that was Haskell or Coffeescript. Guess those win awards for literate programming?
life←{↑1 ⍵∨.∧3 4=+/,¯1 0 1∘.⊖¯1 0 1∘.⌽⊂⍵}<p>(APL Code for Conway's Game of Life, taken from Wikipedia)
Recognized as Haskell.<p>This X[⍋X+.≠' ';] is AVRASM or CSS.<p>UPDATE: It gets better: INTERCAL (the despotic programming language) is recognized as Delphi or SQL. This seems suitable for Delphi ;) (Here's the code: <a href="http://cxg.de/_01a19b.htm" rel="nofollow">http://cxg.de/_01a19b.htm</a>)