The Palindrome Project
This page is a compilation of Palindrome checkers implemented in various programming languages. To view a particular implementation, choose a language from the drop-down select list below. The page should be updated to display the source code for the chosen language, with syntax highlighting applied. A second drop-down can be used to choose another language implementation to display in a separate window. More details about the project appear at the end of the page.
About the Palindrome Project: an exercise in comparative linguistics
This page brings together the results of a little hobby that's been developing slowly over the past few years whenever I found some spare time: solving a straight-forward problem in a variety of different programming languages. The problem is a staple in university computer science courses, namely to determine if a string is a palindrome. Example palindromes include: "A man, a plan, a canal: Panama!" and "Madam, I'm Adam". In fact, when I started learning Java, one of the first programs I wrote was a rewrite of a palindrome detector originally written in Ada for a Uni assignment. That approach used recursion to successively compare characters at each end of the string, from the outside in.
For this project I've chosen a different approach, which may suit some programming languages better than others. Here's the outline for the general approach used in all the example programs:
Where possible I've conformed to the idioms and conventions of each language. To help comparison of implementations, I've tried to use the same key variable names (e.g. for the intermediate strings in the outline above), even if camelcase is not typical for all languages. Given limited experience, many implementations are probably not optimal.
The languages span several decades of computer programming history. Most of the major paradigms are represented: procedural, object-oriented, functional, logic-based, stack-oriented and array-based. There's a mix of compiled and interpreted, static and dynamic, specific- and general-purpose, and several that are considered hybrid or multi-paradigm languages.
To browse an implementation, choose a language from the drop-down select list provided. The page should be updated to display the source code for the chosen language, with syntax highlighting applied. To aid comparison with other languages, a second drop-down select list is available for choosing another language. Just pick a different language, click on the "Compare" link, and its implementation will be displayed in a new window.
Many of the implementations can be run using the Online IDE & Debugging Tool at ideone.com. Steps:
Last updated: February 14, 2011