joka 0.1.4
A nogc utility library.
To use this package, run the following command in your project's root directory:
Manual usage
Put the following dependency into your project's dependences section:
🃏 Joka
A nogc utility library for the D programming language. Joka provides data structures and functions that can work without garbage collection, offering precise memory control. It is designed to complement the D standard library, not replace it.
Why Joka
- Minimalistic: Avoids abstractions
- Focused: Doesn't try to support every use case
- Simple: Uses a single global allocator, set at compile time
- Friendly: Memory-safety features and many examples
WebAssembly Support
WebAssembly is supported with the betterC flag, but a tool like Emscripten is required. In case of errors, the i flag may help. The combination -betterC -i works in most cases.
Modules
joka.algo: Range utilitiesjoka.ascii: ASCII string utilitiesjoka.cli: Command-line parsing utilitiesjoka.containers: General-purpose containersjoka.interpolation: IES supportjoka.io: Input and output functionsjoka.math: Mathematical data structures and functionsjoka.memory: Functions for dealing with memoryjoka.types: Common type definitionsjoka.stdc: C standard library functions
Versions
JokaCustomMemory: Allows the declaration of custom memory allocation functionsJokaGcMemory: LikeJokaCustomMemory, but preconfigured to use the D garbage collector
Documentation
Start with the examples folder for a quick overview.
Frequently Asked Questions
Does Joka have an allocator API?
No. Joka is designed to feel a bit like the C standard library because that's easier for most people to understand and keeps the library simple.
Will Joka get a global context like Jai?
No. A public global context tends to make generic low-level APIs fragile. That doesn't mean it's a bad idea. It can be useful for libraries with a specific purpose, such as UI frameworks.
Why aren't some functions @nogc?
Because the D garbage collector can be used to allocate memory with the JokaGcMemory version. The @nogc attribute is just a hint to the compiler, telling it to check that called functions also carry that hint. It can be helpful but not essential for writing GC-free code.
Why are you supporting the D garbage collector?
It's another tool for memory management.
Joka normally uses a tracking allocator in debug builds to help identify mistakes, but the JokaGcMemory version exists for people who prioritize safety.
This approach is similar to the one used in Fil-C.
What is Joka used for?
It's primarily used for Parin, a game engine.
What are common betterC errors and how do I fix them?
Using
betterCas a global@nogcattribute. This flag does more than just remove the garbage collector and adds extra checks that can sometimes be overly restrictive. If writing GC-free code is important and compiler assistance is really needed, then add@nogc:at the top of every file. To reiterate, the@nogcattribute is just a hint to the compiler, telling it to check that called functions also carry that hint. It can be helpful but not essential for writing GC-free code.Using
betterCwithout theiflag. The combination-betterC -iworks in most cases and is recommended for anyone still learning D.Using
struct[N]. Some parts of the D runtime (_memsetn, ...) are needed when using types like this and they can be missing due to howbetterCworks. The solution is to implement the missing functions or use a custom static array type (./source/joka/types.d:61).TypeInfoerrors. Search fornewin the source code and remove it.
- 0.1.4 released 3 days ago
- Kapendev/joka
- MIT
- Copyright © 2025, Alexandros F. G. Kapretsos
- Authors:
- Dependencies:
- none
- Versions:
-
Show all 49 versions0.1.5 2025-Dec-10 0.1.4 2025-Dec-07 0.1.3 2025-Dec-05 0.1.2 2025-Dec-03 0.1.1 2025-Dec-02 - Download Stats:
-
-
0 downloads today
-
4 downloads this week
-
36 downloads this month
-
376 downloads total
-
- Score:
- 1.3
- Short URL:
- joka.dub.pm