DZone
Java Zone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > Java Zone > One Night With Clojure Makes a Scala Guy Humble

One Night With Clojure Makes a Scala Guy Humble

Wille Faler user avatar by
Wille Faler
·
Aug. 10, 11 · Java Zone · News
Like (4)
Save
Tweet
85.67K Views

Join the DZone community and get the full member experience.

Join For Free

I do most of my work these days in Scala, but I have long been curious about Clojure, partly because of the mythology around Lisp and it’s potential superior productivity and possibility of self-generating code (Clojure is a Lisp dialect).

I’ve been reading about Clojure from time to time, tried little snippets from time to time, but never made any serious efforts to get deep into the language. On Sunday I took the plunge in rewriting a small, but important payments application I have had running in production for a few years in different guises. This was the third incarnation of the app, the first one was in Java from 2008, second in Scala from 2009, and now this, I still have the codebase of all three apps, so I could contrast and compare the results.

A simple metric generated with cloc, namely Lines of Code really blew me away about Clojure:

  • Java version: 755 lines of code (LOC)
  • Scala version: 419 LOC’s*
  • Clojure version: 57 LOC’s

Yup, that’s right, the Clojure version is more than 10 times less code, and about 7-8 times less than it’s Scala equivalent. In fairness though, the Scala number is a bit misleading: it was written before I got really familiar with Scala, and could probably be condensed to about 150-200 LOC’s. But still, it seems Clojure has a 3-4x advantage on even Scala.

Clojure Impressions
At first, the LISP syntax of Clojure looks bewildering to say the least for someone originating from a non-Lisp background. However, once you get your head around the basics and the basic forms, it is actually both very simple and compact at the same time. My guesstimate is that it would be a lot quicker to master Clojure than it would be to master Scala if you started today.

Using Clojure was a humbling experience, I’m certainly looking forward to doing more things in Clojure going forward. I strongly suspect my company will become a mixed Scala/Clojure “shop” as time goes on and I find the sweet spots for the different languages.

I’m not going to go and say that “Clojure is better than Scala” - I think they are both excellent languages, and I don’t really have a strong preference, other than looking forward to do more in Clojure as and when I find reasonable sized things to do to learn more (especially before making definite statements on pros and cons). 

If you have yet to seriously check out Clojure, I strongly suggest that you do! The first few hours may be frustrating and bewildering (you have been warned), but once you get over it, it is worth the effort. If you’re looking for a good build system, Leiningen seems to be it, which certainly works better and simpler than something like Maven. There are a number of books available on Clojure, and this tutorial seems a good start for beginners as well.

Oh, and my new Clojure app went into production the same day I started writing it.

Clojure Scala (programming language)

Published at DZone with permission of Wille Faler, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • The 5 Healthcare AI Trends Technologists Need to Know
  • What Is ERP Testing? - A Brief Guide
  • Migrating From Heroku To Render
  • APIs Outside, Events Inside

Comments

Java Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo