Skip to content

almide/almide-lander

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

almide-lander

CI

Export Almide modules as native packages for 20 languages.

Python Go Ruby Swift C# Dart Kotlin Java C++ Rust
JS C Zig Nim Scala Julia Elixir PHP Lua PowerShell

Almide · almide-bindgen · Playground


What is this?

Write a library in Almide. Run one command. Use it from 20 languages.

almide run src/main.almd -- --lang python mylib.almd
almide run src/main.almd -- --lang python,go,swift mylib.almd   # multiple at once
almide run src/main.almd -- --list                               # show all 20
almide run src/main.almd -- --dry-run --lang ruby mylib.almd     # preview

No runtime. No VM. Almide disappears — only a native shared library and a pure language wrapper remain.

How it works

mylib.almd
    │
    ├─ [1/N] almide compile --json             → interface.json
    ├─ [2/N] almide --target rust --repr-c     → source.rs + cargo build → .so/.dylib
    └─ [3/N] bindgen.bindings.<lang>.generate() → almide_mylib.py / .go / .swift / ...

Architecture

almide-bindgen (library, 20 generators)     almide-lander (this repo, CLI)
├── src/mod.almd                            ├── almide.toml → depends on bindgen
├── src/scaffolding.almd                    ├── src/main.almd → import bindgen
└── src/bindings/ (20 .almd files)          └── test/ (51 tests)

Everything is written in Almide. No Python, no external tool dependencies.

Demo

1. Write Almide

// mathlib.almd
import math

type Point = { x: Float, y: Float }
type Shape = Circle(Float) | Rect(Float, Float)

fn distance(a: Point, b: Point) -> Float = {
  let dx = a.x - b.x
  let dy = a.y - b.y
  math.sqrt(dx * dx + dy * dy)
}

fn area(shape: Shape) -> Float = match shape {
  Circle(r) => math.pi() * r * r,
  Rect(w, h) => w * h,
}

2. Land it

almide run src/main.almd -- --lang python mathlib.almd
[1/3] Compiling interface from mathlib.almd...
[2/3] Building shared library...
  OK
[3/3] Generating python binding...
  almide_mathlib.py

Done. Generated 1 binding(s) for mathlib.

3. Use it

Python

from almide_mathlib import Point, distance
distance(Point(x=0, y=0), Point(x=3, y=4))  # 5.0

Go

d := almide.Distance(almide.Point{X: 0, Y: 0}, almide.Point{X: 3, Y: 4})

Ruby

d = AlmideMathlib.distance(AlmideMathlib::Point.new(x: 0, y: 0), AlmideMathlib::Point.new(x: 3, y: 4))

Swift

let d = Mathlib.distance(Point(x: 0, y: 0), Point(x: 3, y: 4))

C#

var d = Bridge.Distance(new Point(0, 0), new Point(3, 4));

Dart

final d = Mathlib.distance(Point(x: 0, y: 0), Point(x: 3, y: 4));

Kotlin

val d = Mathlib.distance(Point(0.0, 0.0), Point(3.0, 4.0))

Java

double d = Mathlib.distance(new Point(0, 0), new Point(3, 4));

C++

auto d = almide::distance(almide::Point{0, 0}, almide::Point{3, 4});

Rust

let d = almide_mathlib::distance(Point { x: 0.0, y: 0.0 }, Point { x: 3.0, y: 4.0 });

JavaScript

const d = distance({x: 0, y: 0}, {x: 3, y: 4});  // 5.0

C

double d = almide_distance(0, 0, 3, 4);

Zig

const d = almide.distance(Point{ .x = 0, .y = 0 }, Point{ .x = 3, .y = 4 });

Nim

let d = distance(Point(x: 0, y: 0), Point(x: 3, y: 4))

Scala

val d = Mathlib.distance(Point(0.0, 0.0), Point(3.0, 4.0))

Julia

d = distance(Point(0.0, 0.0), Point(3.0, 4.0))

Elixir

d = AlmideMathlib.distance(%Point{x: 0.0, y: 0.0}, %Point{x: 3.0, y: 4.0})

PHP

$d = AlmideMathlib::distance(new Point(0, 0), new Point(3, 4));

Lua

local d = almide.distance(Point.new(0, 0), Point.new(3, 4))

PowerShell

$d = [AlmideMathlib]::Distance([Point]::new(0, 0), [Point]::new(3, 4))

License

MIT

About

Cross-language package exporter — compile Almide modules to native shared libraries with bindings for Python, Go, Swift, Ruby, C, and more

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors