Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!

 



Forgot your password?
typodupeerror
×

Building a Programmer's Rosetta Stone 215

Did you ever run into the problem where you knew how to do something in one programming language, but really needed to do it in another? That's what Rosetta Code is all about. A variety of programming tasks are solved using as many languages as possible. You can examine existing tasks, or create your own.
This discussion has been archived. No new comments can be posted.

Building a Programmer's Rosetta Stone

Comments Filter:
  • by Marxist Hacker 42 ( 638312 ) * <seebert42@gmail.com> on Friday January 19, 2007 @01:38PM (#17683338) Homepage Journal
    Posted to Technocrat.net- as I'm "semi-paid contributing editor" there, it hit the front page immediately of course.
  • if you like this... (Score:4, Informative)

    by taybin ( 622573 ) <taybin@taybi n . c om> on Sunday January 21, 2007 @11:24AM (#17702096) Homepage
    Also check out 99 bottles of beer [99-bottles-of-beer.net] and Hello World Collection [roesler-ac.de].
  • by mgiuca ( 1040724 ) on Sunday January 21, 2007 @11:30AM (#17702136)
    Another great one: HanoiMania [kernelthread.com]. 111 solutions to the "Tower of Hanoi" [wikipedia.org] recursive problem, some in very creative and bizarre environments (as outlined in the summary at the top).
  • Been Done (Score:3, Informative)

    by WED Fan ( 911325 ) <akahige@tras[ ]il.net ['hma' in gap]> on Sunday January 21, 2007 @11:37AM (#17702192) Homepage Journal

    It's already been done. Planet Source Code [planetsourcecode.com] does this already, and it's been around for ages. You can find code examples and complete projects.

    Then for projects in the .NET set there are a number of online translators that do C#VB.NET. Very good for moving code between different types of projects.

    Now, something that would be truely useful would be a service that would do translations from a wider variety languages.

  • Re:No Fair! (Score:5, Informative)

    by Short Circuit ( 52384 ) * <mikemol@gmail.com> on Sunday January 21, 2007 @11:48AM (#17702236) Homepage Journal
    I would be happy to see other types of programming represented in Rosetta Code. I only included what I already knew. Rosetta Code should be about many things I don't already know. Once the server's no longer slashdotted, stop by blog.rosettacode.org [rosettacode.org], and I'll make a point to bring up how to add your own programming tasks. (Really, you just have to add a template to the top of of the page. But there are some guidelines.)
  • Re:Been Done (Score:2, Informative)

    by Inferger ( 1007151 ) on Sunday January 21, 2007 @11:57AM (#17702304)
    It's been done before in another program called XTRAN [pennington.com] too.
  • Re:Erm... (Score:3, Informative)

    by lexarius ( 560925 ) on Sunday January 21, 2007 @12:03PM (#17702342)
    Apple, which currently has a product called Rosetta, which allows PPC code to be executed on Intel chips by translating it dynamically or something.
  • Re:minus 4, T8oll) (Score:2, Informative)

    by Short Circuit ( 52384 ) * <mikemol@gmail.com> on Sunday January 21, 2007 @12:03PM (#17702350) Homepage Journal
    I had to get it started. My hope is that other people will contribute with languages (and tasks) that they know.
  • by Anonymous Coward on Sunday January 21, 2007 @12:14PM (#17702422)
    Did you even bother looking at the site first? Perhaps not as it's slashdotted. The idea isn't bad, but it's just a nearly empty wiki. Not many languages, and looking at some tasks, most of the stuff wasn't very useful. For example, I looked at the file I/O task, and there were no versions for C, C++, Java, C#, VB (not that I'd want that), PHP (idem) nor anything like that - but there was a mIRC scripting version...

    Might be worth posting somewhere once there's actual useful content, but just not now.

    But then again, I'm sure the editors didn't even look at it either before posting. There's nothing news worthy or interesting there - yet.
  • Re:Usage (Score:3, Informative)

    by Short Circuit ( 52384 ) * <mikemol@gmail.com> on Sunday January 21, 2007 @12:16PM (#17702440) Homepage Journal

    I'm not sure the right idea is to "know how to do something" in a particular language. If programmers are encouraged to learn algorithms specific to a particular language, how will they ever adapt once their pet language sinks? (By using an algorithm repository to re-learn rote code?)
    Rosetta Code was largely inspired by a page on Wikipedia where the classic "Hello World" example was shown in a few hundred languages.

    Rosetta Code takes the concept behind Hello World, and spreads it to other tasks.

    At any rate, I think this site has already encountered a problem which is only going to escalate as it grows: code isn't cross-indexed properly at all. For example, there are many "programming tasks" with solutions in C, but there is nothing on the C page. I think this problem stems from the fact they used MediaWiki.
    Actually, this is (almost) intentional. I want people to be able to learn about the languages they're using. I've been filling in the pages as I've had the opportunity. (I'm a full time college student, and president of a student organization.) Check the page on GCC, for example. [rosettacode.org]

    MediaWiki's great for something like... well, Wikipedia. But it doesn't support a cross-referenced database like this. The wiki concept is good for this site, but the server needs to be running some software designed better to the task.
    I'm open to suggestions. (And assistance, if it'll go that far.)
  • Re:Been Done (Score:4, Informative)

    by Zontar The Mindless ( 9002 ) <plasticfish.info@ g m a il.com> on Sunday January 21, 2007 @12:16PM (#17702442) Homepage
    Planet Source Code is not that hot. There's heaps of trivial examples that just aren't done very well - like a "new" PHP4-style class for connecting to MySQL which hard-codes "localhost" for the server name. I guess the guy hasn't heard of mysqli [php.net]?

    The quality of the writing itself is pretty bad, too. People who are purporting to teach you something ought to be a bit more... well... literate.

    Neither am I inclined to be overly impressed when a site throws 175+ JavaScript and CSS errors in Firefox in just the first 2-3 pages. (I didn't bother counting the errors after that point.)
  • by aero6dof ( 415422 ) <aero6dof@yahoo.com> on Sunday January 21, 2007 @01:06PM (#17702858) Homepage
    Sourceforge has hosted to Programming Language Examples Alike Cookbook project for a while now. It does something similar, filling out "Perl Cookbook" recipes for a fairly wide range of languages...

    http://pleac.sourceforge.net/ [sourceforge.net]
  • by Coryoth ( 254751 ) on Sunday January 21, 2007 @01:32PM (#17703038) Homepage Journal
    Also worth looking into is LiteratePrograms [literateprograms.org] which provides a wide range of algorithms written (and documented - hence the "literate" part) in a wide variety of languages. Currently there are over 50 different "Hello World" programs in different languages, including such things as AliceML, AspectJ, Haskell, and Oz, as well as all the usual suspects. More to the point, it also includes a decent variety of more interesting algorithms, including basic sorting algorithms (quick sort, merge sort etc.) in a wide variety of languages, right the way up to a basic GUI file manager in GTK. It's a Wiki, and still growing, but it seems to be well ahead of RosettaCode at the moment.
  • Re:Nice idea, but (Score:3, Informative)

    by multipartmixed ( 163409 ) on Sunday January 21, 2007 @08:33PM (#17706344) Homepage
    Your thinking around loops actually shows (to me, anyhow) why these Rosetta-stone-type projects are actually counter-productive in the long run. (I can also argue that using cross-language keywords is also poisonous).

    Why?

    Your C-language for-loop example uses the same crappy example as nearly every crappy text of the "learn C in 7 days [assuming you already know BASIC)" genre. Giving the first example this way --- as "a for-loop is something that counts, here's how you make it count" is ... so... bogus. And serves to completely POISON programmers' minds. I can't BEGIN to count how many programmers I've met who are confused about basic for-loops in C because they think they have to count.

    A for loop in C is simply the exact, beautiful, expression of the iteration concept:

    for (LOOP_INITIALIZER; LOOP_INVARIANT; PROPELLER)
    {
      EXPRESSION;
    }
    See? Has nothing to do with numbers.

    You're saying: execute LOOP_INITIALIZER, evaluate LOOP_INVARIANT, if it's true, perform EXPERSSION, evaluate PROPELLER and go back to the part of this sentence where we evaluated LOOP_INVARIANT.

    Because of this craputidinous teaching, I am constantly faced with programmers who cannot understand a loops of these types:

    for (a = arr; *a; a++)
      do_shit();
     
    or
     
    for (a = db_get_stuff(); a; a = db_get_more_stuff())
      do_shit();
     
    or even
     
    for (a = fgets(file, line, sizeof(line); a && !ferror(file); a = fgets(file, line, sizeof(line))
      do_shit();
    ...and these people have freakin' degrees in computer science. That final (contrived) example, BTW, is a fine way to avoid doing stupid shit like

    do
    {
      a = fgets(file, line, sizeof(line);
      if (a)
      do_shit();
    } while(a && !ferror(file));
    .... So: Why is the for-loop superior in every way to this while loop example?

    Look carefully.

    Loop control in the for statement is on the same line of code as the loop-construct keyword. In the above while-statement, loop control is at the beginning, middle, and end of the block. That's just BEGGING for a maintainer error. Yet 99 out of 100 C programmers prefer the second form... because it looks more like BASIC... they don't understand the beauty of the for-loop... they simply think ("Oh, I don't have any numbers to count, so I'd better use a while-loop"). That's CRAP! It's broken thinking, and it encourages buggy programs.

    It all comes down to people teaching to the lowest common example [denominator], rather than actually exploring the concepts behind the language.
  • by Short Circuit ( 52384 ) * <mikemol@gmail.com> on Sunday January 21, 2007 @09:26PM (#17706656) Homepage Journal

    Just out of curiosity, why not? And what would you suggest instead?
    A Wiki is essentially just an editable website. It must be manually ordered; tables of contents put in, pages linked to other pages, and so forth.
    I make use of as many MediaWiki features as I know how. There's one template for programming languages, one for compilers, one for interpreters, one for programming tasks, etc. Adding the template to a new page automatically adds the page to the related category, and the category index pages are the primary tool for browsing the site.

    In short, our Tables of Contents are automatically updated for us by the wiki engine. It's cool.

    This is find for data that has a very general structure, such as an encyclopaedia or a manual of some kind. But the Rosetta Stone concept is highly structured, cross-referencing programming languages with programming problems, and it seems to me as if this cross-referencing would be better done automatically, rather than making several Wiki pages and maintaining them manually. The site concept would be better suited to some sort of customised CMS, or perhaps something designed from scratch.
    The benefit of using a wiki, and why I chose to use it, is that in each of these intermediary pages, one can place descriptive information about the relationship. The net effect is that an encyclopedia forms around the structured data. This has only happened in a couple places, such as the page about LAMP, and the page about GCC, but it's something I want to see continue.

  • While you wait (Score:2, Informative)

    by CCFreak2K ( 930973 ) on Sunday January 21, 2007 @10:20PM (#17706966) Homepage Journal
    for the site to come back, you can use this [wikibooks.org].
  • PLEAC (Score:2, Informative)

    by meiao ( 846890 ) on Monday January 22, 2007 @07:47AM (#17709198) Homepage
    There is the PLEAC (Programming Language Examples Alike Cookbook) which uses (or should use) the same examples for many programming languages.

    Many languages are close to complete the provided examples.

2.4 statute miles of surgical tubing at Yale U. = 1 I.V.League

Working...