Clojuratica
  • Home
  • Intro
  • Tutorial
  • Get
  • License
  • Community

An Interface Between Clojure and Wolfram Mathematica

Note: Clojuratica is not maintained (but reports are it still works - source in the GitHub repo).

What is Clojuratica?

Clojuratica brings together two of today's most exciting tools for high-performance, parallel computation.

Clojure is a new dynamic programming language with a compelling approach to concurrency and state, exciting facilities for functional programming and immutability, and a growing reputation for doing all the right things. Wolfram Mathematica is one of the world's most powerful integrated tools for numerical computation, symbolic mathematics, optimization, and visualization and is built on top of a functional programming language of its own.

By linking the two:
  • Clojuratica lets you write and evaluate Mathematica code in Clojure with full syntactic integration. Now Clojure programs can take advantage of Mathematica's enormous range of numerical and symbolic mathematics algorithms and fast matrix algebra routines.
  • Clojuratica provides the seamless and transparent translation of native data structures between Clojure and Mathematica. This includes high-precision numbers, matrices, N-dimensional arrays, and evaluated and unevaluated Mathematica expressions and formulae.
  • Clojuratica lets you call, pass, and store Mathematica functions just as if they were first-class functions in Clojure. This is high-level functional programming at its finest. You can write a function in whichever language is more suited to the task and never think again about which platform is evaluating calls to that function.
  • Clojuratica facilitates the "Clojurization" of Mathematica's existing parallel-computing capabilities. Mathematica is not designed for threads or concurrency. It has excellent support for parallel computation, but parallel evaluations are initiated from a single-threaded master kernel which blocks until all parallel evaluations return. By contrast, Clojuratica includes a concurrency framework that lets multiple Clojure threads execute Mathematica expressions without blocking others. Now it is easy to run a simulation in Clojure with 1,000 independent threads asynchronously evaluating processor-intensive expressions in Mathematica. The computations will be farmed out adaptively and transparently to however many Mathematica kernels are available on any number of processor cores, either locally or across a cluster, grid, or network.
Clojuratica is open-source and targeted at applications in scientific computing, computational economics, finance, and other fields that rely on the combination of parallelized simulation and high-performance number-crunching. Clojuratica gives the programmer access to Clojure's most cutting-edge features--easy concurrency and multithreading, immutable persistent data structures, and software transactional memory (more on Clojure)—alongside Mathematica's easy-to-use algorithms for numerics, symbolic mathematics, optimization, statistics, visualization, and image-processing (more on Mathematica).


News

11/22/09: Version 2 alpha 2 was released today. Added is the evaluator flag :N (and corresponding flag :no-N). Like the Mathematica function N, it stands for numeric. When enabled, the flag speeds up by a factor of 10 the Mathematica-to-Clojure parsing of homogeneous numeric lists (and multidimensional arrays). The trade-off is that the contents become doubles. The flag affects what would otherwise become Clojure vectors/seqs of integers, doubles, bigints, and bigdecimals; these are all cast to vectors/seqs of doubles. Vectors/seqs of rationals (Clojure ratios) are unaffected by the flag and receive neither casting nor speedup.

11/20/09: Version 2 alpha 1 was released today! Please see Intro for more information. Yes, we skipped 1.x. With the new syntactic integration and complete rewrite it seemed right to commemorate the release with a full increment.

8/22/09: Clojuratica v0.96 was released today. The software is now feature-complete for v1.0. Standout improvements in this release:
  • Full Mathematica interface to Clojure. Call Clojure from Mathematica with seamless data-type translation.
  • First-class Mathematica functions in Clojure. Write Mathematica functions and call them in Clojure as though they were Clojure functions. The evaluation is handled transparently by Mathematica. Parallelization of the function calls is automatic and transparent.
  • Greatly improved internals. Better data structure handling. Data-type translation is many times faster than before. Parallel computation queue is lightening fast.
  • Rewritten Tutorial covering all features.

