Follow Slashdot stories on Twitter

 



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:
  • But would you mind if I submitted it to Technocrat?
    • Not at all.

      My only concern is that it's on shared hosting through Dreamhost. But if it comes down to it, I've got people I can talk to to see about alternate hosting.
    • by Anonymous Coward
      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 the
      • by JoshJ ( 1009085 ) on Sunday January 21, 2007 @11:23AM (#17702504) Journal
        Right now it may be "pointless" for someone looking at it. It is certainly not "pointless" for contributing to it. Posting it to /. , technocrat, and similar means that it will get exposed to a lot of potential contributors.
        • Apparently, too many potential contributors.

          The steps are like this:

          1. build web hosting presence that will survive /.
          2. announce yourself on /.
          3. ???
          4. profit!

          It seems someone put #2 ahead of #1.
      • Re: (Score:3, Insightful)

        by Zadaz ( 950521 )
        Then add something.

        Whoops, my fault. Being a hater is easier.
      • Re: (Score:3, Insightful)

        It must have hit the front page.

        The whole idea of a wiki is for the community to build the content. The Rosetta Code is rather new, of course it's not complete. But it's a damned good idea, and deserves wider advertising so that the wiki will be filled!

        However, having said that, I agree, which is why I wasn't sure about firehosing this journal entry just yet. Better to let the professional FOSS experts at Technocrat have a crack at it first.
      • Re: (Score:3, Funny)

        by Reverend528 ( 585549 )
        I looked at the file I/O task, and there were no versions for ... Java

        Well, that would be pushing the limits of the MySQL LARGETEXT field.

    • Re: (Score:3, Interesting)

      by Dunbal ( 464142 )
      "In the 1980s capitalism triumphed over communism, In the 1990s it triumphed over democracy."

            And in the 2000's, it's well on the way to triumphing over common sense... with apologies to the author.
  • Whatever was keeping me out is either gone or something, but I have access now. Since I am attempting (yet again) to teach myself coding I am very excited about using the site and will be voting you up in the hose;-)
  • You're itchin' for a fight with Cupertino, is that it?

  • No Fair! (Score:5, Insightful)

    by Watson Ladd ( 955755 ) on Sunday January 21, 2007 @10:16AM (#17702038)
    A lot of the tasks assume imperative programing, e.x. assigning values to an array. This should be about algorithms that we can all implement, not code fragments that assume a particular style of programing.
    • That's what google or a good book are for. Even (bleh!) design patterns.

      Or programs that convert from one source language to another ...

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

      by Short Circuit ( 52384 ) * <mikemol@gmail.com> on Sunday January 21, 2007 @10: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:No Fair! (Score:5, Funny)

      by frakir ( 760204 ) on Sunday January 21, 2007 @12:02PM (#17702826)
      I program in Malbolge, you insensitive clod!
      http://en.wikipedia.org/wiki/Malbolge_programming_ language [wikipedia.org]

      I hope next windows ver will be coded in Malbolge and open source.
      • Re: (Score:3, Funny)

        by Dunbal ( 464142 )
        I hope next windows ver will be coded in Malbolge and open source.

              You mean it's not? ;)
      • Re: (Score:3, Funny)

        by nuzak ( 959558 )
        > I hope next windows ver will be coded in Malbolge and open source.

        If something's written in malbolge, I don't think it really matters if it's open source.

    • I disagree. I already can think in rather generic, algorithmic terms. If I'm suddenly backed against the wall to get a code from language A into language B, I'd want to see how the language mechanics worked ... whether its 'int' or 'integer', how functions get declared/called, how multidimensioned arrays are created/manipulated... etc. While it might be better to have a pocket reference for every language available on a desk somewhere, this sort of site means I might not have to bother even with a pocket re
    • You know...
      I have to agree with you ABSOLUTELY

      I am not a huge programmer (or at all really). Why then do I then feel empowered to talk?
      No, not because I am a Karma Whore^tm...

      I took 2 years of programming classes, and had only two teachers show me something useful. The first, Stephanie Bowe (awesome teacher) made relational database concepts very simple to understand. The second was never one of my programming teachers. He was my math teacher, Paul Smith (yes that's his real name. No he doesn't look lik
  • 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?

    There are also programs that can be compiled or run by several different compilers/interpreters: [nyx.net]
  • It may prove useful. (Score:4, Interesting)

    by Z00L00K ( 682162 ) on Sunday January 21, 2007 @10:22AM (#17702086) Homepage Journal
    But as a seasoned programmer I also know that some tasks can't be ported. A more efficient method is to actually resolve the problems at link time since most object files doesn't really care about which language you use. Some tasks are better off in one language than in another and porting the "problem" may prove a herculean task ending up as the major time-consumer for a project.

    Of course there are also cases when you will need to port the solution to a different language. This may be the cause when the project specifications requires a specific language like Ada.

    As with all programming; your mileage may vary.

    • by arevos ( 659374 ) on Sunday January 21, 2007 @10:38AM (#17702198) Homepage

      But as a seasoned programmer I also know that some tasks can't be ported. A more efficient method is to actually resolve the problems at link time since most object files doesn't really care about which language you use.
      If you look at the programming tasks [rosettacode.org] the website attempts to translate, you'll notice that they are extremely basic and generic. I don't think the aim of the website is to translate some complex library into another language; rather to provide a learning resource where programmers can see how to map simple tasks from one language to another, which presumably will help them better understand a new language. Remember that the original Rosetta stone was used for a similar purpose.

      This site could be useful, but MediaWiki doesn't seem the best tool to use, and the content so far is rather sparse. I'm uncertain whether this will prove a success; it's an interesting concept, but many interesting concepts have fallen by the wayside.
      • This site could be useful, but MediaWiki doesn't seem the best tool to use...

        Just out of curiosity, why not? And what would you suggest instead?

        • by arevos ( 659374 ) on Sunday January 21, 2007 @04:36PM (#17704926) Homepage

          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. 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.
          • Re: (Score:2, Informative)

            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

            • by arevos ( 659374 )

              In short, our Tables of Contents are automatically updated for us by the wiki engine. It's cool.
              Ah, I wasn't aware that MediaWiki could do that. Still... storing a cross-references on a Wiki page seems somewhat untidy to me. However, I can't think of any major practical disadvantages to the Wiki approach if cross-referencing languages to tasks is handled automatically, so it may be a reasonable solution despite my reservations.
    • But as a seasoned programmer I also know that some tasks can't be ported.
      That's when you invoke Greenspun's Tenth Rule [wikipedia.org]
  • Usage (Score:5, Insightful)

    by mgiuca ( 1040724 ) on Sunday January 21, 2007 @10:24AM (#17702094)
    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?)

    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.

    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.
    • Re: (Score:3, Informative)

      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 t

    • Re:Usage (Score:4, Insightful)

      by cp.tar ( 871488 ) <cp.tar.bz2@gmail.com> on Sunday January 21, 2007 @11:25AM (#17702524) 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?)

      But this kind of thing should be very good for someone learning a new language - you know how to do it in one language, now you're looking it up in another one... like learning the most common phrases first when learning a natural language.

      I hope this project will amount to something; it can be really useful.

  • if you like this... (Score:4, Informative)

    by taybin ( 622573 ) <taybin@tOOOaybin.com minus threevowels> on Sunday January 21, 2007 @10:24AM (#17702096) Homepage
    Also check out 99 bottles of beer [99-bottles-of-beer.net] and Hello World Collection [roesler-ac.de].
    • Re: (Score:2, Informative)

      by mgiuca ( 1040724 )
      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).
    • by Coryoth ( 254751 ) on Sunday January 21, 2007 @12: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: (Score:3, Interesting)

      by Dan East ( 318230 )
      As far as actual usefulness goes, the 99 Bottles of Beer site is worthless. The C version implements a Linux Kernel Driver! Now what's the point in that? Why not output to stdio? The C++ version doesn't even use OOP or implement a single class! It uses recursive templates and thus doesn't contain a single piece of runtime logic.

      However the real nail in the coffin is that the fundamental algorithm used to generate the song varies widely from one language to another, thus no real comparison between langu
      • The C++ version doesn't even use OOP or implement a single class! It uses recursive templates and thus doesn't contain a single piece of runtime logic.
        That's not stupid, it's awesome!
      • The real attraction of 99 Bottles of Beer ... and the reason it is so unhelpful if you just want to compare languages is that the examples often use exotic uses of the programming language in question. More a "lets use the weirdest way possible of writing this program that we can in the given language". So we see examples like, Java using no loops or ifs just throwing exceptions and printing stack traces to get the effect, or the C++ version doing it *all* in template meta-programming .... or my favourite t

  • by antifoidulus ( 807088 ) on Sunday January 21, 2007 @10:24AM (#17702098) Homepage Journal
    "How to bring a hooker back to life" Damn, I really neede....I mean, was interested in how you would do it in Perl, for curiosity's sake....
    • Re: (Score:3, Funny)

      by Anonymous Coward
      use Hooker::Transactional;

      Hooker::Transactional->get_last->rollback;

      Dude, CPAN has EVERYTHING! :)
    • I didn't know Ben Affleck [imdb.com] posted on Slashdot.
    • Re: (Score:3, Funny)

      by patio11 ( 857072 )
      >>
      I mean, was interested in how you would do it in Perl, for curiosity's sake....
      >>

      There's more than one way to do it.
    • Re: (Score:2, Funny)

      by Lord Ender ( 156273 )
      I mean, was interested in how you would do it in Perl, for curiosity's sake....

      • Hold down shift.
      • Mash the top row of your keyboard with your fist. You may also consider outsourcing this job to your cat.

      The Perl language was designed with genetic programming in mind. Any random combination of characters is executable Perl.
  • by Fulkkari ( 603331 ) on Sunday January 21, 2007 @10:28AM (#17702130)

    The site has absolutely no real content. There are only a couple of pages on the whole site. The most advanced thing found there is something along the lines of how to open a file with mIRC scripting [rosettacode.org] (no C/C++/Java) and that bash scripts (usually) start with #!/bin/bash [rosettacode.org]. Oh, please. Should I be impressed?

    • Oh, please. Should I be impressed?

      I think so: Somehow, inspite it's nothingness, it got on the frontpage of Slashdot.

      Then again, it is a Sunday, and yet the server got Slashdotted.
      • Re: (Score:3, Insightful)

        It got to the frontpage because its an interesting idea.
        The firehose will help with things like this.

        I agree it was empty and its implimentation feels flawed, but it gives a baseline for thoughts other people may be having.
        I know *I* have been thinking about this since I saw it and how it should/could be once filled.

        It gets a thumbs up from me.
  • Been Done (Score:3, Informative)

    by WED Fan ( 911325 ) <akahige@trashmaCOUGARil.net minus cat> on Sunday January 21, 2007 @10: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: (Score:2, Informative)

      by Inferger ( 1007151 )
      It's been done before in another program called XTRAN [pennington.com] too.
    • Re:Been Done (Score:4, Informative)

      by Zontar The Mindless ( 9002 ) <plasticfish@info.gmail@com> on Sunday January 21, 2007 @11:16AM (#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.)
  • I was looking for some code to help me load-balance a busy server that was just posted on Slashdot ... all I found was code for this old Applesoft BASIC wiki server.
  • New? (Score:2, Interesting)

    by d34d.10n ( 924456 )
    Although the idea seems nice, it still has a long way to go. The site currently only contains a few mIRC and bash scripts.

    Anyway, I'm looking forward to when it's filled with code from different languages.

    PS: an applet or an IDE plug-in like those from Koders [koders.com] would be really cool.
  • Nice idea, some concepts (string functions, (associative) arrays, file I/O) may be portable across some languages and in these cases rosettacode will be useful.

    But I think the actual problem is not given due value. Sometimes performing the same task in the same language requires different code on different platforms. Examples: Reading a file bigger than 4 Gigabyte in gnu-flavored C++ on mac, linux, windows; figuring out the total number of sectors on disk, etc.

    Also, we should accept that not all languages c
    • by Frumious Wombat ( 845680 ) on Sunday January 21, 2007 @12:26PM (#17703004)
      Years ago my copy of Kruse's "Data Structures" came with examples of how to do all the then-hip dynamic data structures (linked lists, trees, etc) in languages without pointers. This became useful when writing high-level Fortran-77 programs, as it allowed moving beyond Gomputed Goto and Arithmetic If for algorithms. In the same vein "Numerical Algorithms" (Teukolsky, Vettering, et al.) showed how to get decent array performance and add various oversights (such as complex numbers and complex arithmetic) to C-type languages.

      >>>I see this ending up as an effort to shoehorn concepts unique to one language to another language (building web sites in COBOL *shiver*).

      I once saw a series of cgi-bin routines written in Fortran-77 because that's what the web-site designer knew, and the schedule was too tight for her to learn Perl in time. (for those of you who started programming after compiled languages gave way to Python/Perl/Ruby/WombatCode6000, get a copy of G77, and try to compare two strings of different lengths) It's no big deal; given enough time one Turing-complete language can accomplish the same work as any other Turing-complete language. It's just the degree of pain you're willing to endure that's the limiting factor.

      As for the F77/cgi-bin programmer, She's a full professor now (though not in Comp. Sci, alas),
    • Re: (Score:2, Interesting)

      I wouldn't expect all tasks to be solved in all languages. For example, I wouldn't expect someone to solve the File I/O task in UDB DB2.

      I would expect to see an eventual segregation between things like database tasks and web development tasks. I simply haven't known enough about programming to collect the requisite data myself.
  • by aero6dof ( 415422 ) <aero6dof@yahoo.com> on Sunday January 21, 2007 @12: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]
  • I didn't look at the site (/. effect) but the Shootout [debian.org] sounds like a good place to get a list of tasks implemented in several languages. You even get arbitrary, but still usefull, metrics like the line-of-code count, run time and memory usage. If someone has time to waste coding trivial tasks in his favorite language, he should contribute to the shootout. I did and I must admit I got a kick when a few well placed suggestions cranked the performance of my entry [debian.org]. Today Common Lisp is faster than Pascal an
  • http://code.icarusindie.com/ [icarusindie.com]

    The tutorials there show how to do software rendering in Javascript, PHP, C++ and Java. In Javascript, C++ and Java it gets into advanced raycasting. All three languages have a wolf3d clone.
  • Once you get beyond syntax you start delving deep into the particular style of a language, which frustrates attempts to compare. A very good 'Rosetta stone' for programming languages already exists:

    http://merd.sourceforge.net/pixel/language-study/s yntax-across-languages/ [sourceforge.net]
  • But... (Score:3, Insightful)

    by Brandybuck ( 704397 ) on Sunday January 21, 2007 @02:06PM (#17703800) Homepage Journal
    But all Real Programmers know all languages! At least that's what Slashdot keeps telling me...

    AC: Stupid article, the guy could have used Haskell and solved his problems
    BB: But maybe he didn't know Haskell?
    AC: Then he deserves get fired!
    • by arevos ( 659374 )

      But all Real Programmers know all languages! At least that's what Slashdot keeps telling me...

      Whilst it's obviously an exaggeration to state that any experienced programmer is familiar with all computer languages, I feel I should point out than any programmer worth his salt should have a wide enough knowledge as to make learning a good proportion (if not the majority) of programming languages a fairly trivial task. Haskell is one of the exceptions, as it has a lot of features that are not found in many other languages. But most programming languages have a great deal of syntactical overlap, especia

      • An old saying: "Jack of all trades, master of none."

        This is true for programming as well. You can aquire a deep understanding of a few languages, or basic survival skills in dozens. Aquiring a deep understanding in dozens of languages is a truly exceptional feat.
        • Re: (Score:3, Insightful)

          by arevos ( 659374 )

          An old saying: "Jack of all trades, master of none."

          This is true for programming as well. You can aquire a deep understanding of a few languages, or basic survival skills in dozens. Aquiring a deep understanding in dozens of languages is a truly exceptional feat.

          I agree that it's difficult to acquire a deep understanding of most languages. One can study Java and all its related libraries and frameworks for years and still not learn it all. Indeed, my last job was as a Java programmer, and whilst I'm pretty familiar with several web frameworks, libraries and GUI toolkits, I have little knowledge about, say, the SecurityManager class, or J2ME, or JMS.

          But on the other hand, I disagree that a deep understanding of a single language is more useful than a working knowle

  • Forbidden

    You don't have permission to access / on this server.

    Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.

    So much for THAT idea...courtesy of /.
  • While you wait (Score:2, Informative)

    by CCFreak2K ( 930973 )
    for the site to come back, you can use this [wikibooks.org].
  • by the_greywolf ( 311406 ) on Monday January 22, 2007 @03:13AM (#17708546) Homepage

    That's one thing I want to see rewritten in several different languages.

    Just so I can make sense of the damn thing and I won't look at my call to ITPLBV() and wonder, "What the fuck does THAT do?"

  • PLEAC (Score:2, Informative)

    by meiao ( 846890 )
    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.
  • I read somewhere that Microsoft actually has an internal version of SourceSafe that does, in fact, attempt to treat VB.net and C# as two different presentation layers of the same underlying code, and allows you to work on a file using whichever of the two languages you prefer. In other words, two developers can check out the "same" code from the repository -- one, as VB.net, the other, as C#. If #1 commits changes, VSS semi-compiles it to intermediate code and treats the VB.net code as nothing more than a p
  • This idea makes sense, (even if the site sounds like it's empty and poorly designed), but only if you are comparing similar languages. For web scripting, I learned PERL first, and recently made the switch over to PHP for most of my new website stuff. Due to the old stuff still needing periodic work, I'm constantly going back and forth between the languages, and a cheat sheet showing me the syntax diffrences and basic fundamentals is invaluable for me.

    Even if this site was fully fleshed out, you would stil
  • While I haven't been able to take a look at the Rosetta Stone project, it seems like it might be similar in spirit to the Code Codex [codecodex.com].

Solutions are obvious if one only has the optical power to observe them over the horizon. -- K.A. Arsdall

Working...