News for hackers. Stuff that matters.
Re:What's this programming language? by pavanky on Saturday June 02, 2012 @02:58AM (#4057348)
It can't understand C. http://i.imgur.com/7hrPE.png
Re:What's this programming language? by tyrmored on Saturday June 02, 2012 @03:02AM (#4057354)
I gave it this and it thought it was Vala:

    #include <stdio.h>
    
    int main(int argc, char* argv[]) {
        return 0;
    }
Haskell is a very weird guess for yours.
Re:What's this programming language? by nithinbekal on Saturday June 02, 2012 @03:05AM (#4057360)
Yup, it does a terrible job with the C family of languages. Hardly ever gets that right. And if you type in any random keys, it often identifies it as Haskell. ;-)

It does a decent job with Perl, Python, Ruby, Bash, etc.

Re:What's this programming language? by tyrmored on Saturday June 02, 2012 @03:06AM (#4057361)
Yeah, it nailed all the Perl I tried, even rather niche stuff.
Re:What's this programming language? by Akram on Saturday June 02, 2012 @04:06AM (#4057485)
It cant even get a "Hello World" C program right.

#include<stdio.h> main() { printf("Hello World"); }

Re:What's this programming language? by Someone on Saturday June 02, 2012 @05:11AM (#4057624)
Nice idea, but the quality and/or the breadth of languages it knows about leaves much to be desired.

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 http://c2.com/cgi/wiki?ExampleForthCode gets a 'VHDL, could also be VBSCRIPT'

My next attempt was PostScript. I copied http://www.science.uva.nl/~robbert/ps/bluebook/program_01.ht... (which starts with the giveaway line "%!PS-Adobe-2.0"), and it says 'RUBY, could also be MEL'

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.

Re:What's this programming language? by Akram on Saturday June 02, 2012 @04:09AM (#4057490)
<script> var str="hello world"; </script>

This looks like xml. It could also be django, though. I'm not completely sure. //--------------------- How come Django is a programming language?

Re:What's this programming language? by drostie on Saturday June 02, 2012 @04:32AM (#4057549)
It's in the same sense that PHP is a programming language -- Django has its own idiomatic templating language with loops and other such constructs. It looks like this:

    {% extends "base.html" %}
    {% block title %}My amazing blog{% endblock %}
    {% block content %}
        {% for entry in blog_entries %}
            <h2>{{ entry.title }}</h2>
            <p>{{ entry.body }}</p>
        {% endfor %}
    {% endblock %}
As for why this thing can't recognize "it looks like HTML + JS", I can't answer that for you -- but there should be a family of responses; "HTML + PHP," "HTML + Django", "HTML + JS" etc.
Re:What's this programming language? by jhuni on Saturday June 02, 2012 @04:09AM (#4057487)
(defn factorial [n] (apply * (range 2 (inc n)))) - Rust or CSS

(defun factorial (n) (apply (function *) (upto n))) - MATLAB or Lua

Re:What's this programming language? by darkestkhan on Saturday June 02, 2012 @05:00AM (#4057607)
I put this:

  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;
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"
Re:What's this programming language? by carbocation on Saturday June 02, 2012 @02:38AM (#4057301)
Impressive that it doesn't just take the best guess; it also informs you of its alternative hypotheses:

http://i.imgur.com/wITwa.png

Update:

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): http://softwaremaniacs.org/wiki/doku.php/highlight.js:api

Re:What's this programming language? by nithinbekal on Saturday June 02, 2012 @02:42AM (#4057312)
OP here. I can't take credit for that, though. ;-)

It uses the highlight.js API for making the guesses, which provides the 2nd best option as well. :)