8/02/09: Clojuratica v0.91 will be released later this week. The GitHub repository already contains most of the new features, for those ambitious enough to brave it without documentation.

7/27/09: Clojuratica v0.9 was released to the Clojure community. Suggestions are welcome!

More On Clojure

It has been said that Clojure feels like a programming language beamed back from the near future. It is well suited to "concurrency-oriented programming," a new paradigm brought on by the proliferation of multicore machines and high-performance computational clusters.
  • Like Perl, Python, and Ruby, Clojure is a dynamic programming language. It facilitates fast and flexible program development.
  • Like Haskell, ML, and Lisp, Clojure is a functional language. Its rich, immutable data structures are persistent, allowing for all the benefits of functional programming without performance bottlenecks.
  • Clojure is a dialect of Lisp. It shares Lisp's code-as-data philosophy and offers a powerful macro system. These features make it especially expressive.
  • Like JRuby, Jython, and Groovy, Clojure offers seamless interoperability with Java. To an even greater extent than those languages, it offers the speed of pure Java bytecode. It runs on the JVM and is therefore inherently cross-platform.
  • Like Erlang, Clojure is designed for lockless concurrency, making Clojure programs quickly scalable to thousands of CPU cores. Clojure's immutable data structures discourage mutating state, eliminating the need for locking in most cases. For cases where mutable state is necessary, Clojure offers built-in software transactional memory (STM), the first general-purpose language to do so.
There is a terrific set of video introductions to Clojure by Rich Hickey, Clojure's creator. Another excellent, shorter, less philosophical, and more to-the-point set of video introductions is available on YouTube. Programming Clojure is Stuart Halloway's excellent book on the language.

More On Mathematica

Wolfram Mathematica is perhaps the most powerful piece of software available today for numerical and symbolic mathematics, optimization, data visualization, and data analysis.
  • Like MATLAB — but to a greater extent — Mathematica provides a broad collection of built-in routines for linear algebra, matrix decomposition, symbolic mathematics, optimization, differential equations, symbolic and numerical integration, Fourier analysis, 2D and 3D visualization, image and photo manipulation, exploratory data analysis, probability and statistics, graph theory, number theory, geodesy, and access to the Wolfram Research internet data feeds on finance, chemistry, geometry, meteorology, astronomy, protein structure, and the human genome.
  • Mathematica is fast. The speed of its algorithms across all domains match those of numerical libraries for compiled languages. Meta-algorithms for automatic algorithm selection increase performance and make it possible to focus on the task at hand rather than the algorithm used (the programmer retains the option to override automatic selection).
  • Like Clojure and other Lisps, the Mathematica language is a functional language. It supports pure functions. Like Lisps, Mathematica is homoiconic (compare Mathematica expressions with Lisp S-expressions). The bottom line: thinking in Mathematica is very similar to thinking in Clojure.
  • Mathematica has built-in parallelization capabilities. It is easy to build programs that take advantage of multiple coordinated kernels running on multiple processor cores. It is equally easy to distribute computations across a cluster or grid. The Mathematica kernel, however, is designed for single-threaded applications. Clojuratica fixes this.
  • Mathematica can produce stunning visualizations and charts. It supports integrated image-processing that rivals that of Adobe Photoshop.
  • Mathematica provides free, seamless, over-the-internet access to massive databases in areas as diverse as genomics, chemistry, astronomy, geopolitics and geography, and finance.

Author

Clojuratica was created by Garth Sheldon-Coulson, a graduate student at the Massachusetts Institute of Technology and Harvard Law School. See the Community page to find out how to contribute to Clojuratica, suggest features, report bugs, or ask general questions.

Legal

The product names used in this web site are for identification purposes only. All trademarks and registered trademarks, including "Wolfram Mathematica," are the property of their respective owners. Clojuratica is not a product of Wolfram Research. The software on this site is provided "as-is," without any express or implied warranty.
Powered by Create your own unique website with customizable templates.
  • Home
  • Intro
  • Tutorial
  • Get
  • License
  • Community