# Experimental Crystal stdlib replacements

**URL:** <https://forum.crystal-lang.org/t/experimental-crystal-stdlib-replacements/8852>\
**Category:** Offtopic\
**Created:** [April 9, 2026, 12:58am UTC](https://forum.crystal-lang.org/t/experimental-crystal-stdlib-replacements/8852 "2026-04-09T00:58:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![wontruefree](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/wontruefree/32/1467_2.png) [@wontruefree](https://forum.crystal-lang.org/u/wontruefree)\
**Post date:** [April 9, 2026, 12:58am UTC](https://forum.crystal-lang.org/t/experimental-crystal-stdlib-replacements/8852/1 "2026-04-09T00:58:49Z")

</div>

I have been experimenting with some concepts from [Casey Muratori](https://www.computerenhance.com/) and just some other thoughts on performance, dependencies, general experimentation.

This has come together in this [branch](https://github.com/jkthorne/crystal/tree/pure_crystal).  
This fork as a few things.

- [Z](https://github.com/jkthorne/z)
- [YAML](https://github.com/jkthorne/yaml)
- [Big Number](https://github.com/jkthorne/big_number)
- [CharCov](https://github.com/jkthorne/charconv)
- SIMD

* * *

## Why Pure Crystal Backends?

- Cross-compilation
- Static linking
- WASM
- embedded
- Docker to simplify libs
- just because it is cool

Honestly this is just fun and experimental. I remembered the story of [Rubinius](https://rubinius.com/) back in the day and I don’t even know if it was true but I remember one of the goals being to write parts of the stdlib in ruby and llvm.

* * *

## [Z](https://github.com/jkthorne/z)

The goal was to make it as compliant as possible and make it performant. Mainly because of the c library using SIMD crystal cannot get close to zlib. Which got me to start messing with SIMD in crystal. I know this [issue](https://github.com/crystal-lang/crystal/issues/3057) exists but I am just playing around with it.

| | Z (pure Crystal) | stdlib/libz | Ratio |
| --- | --- | --- | --- |
| Compress — Deflate (text) | 140 MB/s | 483 MB/s | 0.3x |
| Compress — Gzip (text) | 135 MB/s | 461 MB/s | 0.3x |
| Compress — Deflate (random) | 26 MB/s | 58 MB/s | 0.5x |
| Decompress — Deflate (text) | 2,910 MB/s | 4,749 MB/s | 0.6x |
| Decompress — Gzip (text) | 766 MB/s | 4,547 MB/s | 0.2x |

* * *

## [CharConv](https://github.com/jkthorne/charconv) : [Forum Post](https://forum.crystal-lang.org/t/charconv-pure-crystal-iconv-replacement/8776)

Replaces libiconv with support for 150+ encodings: all ISO-8859-_, CP_, KOI8-\* single-byte encodings, UTF-7/16/32, full CJK (Shift\_JIS, EUC-JP, GB2312, GBK, GB18030, Big5, EUC-KR, EUC-TW), and stateful codecs  
(ISO-2022-JP/CN/KR, HZ-GB-2312). Supports //IGNORE and //TRANSLIT modes.

| Conversion | charconv | system iconv | Ratio |
| --- | --- | --- | --- |
| ASCII → ASCII | 73 µs | 11.89 ms | 162x |
| UTF-8 → ISO-8859-1 | 3.43 ms | 14.62 ms | 4.3x |
| ISO-8859-1 → UTF-8 | 2.08 ms | 14.24 ms | 6.9x |
| UTF-8 → UTF-8 (mixed widths) | 4.92 ms | 11.98 ms | 2.4x |
| CP1252 → UTF-8 | 2.50 ms | 17.24 ms | 6.9x |
| UTF-16BE → UTF-8 | 3.73 ms | 10.83 ms | 2.9x |
| UTF-8 → UTF-16LE | 4.57 ms | 10.11 ms | 2.2x |

* * *

[BigNumber](https://github.com/jkthorne/big_number) : [Forum Post](https://forum.crystal-lang.org/t/big-number-pure-crystal-gmp-replacement/8775/18)

| Operation | 1 limb (19 dig) | 10 limbs (190 dig) | 50 limbs (950 dig) | 100 limbs (1.9k dig) | 1000 limbs (19k dig) |
| --- | --- | --- | --- | --- | --- |
| add | 0.77x | 0.98x | 1.12x | 1.09x | 1.18x |
| mul | 0.77x | 1.35x | 2.62x | 2.62x | 3.21x |
| div | 0.98x | 2.54x | 2.36x | 2.62x | |
| to\_s | 1.95x | 3.36x | 5.16x | 5.37x | 4.58x |

* * *

## [YAML](https://github.com/jkthorne/yaml)

| Fixture | Size | libyaml | pure Crystal | Ratio |
| --- | --- | --- | --- | --- |
| trivial | 11 B | 333k ips | 429k ips | 1.29x faster |
| flat\_mapping | 1.7 KB | 12.0k ips | 12.4k ips | 1.03x faster |
| flow\_collections | 4.8 KB | 4.7k ips | 5.2k ips | 1.12x faster |
| nested | 32 KB | 1.02k ips | 989 ips | 0.97x |
| block\_scalars | 1.6 KB | 28.9k ips | 24.5k ips | 0.85x |
| strings\_heavy | 6.9 KB | 8.9k ips | 5.2k ips | 0.59x |
| large\_config | 49 KB | 727 ips | 656 ips | 0.90x |

* * *

## SIMD Vectors (SIMDVector(T, N))

- SIMDVectorType and SIMDVectorInstanceType
- LLVM vector instruction bindings
- Codegen: simd\_splat, simd\_extract, simd\_insert, simd\_binary, simd\_compare

* * *

## Finally

I am curious if people would use this, be interested in this, general feedback. I have some ideas for my own web framework and will probably see if I can include any of this in some of the ideas I have.

Thanks for reading this far!

---

<div class="post-metadata">

**Author:** ![wontruefree](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/wontruefree/32/1467_2.png) [@wontruefree](https://forum.crystal-lang.org/u/wontruefree)\
**Post date:** [April 9, 2026, 2:14am UTC](https://forum.crystal-lang.org/t/experimental-crystal-stdlib-replacements/8852/2 "2026-04-09T02:14:07Z")

</div>

This is a small Z update with some SIMD updates

| Benchmark | libz (C) | Crystal+SIMD | Ratio |
| --- | --- | --- | --- |
| Gzip compress (compressible 990KB) | 1.84ms | 4.77ms | 2.6x slower |
| Gzip compress (random 1MB) | 17.67ms | 33.42ms | 1.9x slower |
| Gzip compress (repetitive 1MB) | 1.86ms | 4.73ms | 2.5x slower |
| Zlib compress (compressible 990KB) | 1.88ms | 3.99ms | 2.1x slower |
| Zlib compress (random 1MB) | 16.98ms | 31.18ms | 1.8x slower |

---

<div class="post-metadata">

**Author:** ![weirdbricks](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/weirdbricks/32/1741_2.png) [@weirdbricks](https://forum.crystal-lang.org/u/weirdbricks)\
**Post date:** [April 19, 2026, 3:23am UTC](https://forum.crystal-lang.org/t/experimental-crystal-stdlib-replacements/8852/3 "2026-04-19T03:23:24Z")

</div>

In my opinion, Crystal’s ability to compile to a single binary is one of it’s greatest strengths, so I’m excited about enabling this with pure Crystal implementations. Thank you for this @wontruefree !