Re:What's this programming language? by reacweb on Saturday June 02, 2012 @06:10AM (#4057708)
In conclusion, the site is a very good idea, but highlight.js is really too bad for this kind of use. Raise a ticket on highlight.js
Re:What's this programming language? by ittan on Saturday June 02, 2012 @02:47AM (#4057318)
Just tried it out with brainfuck(http://en.wikipedia.org/wiki/Brainfuck)!

++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.

XML or django. then again this could be anything. :P

Re:What's this programming language? by nithinbekal on Saturday June 02, 2012 @04:20AM (#4057509)
The app depends on highlight.js which currently supports a limited set of languages, and unfortunately, Brainfuck isn't one of them.

http://softwaremaniacs.org/media/soft/highlight/test.html

I wonder what would happen to the accuracy of highlight.js highlightAuto method if more languages were to be supported. Highlight.js recognizes languages based on how many language constructs it can recognize. More languages = more overlap in language constructs, and therefore more likelihood of wrong matches.

Re:What's this programming language? by pud on Saturday June 02, 2012 @03:57AM (#4057461)
Cool thing. Though it doesn't get ColdFusion. Anything with <cf_____> tags is ColdFusion.

<cfset foo = "bar">

Re:What's this programming language? by chuckbot on Saturday June 02, 2012 @02:48AM (#4057324)

   int main(int argv, char **argv) {
       return 0;
   }
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.

The idea to reduce language recognition to syntax highlighting is a nice idea, but doesn't seem to work.

Re:What's this programming language? by jvc26 on Saturday June 02, 2012 @05:54AM (#4057684)
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 http://wtpl.heroku.com/.
Re:What's this programming language? by Ivatar on Saturday June 02, 2012 @06:41AM (#4057753)
Doesn't seem to be familiar with factor:

  : foo ( seq -- nseq ) [ 1 + ] map ;
"This looks like ruby. It could also be lua, though. I'm not completely sure."

I would have expected a guess at forth, but I really don't think it looks like ruby...

Re:What's this programming language? by mseepgood on Saturday June 02, 2012 @06:30AM (#4057739)
Input (Go):

-----------------------

package main

import "fmt"

func main() { fmt.Println("Hello, 世界") }

-----------------------

Response: "This looks like actionscript. It could also be haskell, though. I'm not completely sure."

FAIL

Re:What's this programming language? by sink on Saturday June 02, 2012 @03:15AM (#4057374)
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?
Re:What's this programming language? by bad_alloc on Saturday June 02, 2012 @04:25AM (#4057532)
life←{↑1 ⍵∨.∧3 4=+/,¯1 0 1∘.⊖¯1 0 1∘.⌽⊂⍵}

(APL Code for Conway's Game of Life, taken from Wikipedia) Recognized as Haskell.

This X[⍋X+.≠' ';] is AVRASM or CSS.

UPDATE: It gets better: INTERCAL (the despotic programming language) is recognized as Delphi or SQL. This seems suitable for Delphi ;) (Here's the code: http://cxg.de/_01a19b.htm)

Re:What's this programming language? by sbmassey on Saturday June 02, 2012 @02:53AM (#4057338)
Its not too good at C++.

Apparantly,

  template <typename T> T foo(T t) { return t; }
looks like DJANGO or XML.
Re:What's this programming language? by estenh on Saturday June 02, 2012 @04:10AM (#4057492)
So, uh... what does this say about PHP?

http://i.imgur.com/81uas.jpg

Re:What's this programming language? by tluyben2 on Saturday June 02, 2012 @04:02AM (#4057473)
This definitely needs some work :) http://o7.no/JGT5pv
Re:What's this programming language? by tg3 on Saturday June 02, 2012 @04:22AM (#4057513)
it thought my javascript was Lua, my php was bash or ruby, and my ruby was haskell.
Re:What's this programming language? by damian2000 on Saturday June 02, 2012 @02:52AM (#4057334)
Nice job... got my C# and Ruby correct, but FORTRAN was seen as VBSCRIPT.
Re:What's this programming language? by mitchi on Saturday June 02, 2012 @03:11AM (#4057369)
So bad!

#include <stdio.h> XML

printf("%d", i); ERLANG

Re:What's this programming language? by hornetblack on Saturday June 02, 2012 @06:39AM (#4057750)
I put in brainfuck it said it might be VB
Re:What's this programming language? by KonradKlause on Saturday June 02, 2012 @05:57AM (#4057689)
main() { }

"This looks like css. It could also be haskell, though. I'm not completely sure."

Erm, okay...

Re:What's this programming language? by stewie2 on Tuesday June 05, 2012 @03:17PM (#4070321)
not accurate at all.