Code Monkey home page Code Monkey logo

multimethod-experiments's Introduction

multimethod-experiments

Clojars Project

This repository is intended as something like reproducible research, to document in detail what led to 2 libraries:

  • faster-multimethods: a faster backwards-compatible alternative to the Clojure 1.8.0 implementation,

  • dynamic-functions: not backwards compatible, more restricted than Clojure multimethods, but faster still.

Clojure provides about a dozen competing variations on 'object-oriented' or 'polymorphic' functionality, including: definterface, defmulti/defmethod, multi-arity defn, defprotocol, defrecord, defstruct, deftype, gen-class, reify, and proxy. See Chas Emerick's Flowchart for choosing the right Clojure type definition form for a comparison and evaluation of when to use which. (Note that it doesn't include defmulti/defmethod.)

Of the non-deprecated ones, defmulti/defmethod seems to one of the least used (though I have no hard data for that). This may in part be due to the general advice on the web, which is to use defprotocol rather than defmulti, because defmutli is 'slow' by comparison.

The motivation for this project was, first, to create some realistic enough benchmarks (at least for the kinds of problems I work on) to measure the cost of using defmulti versus various alternatives. Second, I wanted to understand the current Clojure implementation. Third, I was curious whether significant performance improvements can be achieved with small changes to the existing implementation, provided as a library layered on top of Clojure, or would compiler level changes be required.

For general background on generic functions (aka multimethods), from my perspective, see generic_functions.

For notes on the Clojure 1.8.0 implementation, see Clojure 1.8.0 multimethods.

For descriptions of the current benchmarks, and results, see benchmarks.

Installation

Clone the repository and build from source using Maven, for example:

mvn package

License

Copyright © 2017 John Alan McDonald

Apache 2.0

Acknowledgments

Yourkit

YourKit is kindly supporting open source projects with its full-featured Java Profiler.

YourKit, LLC is the creator of innovative and intelligent tools for profiling Java and .NET applications. Take a look at YourKit's leading software products:

multimethod-experiments's People

Contributors

palisades-lakes avatar

Stargazers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.