# Language Bindings

URL: https://docs.hanzo.ai/docs/zap/bindings

> ZAP SDK documentation for all supported languages

ZAP provides native bindings for 11 programming languages. Each binding is built on the reference Cap'n Proto implementation for that language.

## Supported Languages

- [Rust](https://docs.hanzo.ai/docs/zap/bindings/rust): Reference implementation with full async support
- [Go](https://docs.hanzo.ai/docs/zap/bindings/go): Idiomatic Go with goroutine-safe clients
- [Python](https://docs.hanzo.ai/docs/zap/bindings/python): Async/await API with pycapnp
- [JavaScript](https://docs.hanzo.ai/docs/zap/bindings/javascript): Node.js and browser support
- [C++](https://docs.hanzo.ai/docs/zap/bindings/cpp): High-performance native binding
- [C](https://docs.hanzo.ai/docs/zap/bindings/c): Minimal C API for embedded
- [Java](https://docs.hanzo.ai/docs/zap/bindings/java): JVM binding with Netty transport
- [C#](https://docs.hanzo.ai/docs/zap/bindings/csharp): .NET binding with async support
- [Erlang](https://docs.hanzo.ai/docs/zap/bindings/erlang): OTP-compatible binding
- [OCaml](https://docs.hanzo.ai/docs/zap/bindings/ocaml): Functional binding with Lwt
- [Haskell](https://docs.hanzo.ai/docs/zap/bindings/haskell): Pure functional binding

## Implementation Status

| Language   | Client | Server  | Gateway | PQ-TLS  | Consensus |
| ---------- | ------ | ------- | ------- | ------- | --------- |
| Rust       | Yes    | Yes     | Yes     | Yes     | Yes       |
| Go         | Yes    | Yes     | Yes     | Yes     | Yes       |
| Python     | Yes    | Yes     | Yes     | Partial | Planned   |
| JavaScript | Yes    | Partial | Yes     | No      | Planned   |
| C++        | Yes    | Yes     | Yes     | Yes     | Partial   |
| C          | Yes    | Partial | No      | No      | No        |
| Java       | Yes    | Yes     | Partial | Partial | Planned   |
| C#         | Yes    | Partial | No      | No      | No        |
| Erlang     | Yes    | Yes     | Partial | No      | Planned   |
| OCaml      | Yes    | Partial | No      | No      | No        |
| Haskell    | Yes    | Partial | No      | No      | No        |

## Common Patterns

### Client Creation

All bindings follow a similar pattern:

```rust
// Rust
let client = Zap::connect("zap://localhost:9000").await?;
```

```go
// Go
client, err := zap.Connect(ctx, "zap://localhost:9000")
```

```python
# Python
client = await Zap.connect("zap://localhost:9000")
```

```typescript
// JavaScript
const client = await Zap.connect('zap://localhost:9000');
```

### Error Handling

Each binding uses idiomatic error handling:

- **Rust**: `Result<T, Error>` with `?` operator
- **Go**: Multiple return values `(result, error)`
- **Python**: Exceptions with async context
- **JavaScript**: Promises with try/catch or `.catch()`

### Async/Await

Most bindings support async operations:

```rust
// Rust (tokio)
let tools = client.list_tools().await?;
```

```go
// Go (goroutines)
tools, err := client.ListTools(ctx)
```

```python
# Python (asyncio)
tools = await client.list_tools()
```

```typescript
// JavaScript (Promises)
const tools = await client.listTools();
```

## Schema Code Generation

Generate bindings from the ZAP schema:

```bash
# Clone the schema
git clone https://github.com/zap-proto/zap
cd zap/schema

# Generate for your language
capnp compile -o rust zap.capnp
capnp compile -o go zap.capnp
capnp compile -o c++ zap.capnp
```

See language-specific pages for detailed code generation instructions.

## Contributing

Language bindings are maintained in separate repositories:

- [zap-proto/rust](https://github.com/zap-proto/rust) - Rust
- [zap-proto/go](https://github.com/zap-proto/go) - Go
- [zap-proto/py](https://github.com/zap-proto/py) - Python
- [zap-proto/js](https://github.com/zap-proto/js) - JavaScript

Contributions welcome! See each repo's CONTRIBUTING.md for guidelines.

- [Rust](https://docs.hanzo.ai/docs/zap/bindings/rust): ZAP Rust SDK - Reference implementation
- [Go](https://docs.hanzo.ai/docs/zap/bindings/go): ZAP Go SDK - Idiomatic Go binding
- [Python](https://docs.hanzo.ai/docs/zap/bindings/python): ZAP Python SDK - Async/await API
- [JavaScript](https://docs.hanzo.ai/docs/zap/bindings/javascript): ZAP JavaScript SDK - Node.js and browser support
- [C++](https://docs.hanzo.ai/docs/zap/bindings/cpp): ZAP C++ SDK - High-performance native binding
- [C](https://docs.hanzo.ai/docs/zap/bindings/c): ZAP C SDK - Minimal C API for embedded systems
- [Java](https://docs.hanzo.ai/docs/zap/bindings/java): ZAP Java SDK - JVM binding with Netty transport
- [C#](https://docs.hanzo.ai/docs/zap/bindings/csharp): ZAP C# SDK - .NET binding with async support
- [Erlang](https://docs.hanzo.ai/docs/zap/bindings/erlang): ZAP Erlang SDK - OTP-compatible binding
- [OCaml](https://docs.hanzo.ai/docs/zap/bindings/ocaml): ZAP OCaml SDK - Functional binding with Lwt
- [Haskell](https://docs.hanzo.ai/docs/zap/bindings/haskell): ZAP Haskell SDK - Pure functional binding
