Skip to content
 

Google Translate for code, and an R help-list bot

What we did in our Stan meeting yesterday:

Some discussion of revision of the Nuts paper, some conversations about parameterizations of categorical-data models, plans for the R interface, blah blah blah.

But also, I had two exciting new ideas!

Google Translate for code

Wouldn’t it be great if Google Translate could work on computer languages? I suggested this and somebody said that it might be a problem because code isn’t always translatable. But that doesn’t worry so much. Google Translate for human languages isn’t perfect either but it’s a useful guide. If I want to write a message to someone in French or Spanish or Dutch, I wouldn’t just write it in English and run it through Translate. What I do is try my best to write it in the desired language, but I can try out some tricky words or phrases in the translator. Or, if I start by translating, I go back and forth to make sure it all makes sense.

An R help-list bot

We were talking about how to build a Stan community that will be helpful to a diverse range of users without taking up too much of our time, and that’s when I came up with a brilliant idea. Let’s take a successful existing help group—for example, the R-help mailing list—then make a database of the helpful bits of advice of a distinguished and frequent contributor to the list. The bot would be easy: whatever the question is that comes in, just send back a random tip. I have a feeling that advice such as “PLEASE do, and not send HTML” and “My guess is that this is a Mac-specific question (e.g. you are using the R.app GUI), so please consider if this is the appropriate list” and “The posting guide was not followed” and “Please use the R-devel list to comment on current development versions” would work pretty well for almost any question (maybe after some global sub of Stan for R).

It’s sort of like when we were kids and had this book, Bennett Cerf’s Book of Riddles—it was a gray with a picture of a big red rock-eater on the cover. We started out by just reading through the riddles one at a time but we had more fun after inventing a game where we’d open the book and read a riddle, then open again at random to give the answer. For example:
Q: What’s big, red and eats rocks?
A: Two cats stuck in a tree!

17 Comments

  1. PM says:

    The R-list bot is easily the funniest thing on the Internet today, including the archives of The Onion.

  2. Hi Andrew, you might be interested in what Ben Lafreniere is doing with the gimp. I read about it at http://crowdresearch.org/blog/?p=657 . Also, see http://crowdresearch.org/blog/?s=gimp -David

  3. Daniel Habtemariam says:

    Our group put together a (very basic) translator for code for translating between various statistical package languages. It’s a desktop application. We’d never thought to put it on the web. I agree that it would be fantastic if Google would do it.

    And here I was thinking I had an original idea…

  4. Clark Andersen says:

    Back in 1999 or thereabouts I participated in a project to convert code from an obscure language called Jovial (which has odd features like arrays which can begin with arbitrary indices other than 0 or 1, and is used in hardware like GPS satellites and military aircraft) to C. Spoken languages don’t have to deal with looping/blocking/logic/data structures, which makes translating programming languages challenging. Of course, spoken languages lack a concise symbol structure, which makes translating spoken languages challenging. For this project, I wrote a program which automatically handled 90+% of the conversion, but we still needed programmers to handle the final portion.

    There are a variety of utilities for converting amongst the more standard programming languages, but I think they are weak when you get away from the text & command line paradigm and move into the modern graphical user interface paradigm. Then there’s issues with software which is assembled from a multitude of files and references libraries of predefined functions. As you suggest, a rough translation is fairly easy to provide, but a complete translation will likely require the involvement of a programmer. There’s probably not enough demand for a commercial company like Google to get this underway, but I agree that it would be nice if such an all-in-one utility existed.

  5. zbicyclist says:

    I’m reading this entry while on hold with corporate PC Online Support — 3rd call in 2 days, on hold with multiple people, each suggesting apparently random unsuccessful fixes. The R bot idea is not so much hilarious as painfully accurate.

  6. Ely Spears says:

    There is also the Online Matlab to Python converter: ( http://ompc.juricap.com/ ) and a paper accompanying it: ( http://www.ncbi.nlm.nih.gov/pmc/articles/PMC2644618/ ).

  7. Andreas Baumann says:

    Both are great ideas, but I think it would the first idea would create a strong incentive counter to our central undertaking, which – of course – should be to ensure that everyone writes their damned things in LISP.

  8. I think we already have bots. They’re people (I’m most positive most of them are indeed people) over at stackoverflow.com under the [r] tag.

  9. Ken Rice says:

    Back in the days of “Clippy”, the awful Microsoft paper clip, the WinBUGS team joked about the idea of adding a little pop-up professor (very much modeled on an R-help mailing list contributor) who would appear whenever you opened WinBUGS. Before you could use the software, he’d ask, with an air of irritation, questions like “what’s the conjugate prior for the Pearson Type 7 distribution?” or “what property does satisfying the detailed balance equations provide?”.

    Get them right and he went away, although only after a finger-wagging about first reading the manual. Give a wrong answer and you were *clearly* an incompetent liability, so for the general good of humanity the software would then automatically de-install itself, deleting all your WinBUGS files as it went.

    • Andrew says:

      Ken:

      In all seriousness, I very much appreciate the thousands of hours of unpaid labor put in by the R crew. If the occasional sarcastic response on the help list is the price we pay for getting so much useful free assistance, so be it. I enjoy joking about these things but these guys do so much that I don’t begrudge them their small foibles!

  10. K? O'Rourke says:

    Ken:

    Ken: He is a little less like that in person.

    But on a more serious note – it underscores the challenge of the less informed querying the more informed.

    For instance, I once asked a WinBUGS expert how one would discern the likelihood that was used in a WinBUGS analysis and they told me somewhat sternly it does not use likelihoods it samples from blah, blah (meaning I did not understand anything after the “does not use likelihoods”)

    If anyone is game – how should I have asked that question and what is the answer?

    • Ken Rice says:

      Keith,

      Indeed he is, and he gives excellent lectures and excellent advice, in addition to the occasional sarcastic response.

      If you have a question about WinBUGS (that’s not answered in the manual) then the Bugs mailing list is the place to go. It’s moderated; your query may be answered directly, or mailed out to the broader audience of list members. Its archives are also a good place to search for all things BUGS-ian. Also note that, if you want an answer, you’ll have to make your question a lot more specific.

      • K? O'Rourke says:

        Thanks Ken, but your answer to my for instance seems a bit _riply_ ;-)

        I have an answer that is satisfactory for my needs – but it might
        be an idea to see what answer I get on the Bugs mailing list.

        The real question was about mis-communication.

        • Ken Rice says:

          If you already have the answer (to your WinBUGS query, whatever it is) then please make this clear when you contact the Bugs list – or anyone else. In other words, say “I want to discuss X, which I already know is the answer to Y” and not “Please help me answer Y”.

  11. Nick says:

    A Google translate for code would be awesome. Imagine if you could teach it to output machine language. Then you could “Google Translate” from C++ to machine language instead of compiling! And if you translated Java to machine language, would it automatically give you Dalvik first? :)

  12. Nigel Goodwin says:

    I recently wanted to convert from Fortran to Java. My first attempt was to use a tool to convert Fortran to C, and then another tool for C to Java. One of these (I forget which) had been used for Lapack (or maybe Linpack) conversions.

    My conclusion – the first translation turned it into something incomprehensible, the second translation made it complete obfuscated.

    So I went back to doing it by hand, took a couple of weeks to test and debug.

    I remember way back in 1970′s using a structured Fortran pre processor, to convert into Fortran 66. Maybe what we need is a super language, which any algorithm can be written in (pseudo code?) and then different implementations can be generated. But I think an intermediate super language is necessary.