Ruby, Clojure, and Ceylon: Same goal, three very different results
- 14 June, 2012 10:09
Computer languages reflect the goals, target audiences, and to some degree the personalities of their creators and their communities. As a result, even languages that are created with similar goals in mind may yield highly disparate final results, depending on how their communities understand those goals. Ruby, Clojure, and Ceylon are three such languages.
Ruby is the oldest of the three. Created in the mid-1990s, it didn't achieve widespread popularity until the 2000s. One reason for Ruby's growth is the work of Charles Nutter, who created jRuby, a port of Ruby to the Java virtual machine (JVM). Ruby is a dynamic, object-oriented language, whereas Clojure and Ceylon use a functional programming approach.
[ InfoWorld's Paul Krill has interviewed the fathers of 9 modern programming languages; read the key excerpts from each. | Follow the latest issues in software development with InfoWorld's Developer World newsletter, and get Java users' tips from JavaWorld.com. ]
Clojure appeared in 2007, created by Rich Hickey. Although Clojure is new, it's a derivative of Lisp, the listy processing language specified in 1958, making it the second-oldest high-level language. Then there's Ceylon (the brainchild of Galvin King, the creator of the Hibernate ORM framework), which is on its second milestone prerelease.
In interviewing Ruby's Nutter, Clojure's Hickey, and Ceylon's King, I was surprised at how -- despite ending up with vastly divergent outcomes -- they share common goals and viewpoints. Each believe their language is designed to simplify the job of the developer, yet the approaches they each take toward achieving that simplicity vary wildly.
A key idea behind Ruby is to "feel as natural as possible, so you can do powerful things with Ruby but it doesn't get in your way," Nutter says. On the other hand, it "does not limit you to programs and development styles that fit into a strict statically typed world."
Ceylon, Nutter says, aims to be "an evolutionary 'better Java' that doesn't try to take a revolutionary leap forward (Scala) or completely change paradigms (Ruby)." Its creator, King, seems to agree; he considers "Ceylon to be an alternative to Java that interoperates well with Java." Ceylon focuses more on tooling and is itself developed using the Ceylon IDE. Due to their dynamic nature, "you'll never ever find a tool like Ceylon IDE for a language like Ruby, Python, or Smalltalk," he says.
Clojure's simplicity at first may appear more complexClojure is the most unique of the three. The syntax for Lisp was heavily influenced by lambda calculus (PDF). Like Ruby, Clojure is dynamically typed, but where Ruby is a more nominally imperative object-oriented programming language, Clojure is functional. Hickey's idea of simplicity doesn't exactly match up with King's and Nutter's. Clojure aims to remove "self-inflicted complexity derived from their programming languages, approaches, and tools," Hickey says.
Clojure's simplicity is fundamentally different from that in Ceylon or Ruby. The best way to understand Clojure's simplicity is by an example. Stuart Halloway, who runs a consulting company down the street from me, recently gave a talk to the New York City Clojure User's Group and provided a code sample of Clojure reflecting on the java.lang.String class and printing out members named "last":
He said that code could be "simplified" in Clojure to:
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 simplicityKing 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.
Read more about application development in InfoWorld's Application Development Channel.
Philip's 'smart' lightbulbs hit Australia
Philip's 'smart' lightbulbs hit Australia
Bitcoin finding its feet at first Silicon Valley conference
Australia lags Mongolia in Internet speeds
Salesforce.com to buy Clipboard, shutting down service