Language Bindings¶
YAMLStar provides native bindings for 17 programming languages, all using the same underlying shared library. This ensures consistent YAML behavior across supported binding 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:
Julia¶
Julia binding using ccall.
Install:
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:
Lua¶
Lua binding using cffi-lua or LuaJIT FFI.
Install:
Quick Example:
Delphi (Pascal)¶
Free Pascal binding using native FFI.
Install:
# Build the YAMLStar shared library first
cd libyamlstar
make native && sudo make install
# Build the Delphi binding
cd ../delphi
make build
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 - Crystal:
YAMLStar.new - Go:
yamlstar.New() - Haskell: no instance needed
- Julia:
YS.Runtime() - Rust:
YAMLStar::new() - Perl:
YAMLStar->new() - Ruby/PHP:
YAMLStar.new/new YAMLStar\YAMLStar() - Raku:
YAMLStar.new - Lua:
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) - Crystal:
ys.load(yaml_string) - Haskell:
loadYAMLStar yaml_text - Julia:
YS.load(ys, yaml_string) - Rust:
ys.load(&yaml_string) - Perl:
$ys->load($yaml_string) - Ruby/PHP:
ys.load(yaml_string)/$ys->load($yaml_string) - Raku:
$ys.load($yaml-string) - Lua:
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) - Crystal:
ys.load_all(yaml_string) - Go:
ys.LoadAll(yaml_string) - Haskell:
loadYAMLStarAll yaml_text - Java/C#:
ys.loadAll(yaml_string) - Julia:
YS.load_all(ys, yaml_string) - Rust:
ys.load_all(&yaml_string) - Perl:
$ys->load_all($yaml_string) - Ruby:
ys.load_all(yaml_string) - PHP:
$ys->loadAll($yaml_string) - Raku:
$ys.load-all($yaml-string) - Lua:
ys:load_all(yaml_string) - Fortran:
call ys%load_all(yaml_string)
Dumping Values¶
Dump JSON-compatible native values to YAML:
- Python:
ys.dump(value)andys.dump_all(values) - Node.js:
ys.dump(value)andys.dumpAll(values) - Clojure:
(yaml/dump value)and(yaml/dump-all values) - Crystal:
ys.dump(value)andys.dump_all(values) - Go:
yamlstar.Dump(value)andyamlstar.DumpAll(values) - Haskell:
dumpYAMLStar valueanddumpYAMLStarAll values - Java/C#:
dump(value)/Dump(value)anddumpAll(values)/DumpAll(values) - Julia:
YS.dump(ys, value)andYS.dump_all(ys, values) - Rust:
ys.dump(&value)andys.dump_all(&values) - Perl:
$ys->dump($value)and$ys->dump_all($values) - Ruby:
ys.dump(value)andys.dump_all(values) - PHP:
$ys->dump($value)and$ys->dumpAll($values) - Raku:
$ys.dump($value)and$ys.dump-all($values) - Lua:
ys:dump(value)andys:dump_all(values) - Fortran:
ys%dump(json_value)andys%dump_all(json_values)
For example:
Cleanup¶
Close the YAMLStar instance when done:
- Python/Node.js/Java/C#/Rust/Perl/Ruby/PHP:
ys.close() - Clojure: No cleanup needed
- Crystal:
ys.close - Go:
ys.Close() - Haskell: No cleanup needed
- Julia:
YS.close(ys) - Raku:
$ys.close - Lua:
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 shared-library artifacts are built; binding-level native Windows support varies by language
The shared library (libyamlstar.so, libyamlstar.dylib, yamlstar.dll) is
built using GraalVM native-image for optimal performance and small binary size.
The Crystal, Haskell, Julia, and Raku bindings are currently tested on the Linux/macOS shared-library path. Native Windows support for these bindings is not claimed until their build and library lookup paths are verified there.
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
Crystal¶
- Requires Crystal 1.0+
- Uses native FFI
- Currently tested on Linux/macOS
- Available from the YAMLStar Crystal split repository
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
Haskell¶
- Requires GHC 9.4+
- Uses FFI through Cabal
- Currently tested on Linux/macOS
- Available on Hackage
Julia¶
- Requires Julia 1.x
- Uses
ccalland JSON for native value conversion - Currently tested on Linux/macOS
- Available through the Julia General registry
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
Ruby¶
- Requires Ruby 2.7+
- Uses Fiddle from Ruby's standard library
- Available on RubyGems
PHP¶
- Requires PHP 8.0+
- Uses the PHP FFI extension
- Available on Packagist
Lua¶
- Requires Lua 5.1+ with cffi-lua or LuaJIT FFI
- Uses lua-cjson for JSON conversion
- Available on LuaRocks
Raku¶
- Requires Rakudo
- Uses NativeCall
- Currently tested on Linux/macOS
- Available through zef/fez
C¶
- Requires .NET 6+
- Uses P/Invoke
- Returns standard .NET collections
- Available on NuGet
Delphi (Pascal)¶
- Requires Free Pascal Compiler (FPC) 3.0+
- Uses native FFI
- Returns FPJson TJSONData objects
- Compatible with Delphi and Lazarus
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:
char* yamlstar_load(char* yaml_input);
char* yamlstar_load_all(char* yaml_input);
char* yamlstar_dump(char* data_json);
char* yamlstar_dump_all(char* data_json);
yamlstar_load and yamlstar_load_all return JSON strings that can be parsed
by your language's native JSON library. yamlstar_dump and
yamlstar_dump_all accept JSON strings and return YAML text.
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