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 > The Growing Clojure Ecosystem - A Data Structures Library and Mocking Facility

The Growing Clojure Ecosystem - A Data Structures Library and Mocking Facility

Mitch Pronschinske user avatar by
Mitch Pronschinske
·
Jun. 22, 10 · Java Zone · Interview
Like (0)
Save
Tweet
7.35K Views

Join the DZone community and get the full member experience.

Join For Free
As the JVM-languages continue to grow in popularity and deployments, some have speculated about the next 'heir to Java'.  Many believe that the programming world has evolved to a stage where platform is more important than language.  Nonetheless, there are a few languages, like Groovy and Scala, that are more popular than the other JVM-languages.  I would also bet that Clojure is going to join the Groovy/Scala echelon of popularity in the next few years.  Alex Miller and (Uncle) Bob Martin are two prominent developers who have found Clojure to be very useful.  The number of tools and frameworks for Clojure have grown rapidly as well.  I found two interesting Clojure projects that were posted on GitHub in just the last few months.  Here you'll find a description of each of them.

clj-ds

Karl Krukow loves Clojure, and he especially likes using the data structures.  Even though Clojure is distributed as a .jar, the structures work best within Clojure.  Since many clients require that he use Java, Krukow has authored a library that is able to capture some of the benefits of using Clojure data structures within Clojure.

clj-ds is not dependent on the Clojure runtime and does not run any Clojure bootstrap process, so calling certain methods on PersistentHashMap that require loading of the entire Clojure runtime will not cause delays for a Java user.  clj-ds will also support generics (Clojure doesn't have them) for the Java data structure library.

Clojure data structures are currently implemented in Java, but the language is moving towards being completely implemented in Clojure itself.  This could make the data structures even more inconvenient to use in a Java environment.  So the clj-ds project will maintain Java versions of the code.  

Other JVM languages such as JRuby, Groovy, Jython, Scala, or Erjang could benefit from Krukow's implementation. 

                          

Atticus

atticus.mock is an alternative approach to mocking where the mocked function can be implemented as an inline function to perform any checking or return value calculation.  The project currently has two macros to wrap the body of a mocked function.  One will verify that a function is called once, and the other will verify that a function is called a predetermined number of times.

The Once macro
;; define test, that should be called just once
(deftest mock-test
(atticus.mock/expects
[(f [arg]
(atticus.mock/once
(is (= arg 1) "Check argument")
arg))]
(is (= 1 (f 1)) "Call mocked function"))

Atticus includes this all Clojure mocking facility.  The project's author, Hugo Duncan, says that most of the mocking tools in Clojure reflect the Java mocking libraries and don't harness more of Clojure's dynamic capabilities.  Atticus follows the convention of implementing mocking by binding a function's var to a new function for the duration of the test.  Atticus also has new support for mocking protocols.

You can find hundreds of other Clojure-related projects on GitHub such as Leiningen, Compojure, and then there's jclouds, which wants to be the Clojure cloud library.
Clojure Data (computing) Library Java (programming language)

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Stupid Things Orgs Do That Kill Productivity w/ Netflix, FloSports & Refactoring.club
  • The End of the Beginning for Apache Cassandra
  • Why Performance Projects Fail
  • What Are Cookies in Servlets?

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