|
||
The Palindrome ProjectThis 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. Loading... About the Palindrome Project: an exercise in comparative linguisticsThis 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". Palindromes are not limited to letters, so numbers can be palindromes (e.g. "16461"). By the way, 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 my limited experience, many implementations may not be optimal or strictly idiomatic for the relevant language. 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. This page uses jQuery to do some dynamic layout magic. Syntax highlighting is done using SHJS - Syntax Highlighting in JavaScript. Check the comments at the top of each implementation for other relevant information and links. Many of the implementations can be run using either the Online IDE & Debugging Tool at ideone.com, or Try It Online (TIO). Steps:
Last updated: January 24, 2022 |
||