Newsletter sign-up
View all newsletters

Enterprise Java Newsletter
Stay up to date on the latest tutorials and Java community news posted on JavaWorld

Sponsored Links

Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs

Ruby, Clojure, and Ceylon: Same goal, three very different results

Charles Nutter, Rich Hickey, and Gavin King each discovered that 'simplicity' doesn't mean the same thing

  • Print
  • Feedback

Page 2 of 2

 (describe String (named "last"))

He said that code could be "simplified" in Clojure to:

(->>
   (reflect java.lang.String)
   :members
   (filters
        #(.startWith (str (:name %)) "last"))
   (print-table)
)

Initially, the latter appears more complicated. To the uninitiated, it is at least harder to read. However, it introduces the least number of new concepts to the language. In the words of Clojure's Hickey, "Simplicity means lack of entanglement. For a programming language, it means delivering abstractions and mechanisms that each do one thing well, and can be composed as needed." The first example cannot be composed at all.

King explains that "we read code a lot more often than we write it, so readability is the most important criteria for judging the syntax of a language. A programming language is for communicating algorithms to humans." If you're familiar with Java, Pascal, C#, or any of the other widely used higher-level languages, the syntax of Ceylon or Ruby will probably be more readable to you. If you come from a more mathematical background, I believe Clojure will be an easier fit. Indeed, when writing software that is heavily algorithmic in nature, Clojure's syntax looks brief and relatively clear.

Choose your preferred version of simplicity

King and Hickey agree that removing complexity is a goal. King views his job as being the "nasty ogre who says no all the time," trimming unneeded features and syntax. Hickey believes that "we can build better software using significantly simpler constructs and techniques, with a corresponding reduction in complexity and increase in robustness."

At first, it surprised me that each language's creator directly or indirectly identified simplicity as his goal, as well as how differently the three creators and their languages' communities define what simplicity is. For Ruby, it is about a language that feels natural and gets out of your way to do what you want. For Clojure, it is about keeping the language itself simple. For Ceylon, it is a compromise between enabling the language to help, in King's words, "communicating algorithms to humans" and providing proper tooling support: the same general goal, three very different results.

I've found the Ruby, Clojure, and Ceylon communities all very friendly and approachable. Developers looking to pick up a new skill cannot go wrong trying one of these on for size. Managers looking to find a better fit for some of their software problems that just don't fit Java or C# will find help in these communities, as well. Ruby, Clojure, and Ceylon can all be used on the Java platform with existing APIs, so you can easily choose to mix and match the vision of simplicity that suits your problem space. But this polyglot language architecture may create its own form of complexity.

This article, "Ruby, Clojure, and Ceylon: Same goal, three very different results," was originally published at InfoWorld.com. Follow the latest developments in business technology news and get a digest of the key stories each day in the InfoWorld Daily newsletter. For the latest business technology news, follow InfoWorld on Twitter.

About the author

Andrew C. Oliver is a professional cat herder who moonlights as a software consultant. He started programming when he was 8 and cut his teeth on GW Basic, BASICA, and dBase III+. He is most known for founding the POI project, which is now hosted at Apache. He also was one of the early developers at JBoss before it merged with Red Hat. He is a former board member and current helper at the Open Source Initiative. He is president and founder of Open Software Integrators, a professional services firm with offices in Durham, N.C., and Chicago, Ill.
  • Print
  • Feedback

Resources