Skip to content
/ immer Public
forked from arximboldi/immer

Postmodern immutable and persistent data structures for C++

License

Notifications You must be signed in to change notification settings

csguth/immer

 
 

Repository files navigation

Travis Badge CodeCov Badge

Logotype

immer is a library of persistent and immutable data structures written in C++. These enable whole new kinds of architectures for interactive and concurrent programs of striking simplicity, correctness, and performance.

This library has full months of pro bono research and development invested in it. This is just the first step in a long-term vision of making interactive and concurrent C++ programs easier to write. To ensure this project's long term sustainability please consider becoming a sponsor: [email protected]

Example

#include <immer/vector.hpp>
int main()
{
    const auto v0 = immer::vector<int>{};
    const auto v1 = v0.push_back(13);
    assert(v0.size() == 0 && v1.size() == 1 && v1[0] == 13);

    const auto v2 = v1.set(0, 42);
    assert(v1[0] == 13 && v2[0] == 42);
}
For a complete example check Ewig, a simple didactic text-editor built with this library.

Why?

In the last few years, there has been a growing interest in immutable data structures, motivated by the horizontal scaling of our processing power and the ubiquity of highly interactive systems. Languages like Clojure and Scala provide them by default, and implementations for JavaScript like Mori and Immutable.js are widely used, specially in combination with modern UI frameworks like React.

Interactivity
Thanks to persistence and structural sharing, new values can be efficiently compared with old ones. This enables simpler ways of reasoning about change that sit at the core of modern interactive systems programming paradigms like reactive programming.
Concurrency
Passing immutable data structures by value does not need to copy any data. In the absence of mutation, data can be safely read from multiple concurrent processes, and enable concurrency patterns like share by communicating efficiently.
Parallelism
Some recent immutable data structures have interesting properties like O(log(n)) concatenation, which enable new kinds of parallelization algorithms.

Features

Idiomatic
This library doesn't pretend that it is written in Haskell. It leverages features from recent standards to provide an API that is both efficient and natural for a C++ developer.
Performant
You use C++ because you need this. Immer implements state of the art data structures with efficient cache utilization and have been proven production ready in other languages. It also includes our own improvements over that are only possible because of the C++'s ability to abstract over memory layout. We monitor the performance impact of every change by collecting benchmark results directly from CI.
Customizable
We leverage templates and policy-based design to build data-structures that can be adapted to work efficiently for various purposes and architectures, for example, by choosing among various memory management strategies. This turns immer into a good foundation to provide immutable data structures to higher level languages with a C runtime, like Python or Guile.

Dependencies

This library is written in C++14 and a compliant compiler is necessary. It is continuously tested with Clang 3.8 and GCC 6, but it might work with other compilers and versions.

No external library is necessary and there are no other requirements.

Usage

This is a header only library. Just make sure that the project root is in your include path.

Development

One may generate a development project using CMake:

mkdir build && cd build
cmake ..

To automatically fetch and build all depedencies required to build and run the tests and benchmarks run:

make deps

From then on, one may build and run all tests by doing:

make check

In order to build and run all benchmarks when running make check, run cmake again with the option -DCHECK_BENCHMARKS=1. The results of running the benchmarks will be saved to a folder reports/ in the project root.

License

This software is licensed under the GNU Lesser General Public License v3 (LGPLv3+).

LGPL3 logo

The full text of the license is can be accessed via this link and is also included in the LICENSE file of this software package.

This is a header-only library. As such, under the terms of the LGPLv3 license, you can use it to build any kind of software. However, if you distribute software containing a modified version of Immer, you need to make your version of Immer available to your users under the LGPLv3 license. For further details please refer to the LICENSE file.

Alternatively, you can purchase a custom license tailored to your business needs.

For any licensing questions, contact us on [email protected]


immer - immutable data structures for C++
Copyright (C) 2016, 2017 Juan Pedro Bolivar Puente

This file is part of immer.

immer is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

immer is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with immer.  If not, see <http://www.gnu.org/licenses/>.

About

Postmodern immutable and persistent data structures for C++

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 56.2%
  • JavaScript 40.7%
  • CMake 1.6%
  • Scheme 0.6%
  • Nix 0.4%
  • Python 0.3%
  • Other 0.2%