Five reasons to meet Rosetta

Rosetta Code is essential for developers for timestamping and much more

By Cameron Laird  Add a new comment

Timestamping played a big part in our programming this week. One of my responses was to do one of the things I often do: write a "crib sheet" on the subject, in this case something along the lines of:

    command.com:
        echo %DATE %TIME
        Thus 01/21/2010 13:52.55.95

    Perl 5.8.8:
        print scalar localtime(time), "\n";
        # Thu Jan 21 13:52:55 2010

    Python 2.4.4:
        print datetime.datetime.now().ctime()
        # Thu Jan 21 13:52:55 2010

    Tcl 8.5:
        puts [clock format [clock seconds]]
        # Thu Jan 21 13:52:55 CST 2010

    SQL (Oracle, MySQL, PostgreSQL):
        select CURRENT_TIMESTAMP [from DUAL]
        21-JAN-10 13.52.55.956733 PM +00:00
...

That's as far as I got before I had my, "It's no longer 1990! Maybe it is quicker to use what someone else has written" moment, and realized that Rosetta Code has already done the work.

You need to know Rosetta Code -- or, if like me, you sometimes don't think of it in the first two minutes of tackling a programming problem, you need to know it better. Rosetta Code styles itself as a programming chrestomathy, a refinement of my crib sheets. There are several such chrestomathies; Rosetta Code is the essential one for working programmers, though, as far as I'm concerned. It's the one that is useful for daily work.

Varieties of values

Timestamping makes a good example of one kind of benefit Rosetta Code provides. I'm big on measurement; while I trust my colleagues, I get "itchy" when one of us says, "slow", or "a few", or other such vernacular quantifiers. I relax better, particularly when we're making design decisions, after quickly coding a pertinent measurement.

Like most professionals, we work in a variety of different languages during any particular day. It's easy to grow a bit rusty on subtleties of rarely-used syntax ("in Texan, do you say, 'access road', 'frontage road', or ...?"), so I've long written personal chrestomathies to keep me on track.

It's rarely necessary, now, though! Although it has a few blemishes, Rosetta Code is generally more complete and correct than my own memory; the page that applies most immediately to timestamping, for example, improves on my Perl, and has the C, Java, Lua, and Erlang that I had in mind to write next, as well as dozens of others that we won't soon need. I was mildly surprised to see no entries for SQL, command.com, and /bin/sh--I'll need to log in later and add those.

In any case, this is the first great value of Rosetta Code: it supplies working code that serves as a useful model for a developer's daily needs.

I also recommend it in four other aspects:

  • It's simply good reading. Contributors to Rosetta Code are generally knowledgeable and literate, and Rosetta Code is interesting much as Wikipedia is, despite its far narrower ambition;
  • The high quality of the contributions as code, or at least as code-in-the-small, means that Rosetta Code is educational. Read through all the examples of a language you think you already know well: you're likely to pick up at least a few valuable idioms or techniques;
  • Comparison is important. When a particular concept--"pointers", say, or functions whose domain is other functions--in a particular language gives you problems, read about how other languages handle the same challenge. You're likely to gain insight into the idea behind the particular implementation before you, and its advantages and disadvantages;
  • Rosetta Code is a challenge and inspiration. If you're ever in the "I want to learn X, but don't know what to write" mode that afflicts some acquaintances, pick a corner of Rosetta Code, and see if you can fill it in or improve it.

Two ongoing themes of "Smart Development" are the pedagogic value of good reading, and how smart programmers take advantage of the resources available to them. Rosetta Code fits in both categories.

ITworld LIVE

DevelopmentWhite Papers & Webcasts

Webcast On Demand

How to Distribute Apps to Your Mobile Workforce

When considering enterprise app deployment, you may find some unexpected challenges and a number of options that range from simple distribution to running your own enterprise market. How can you determine the best approach for your organization? MOTODEV for Enterprise can help you understand and evaluate current enterprise deployment technologies and learn best practices that support your choice.

Sponsor: Motorola Mobility

Webcast On Demand

Authentication, Certificates and VPNs

MOTODEV for Enterprise can help get you up to speed quickly on key topics such as how to enable secure access to a company intranet from outside the firewall. This webinar provides a clear explanation of terms and technologies and what they can do for your enterprise app development.

Sponsor: Motorola Mobility

Webcast On Demand

Improving Enterprise App Quality with MOTODEV App Validator

MOTODEV for Enterprise supports quality app development for businesses, government, and institutions with technical resources and tools such as the MOTODEV App Validator, a free static analysis testing tool.

Sponsor: Motorola Mobility

White Paper

HR Analytics: Driving Return on Human Capital Investments

In today's economy, it's critical for organizations to make employee retention and development a major business focus, to ensure that valuable employees are not lost as the economy improves. With advanced BI solutions, organizations can be supported by workforce analytics to drive return on human capital investment and to see the value the workforce delivers to organizational performance. This white paper demonstrates how the increased power of having metrics and analytic insight can align core HR business processes with organizational goals and strategies and help ensure organizations make the right business decisions today for tomorrow.

White Paper

Positioning the CIO as a Powerful Business Partner with IT Portfolio Governance

In this whitepaper, learn how you can become a visionary portfolio manager and transform IT into a streamlined revenue and profit center.

See more White Papers | Webcasts

Ask a question

Ask a Question