Language Bindings¶
YAMLStar provides native bindings for 9 programming languages, all using the same underlying shared library. This ensures 100% consistent behavior across all platforms.
Available Bindings¶
Python¶
Pure Python binding using ctypes.
Install:
Quick Example:
Node.js¶
Native JavaScript binding for Node.js.
Install:
Quick Example:
Go¶
Native Go binding using cgo.
Install:
Quick Example:
Java¶
Java binding using JNI.
Install (Maven):
<dependency>
<groupId>com.yaml</groupId>
<artifactId>yamlstar</artifactId>
<version>0.1.2</version>
</dependency>
Quick Example:
Rust¶
Rust binding using FFI.
Install:
Quick Example:
Perl¶
Perl binding using FFI::Platypus.
Install:
Quick Example:
C¶
C# binding using P/Invoke.
Install:
Quick Example:
Common API¶
All bindings provide the same core functionality:
Constructor/Initialization¶
Create a new YAMLStar instance:
- Python/Node.js/Java/C#:
YAMLStar()ornew YAMLStar() - Clojure:
(require '[yamlstar.core :as yaml])- no instance needed - Go:
yamlstar.New() - Rust:
YAMLStar::new() - Perl:
YAMLStar->new() - Fortran:
yamlstar_new()
Loading Single Documents¶
Load a single YAML document:
- Python/Java/C#:
ys.load(yaml_string) - Node.js/Go:
ys.load(yaml_string)orys.Load(yaml_string) - Clojure:
(yaml/load yaml-string) - Rust:
ys.load(&yaml_string) - Perl:
$ys->load($yaml_string) - Fortran:
call ys%load(yaml_string)
Loading Multiple Documents¶
Load all documents from a multi-document YAML stream:
- Python:
ys.load_all(yaml_string) - Node.js:
ys.loadAll(yaml_string) - Clojure:
(yaml/load-all yaml-string) - Go:
ys.LoadAll(yaml_string) - Java/C#:
ys.loadAll(yaml_string) - Rust:
ys.load_all(&yaml_string) - Perl:
$ys->load_all($yaml_string) - Fortran:
call ys%load_all(yaml_string)
Cleanup¶
Close the YAMLStar instance when done:
- Python/Node.js/Java/C#/Rust/Perl:
ys.close() - Clojure: No cleanup needed
- Go:
ys.Close() - Fortran:
call ys%close()
Resource Management
The YAMLStar instance uses native resources (shared library handles).
Always call close() when you're done to free these resources.
In languages with RAII (Rust, C++), this happens automatically.
Building Bindings from Source¶
Each binding can be built and tested independently:
# Clone the repository
git clone https://github.com/yaml/yamlstar.git
cd yamlstar
# Build the core shared library first
cd libyamlstar
make build
# Build and test a specific binding
cd ../python
make test
The build system automatically installs all required tools and dependencies on first run using the Makes system.
Platform Support¶
YAMLStar bindings are tested on:
- Linux: x86_64, arm64
- macOS: x86_64 (Intel), arm64 (Apple Silicon)
- Windows: x86_64 (via WSL or native)
The shared library (libyamlstar.so, libyamlstar.dylib, yamlstar.dll) is
built using GraalVM native-image for optimal performance and small binary size.
Language-Specific Notes¶
Python¶
- Requires Python 3.7+
- Uses
ctypesfor FFI (no compilation required) - Thread-safe when using separate instances
- Pip package includes pre-built binaries for common platforms
Node.js¶
- Requires Node.js 14+
- Uses
node-gypfor native bindings - Async API planned for future release
- NPM package includes pre-built binaries
Clojure¶
- Requires Clojure 1.12+
- No FFI overhead (native Clojure implementation)
- Works with Leiningen and deps.edn
- Available on Clojars
Go¶
- Requires Go 1.20+
- Uses cgo (requires C compiler)
- Native Go types (map[string]interface{}, []interface{})
- Available via go get
Java¶
- Requires Java 11+
- Uses JNI for native calls
- Returns standard Java collections
- Available on Maven Central
Rust¶
- Requires Rust 1.70+
- Uses FFI with safety guarantees
- Returns serde-compatible types
- Available on crates.io
Perl¶
- Requires Perl 5.32+
- Uses FFI::Platypus
- Returns Perl hashes and arrays
- Available on CPAN
C¶
- Requires .NET 6+
- Uses P/Invoke
- Returns standard .NET collections
- Available on NuGet
Fortran¶
- Requires gfortran 10+ or Intel Fortran 2021+
- Uses iso_c_binding
- Modern Fortran 2018 features
- Available via FPM (Fortran Package Manager)
Contributing a New Binding¶
Want to add support for another language? See the Contributing Guide for instructions on creating new language bindings.
The shared library provides a simple JSON-based FFI:
Both functions return JSON strings that can be parsed by your language's native JSON library.
Performance¶
All bindings use the same underlying C library, so performance is consistent:
- Parsing: ~50-100 MB/s (depends on document complexity)
- Memory: ~2-5x the input size during parsing
- Startup: <10ms (native binary, no JVM warmup)
For detailed benchmarks, see the performance documentation.
Next Steps¶
- Get started with your language of choice
- Explore the roadmap for upcoming features
- Read about YAMLStar to understand the architecture
- Visit the GitHub repository to contribute