Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. Crystal
  3. immutable

immutable

MITCrystalv0.1.24

Efficient, thread-safe immutable data structures (Vector and Map) for the Crystal programming language.

GitHubGitHub
203 stars11 forks0 contributors

What is immutable?

Immutable is a library providing efficient, thread-safe immutable data structures for the Crystal programming language. It implements persistent collections like Vector (array-like) and Map (hash-like) where modifications return new copies while preserving the original, enabling functional programming patterns with structural sharing for performance.

Target Audience

Crystal developers building concurrent applications, functional programming enthusiasts, or anyone needing thread-safe collections without locking overhead.

Value Proposition

Developers choose Immutable for its performance-optimized persistent data structures, inherent thread safety, and seamless integration with Crystal's ecosystem, offering a functional alternative to mutable collections.

Overview

Thread-safe, persistent, immutable collections for the Crystal language

Use Cases

Best For

  • Building concurrent Crystal applications without locking mechanisms
  • Implementing functional programming patterns with persistent data structures
  • Creating thread-safe collections for shared data access
  • Optimizing performance with structural sharing for frequent collection modifications
  • Converting nested arrays and hashes into immutable versions
  • Performing bulk updates efficiently using transient interfaces

Not Ideal For

  • Applications performing millions of small, sequential updates to large collections where mutable in-place changes are preferred for raw speed
  • Projects with strict real-time latency requirements that cannot tolerate even near-constant O(Log32) overhead for lookups and updates
  • Teams heavily reliant on Crystal's standard mutable Array and Hash APIs without concurrency needs, as switching adds unnecessary complexity

Pros & Cons

Pros

Inherent Thread Safety

Immutability guarantees safe concurrent access without locks, making it ideal for multi-threaded Crystal applications as highlighted in the README's emphasis on thread-safe design.

Efficient Structural Sharing

Modifications return copies via structural sharing, minimizing memory overhead and performance hits compared to deep copies, with implementations like vector tries ensuring O(Log32) operations.

Optimized Bulk Updates

The transient interface allows for faster bulk modifications by temporarily using mutable operations, as demonstrated in the usage examples for handling thousands of updates efficiently.

Seamless Nested Conversion

The `.from` method easily converts nested arrays and hashes into immutable versions, integrating with existing Crystal code without manual restructuring.

Cons

Limited Data Structure Variety

Only Vector and Map are implemented, lacking other common immutable collections like sets or queues, which might require additional libraries or workarounds.

Logarithmic Complexity Overhead

Despite being near-constant, operations have O(Log32) complexity, which can be slower than O(1) for mutable collections in performance-critical scenarios, as noted in the implementation details.

API Divergence from Standards

While similar to Array and Hash, the immutable API has differences (e.g., `.set` instead of assignment) that require code changes and learning effort for developers accustomed to mutable paradigms.

Frequently Asked Questions

Quick Stats

Stars203
Forks11
Contributors0
Open Issues3
Last commit5 years ago
CreatedSince 2016

Tags

#functional-programming#hash#vector#data-structures#persistent-data-structure#immutable-collections#thread-safe#persistent-data-structures#crystal#crystal-language#hash-map#concurrency

Built With

C
Crystal

Included in

Crystal3.5k
Auto-fetched 1 day ago

Related Projects

anyoliteanyolite

Embedded mruby/Ruby for Crystal

Stars178
Forks10
Last commit4 months ago
crzcrz

Functional programming library for https://github.com/crystal-lang/crystal

Stars94
Forks6
Last commit5 years ago
crystal-web-framework-starscrystal-web-framework-stars

⭐️ Web frameworks for Crystal, most starred on Github

Stars76
Forks3
Last commit5 days ago
lua.crlua.cr

Crystal to Lua bridge

Stars70
Forks9
Last commit2 months ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub