东
东 是一种静态地打入了TypeScript中嵌入的基于表达式的编程语言. 设计于 爱拉拉 , East 使您能够一次写出可移植逻辑,并在多个环境(JavaScript, Julia, Python等)中执行, 利用每种语言的本土性能特征和生态系统.
动机
提供完整的业务解决方案需要广泛的技术和活动:数据集成,数学优化,机器学习,模拟,用户界面,认证和授权,托管,管理数据一致性,审计等. 需要多个编程环境来解决任何给定的商业问题——例如,您可以使用JavaScript进行网络前端和python来培训和评价机器学习模型.
东方的设计是为了通过专注于一个简单而强大的结构类型系统, 使得所有锅炉和管道的工作都消失, 让你花更多的时间来解决现实世界的问题, 来方便地将不同的技术融合在一起. 东方是故意的简单语言,快速地学习,在新的运行时刻直接实施.
特征
- 静态打字: 明确宣布速度和正确性的所有类型、函数和值
- 结构打字: 有递归类型,一等功能和多形态变体的表达式类型系统
- 便携式 IR: 编译到 JavaScript, Python 和 Julia
- 控制边效果: 有跨语言平台定义效果的安全执行
- LLM 友好游戏: 为AI所设计,有清晰,可堆肥而有花样的友好别名
- 可序列:所有数据都可以被序列化;函数和关闭可以作为IR传输
- 最小依赖性: 单一运行时间依赖(用于高效收集的种类树)
- 订购共计:所有类型都有定义的比较,所有语文目标都是一致的
快速启动
安装
npm install @elaraai/east
基本示例
import { East, IntegerType, ArrayType, StructType, StringType, DictType, NullType } from "@elaraai/east";
// Platform function for logging
const log = East.platform("log", [StringType], NullType);
const platform = [
log.implement(console.log),
];
// Define sale data type
const SaleType = StructType({
product: StringType,
quantity: IntegerType,
price: IntegerType
});
// Calculate revenue per product from sales data
const calculateRevenue = East.function(
[ArrayType(SaleType)],
DictType(StringType, IntegerType),
($, sales) => {
// Group sales by product and sum revenue (quantity × price)
const revenueByProduct = sales.groupSum(
// Group by product name
($, sale) => sale.product,
// Sum quantity × price
($, sale) => sale.quantity.multiply(sale.price)
);
// Log revenue for each product
$(log(East.str`Total Revenue: ${East.Integer.printCurrency(revenueByProduct.sum())}`));
$.return(revenueByProduct);
}
);
// Compile and execute
const compiled = East.compile(calculateRevenue, platform);
const sales = [
{ product: "Widget", quantity: 10n, price: 50n },
{ product: "Gadget", quantity: 5n, price: 100n },
{ product: "Widget", quantity: 3n, price: 50n }
];
compiled(sales);
// Total Revenue: $1,150
类型系统
东方支持为业务逻辑和数据处理优化的丰富类型系统:
| 类型 | 值类型 | 变异性 | 说明 |
|---|---|---|---|
| 初级类型 | |||
NullType | null | 不可改变 | 单位类型(单值) |
BooleanType | boolean | 不可改变 | 真伪 |
IntegerType | bigint | 不可改变 | 64 位签名整数 |
FloatType | number | 不可改变 | IEEE 754 双精度 |
StringType | string | 不可改变 | UTF-8 文本 |
DateTimeType | Date | 不可改变 | UTC 时间戳( 毫秒) |
BlobType | Uint8Array | 不可改变 | 二进制数据 |
| 可变收藏 | |||
ArrayType<T> | ValueTypeOf<T>[] | 可变 | 有序收藏 |
SetType<K> | Set<ValueTypeOf<K>> | 可变 | 排序集 |
DictType<K, V> | Map<ValueTypeOf<K>, ValueTypeOf<V>> | 可变 | 排序词典 |
RefType<T> | ref<ValueTypeOf<T>> | 可变 | 可变箱 |
| 数字阵列 | |||
VectorType<FloatType> | Float64Array | 可变 | 强烈浮向量 |
VectorType<IntegerType> | BigInt64Array | 可变 | 强烈整数向量 |
VectorType<BooleanType> | Uint8ClampedArray | 可变 | 深布尔向量 |
MatrixType<T> | matrix<TypedArray> | 可变 | Ense 2D 矩阵(主要) |
| 化合物类型 | |||
StructType<Fields> | {...} | 不可改变 | 产品类型(记录) |
VariantType<Cases> | variant | 不可改变 | 总和类型( 标记的结合) |
RecursiveType<T> | ValueTypeOf<T> | 不可改变 | 树、 DAG 和圆形结构的递归引用 |
| 函数类型 | |||
FunctionType<I, O> | 函数 | 不可改变 | 一等职能/关闭 |
AsyncFunctionType<I, O> | 函数返回 Promise | 不可改变 | 同步函数/关闭 |
文档
- SKILLL.MD (英语) - 综合指南,包括API和实例参考
- 利比里亚 - 双重许可证信息(AGPL-3.0/商业)
- 捐款额 - 如何向东部捐款
- 洛杉矶 - 捐助者许可证协议
关键概念
平台函数
东码运行在被控制的环境中. 您定义 平台功能 您的东方代码可以调用 :
// Define platform functions
const log = East.platform("log", [StringType], NullType);
const readFile = East.platform("readFile", [StringType], StringType);
// Provide implementations
const platform = [
log.implement((msg: string) => console.log(msg)),
readFile.implement((path: string) => fs.readFileSync(path, 'utf-8')),
];
// Compile with platform
const compiled = East.compile(myFunction, platform);
东方也支持 asyncPlatform 函数(可能由 AsyncFunctionType ,插入 await 视需要自动.
在上述情况中, readFile 可以使用 fs.promises.readFile 利用货币.
流利的接口
使用可链路方法构建表达式 :
const myFunction = East.function([IntegerType], IntegerType, ($, x) => {
// Arithmetic
const result = $.const(x.add(10n).multiply(2n));
// Collections
const arr = $.const([1n, 2n, 3n]);
const doubled = $.const(arr.map(($, x, i) => x.multiply(2n)));
const sum = $.const(doubled.sum());
// Closures can capture variables from the enclosing scope
const addResult = $.const(East.function([IntegerType], IntegerType, ($, y) => {
$.return(y.add(result));
}));
$.return(addResult(sum));
});
// Compile and execute
const compiled = East.compile(myFunction, []);
compiled(5n);
// 42n — result = (5+10)*2 = 30, sum of [2,4,6] = 12, addResult(12) = 12+30 = 42
序列化
所有东方数据都可以以下列任何一种格式写出并读取:
- 东方文本格式(为东方类型系统设计的类似JSON格式)
- 二进制 East 格式,称为 “ beast (compact,自描述,流出)
- JSON(每个东方类型都有犬科编码)
注意可变异名 实值 通过序列化/去序化加以保存.
函数和关闭定义可以在Beast2 二进制格式中被序列化为IR并跨环境传输,以编译并运行到另一边:
import { East, IntegerType, Expr, encodeBeast2For, decodeBeast2For } from "@elaraai/east";
const myFunction = East.function([IntegerType], IntegerType, ($, x) => {
$.return(x.add(1n));
});
// the type of the function (IntegerType -> IntegerType)
const funcType = Expr.type(myFunction);
// Compile the function (this attaches the IR)
const compiled = East.compile(myFunction, []);
// Serialize the compiled function to Beast2 (binary format)
const encode = encodeBeast2For(funcType);
const bytes = encode(compiled);
// Deserialize and recompile
const decode = decodeBeast2For(funcType);
const restored = decode(bytes);
restored(41n); // 42n
实例
见 SKILLL.MD (英语) 为了更多.
发展
大楼
npm run build # Compile TypeScript to JavaScript
npm run test # Run test suite (requires build first)
npm run lint # Check code quality with ESLint
npm run example # Run the basic example
测试
东部有一个综合测试套房,包括:
- 系统操作类型
- 序列化格式( BEAST v1/v2, JSON, East 文本格式)
- 收款和职能运作
- 处理错误和边缘大小写
值得注意的是,这些测试是在东方进行的,可以方便地验证新运行时间的正确性(有效发挥合规套件的作用).
释放进程
@elaraai/east 与所有其他出版物一起出版 @elaraai/* npm 包在一个单一统一版本下的东-工作空间单列波. 释放是手动通过 NPM Publish GitHub 动作工作流程在 repo 根(.github/workflows/npm-publish.yml) (中文(简体) ). 没有每个包装的释放命令——见根 读取 详细情况.
Claude 代码插件
东方生态系统也运载a 克劳德代码 插件 — East 语言技能, 实例搜索, 以及 East 代码的先发制人诊断 elaraai 市场:
# Inside Claude Code
/plugin marketplace add elaraai/east-workspace
/plugin install east@elaraai
# From a terminal
claude plugin marketplace add elaraai/east-workspace
claude plugin install east@elaraai
许可证
这个项目有双重许可证:
- 开源数字 : AGPL-3.0 导弹 - 免费开放源码使用,有源码披露要求
- 商业:可供专有用途-联系方式 支助@elara.ai
见 利比里亚 详细情况.
捐款
我们欢迎捐款! 请看 捐款额 详细情况.
说明贡献者必须签署我们 洛杉矶 在接受拉动请求之前 这使我们能够提供商业许可证,同时保持项目的开放源码.
生态系统
-
东: statical地打出,以表达为主的语言有可序列的IR. 运行跨 TypeScript, Python, C 等运行时间的可移植逻辑.
- @elaraai/东边: 有类型系统、表达式和参考JS编译器的核心语言SDK
-
东节点: Node.js 平台用于I/O,数据库和系统操作的功能.
- @elaraai/东节点-std: 控制台、 文件系统、 获取、 加密、 时间、 路径、 随机
- @elaraai/东-北-欧: SQLite, PostgreSQL, MySQL, MongoDB, Redis, S3, FTP, SFTP, XLSX, XML, 压缩
- @elaraai/东-节点-cli: 用于在 Node.js 运行 East IR 程序的 CLI
-
东 C: C11本土运行时间用于执行东IR. 通过npm(发射器+每个平面的可选依赖)进行分配,并在每个GitHub放出上作为tarball.
- @elaraai/东-克-克利: npm 发射器 – 安装匹配的本地二进制作为可选依赖
east-c: Core 运行时间 – 类型系统,IR 解释器,内置,序列化(Beast2, JSON, CSV, East text)east-c-std: 控制台、 文件系统、 获取、 加密、 时间、 路径、 随机east-c-cli: 用于在本地运行 East IR 程序的 CLI
-
东 Py: Python 运行时间,标准平台,I/O,以及数据科学平台功能. 发布至PyPI.
- 东平: Core Python 运行时间——类型系统,IR编译器,212+内建,Cython加速热路
- 东平-上: 控制台、 文件系统、 获取、 加密、 时间、 路径、 随机
- 东比欧: SQLite, PostgreSQL, MySQL, MongoDB, Redis, S3, FTP, SFTP, XLSX, XML, 压缩
- 东-平-克利: 用于在 Python 运行 East IR 程序的 CLI
- 东平数据科学 (平价)+ @elaraai/东平数据科学 (npm):优化(MADS, Optuna, ALNS, GoogleOR),ML(XGBoost, LightGBM, NGBoost, PyTorch, Lightning, GP), 贝叶斯推论(PyMC),可解释性(SHAP),相通性预测(MAPIE)
-
东方大学:已打入UI组件定义和React渲染器,外加VS代码预览.
- @elaraai/东-伊: 50+ 键入的UI 组件用于布局,窗体,图表,表格,对话框
- @elaraai/ 东- ui- 组件: 带有 Chakra UI v3 样式的反相渲染器
- @elaraai/e3-ui (英语):e3 + UI桥-数据绑定,
e3.ui()任务,显示 - @elaai/e3-ui-组件: 为 e3 API 执行查询钩和预览组件
-
e3——东行发动机: 大规模运行东方管线的持久执行引擎。 类似Git的内容可处理存储,自动记忆,反应数据流,实时监测.
- @elaraai/e3 请检查url=值 (帮助): SDK 用于编写带有打字任务和管道的 E3 包
- @elaraai/e3-core (英语): 对象存储、数据流管弦器、执行状态
- @elaai/e3型: e3 包的共享类型定义
- @elaraai/e3-cli (英语)数字 :
e3 repo, (中文(简体) ),e3 package, (中文(简体) ),e3 workspace, (中文(简体) ),e3 dataflow run, (中文(简体) ),e3 watch, (中文(简体) ),e3 task logs命令 - @elaraai/e3-api-客户端远程 e3 寄存器的 HTTP 客户端
- @elaraai/e3-api-服务器: 用于 e3 寄存器的 REST API 服务器
- @elaraai/e3-api测试: 共享 API 合规测试套件
链接
- 网站数字 : https://elaai.com/ (中文(简体) )
- 仓库数字 : https://github.com/elaraai/east-workspace/tree/main/libs/east 页面存档备份,存于互联网档案馆
- 问题数字 : https://github.com/elaraai/east-workspace/issues (中文(简体) )
- 电子邮件数字 : 支助@elara.ai
关于埃拉拉
东方由 Elara AI Pty有限公司一个由AI驱动的平台 创造经济数字双胞胎 企业优化业绩。 Elara将业务目标、决定和数据结合起来,以帮助各组织在业务、采购、销售和客户参与以及项目和投资规划方面作出由数据驱动的决定。 东能给以埃拉拉解决方案的计算层,使得复杂的商业逻辑和数据能够以简单,类型安全和可移植的语言来表达.
开发者 Elara AI Pty有限公司。 。 。 .
开发者 Elara AI Pty有限公司