百科.dev
全部条目AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
D

dyon

> 编程语言
开源

一种生锈的动态类型脚本语言

1.9K stars0 点赞0 次浏览
访问官网GitHub

工具介绍

一种生锈的动态类型脚本语言

Dyon

A rusty dynamically typed scripting language

fn main() {
    println("hello world!")
}

DYON-API | LICENSE-APACHE | LICENSE-MIT

Introduction

Tutorial
Dyon-Interactive
Dyon Snippets
/r/dyon

Dyon script files end with .dyon.

To install Dyon REPL, type:

cargo install --example dyon dyon

Then, to run the Dyon REPL, type:

dyon

To run Dyon script files from command line, type:

cargo install --example dyonrun dyon

Then, to run a script file you type:

dyonrun <file.dyon>

Editor-plugins

Dyon for Atom
Dyon for Vim
Dyon for Visual Studio Code

List of features

  • Array arr := [a, b, c] with lookup arr[0] and lookup with array of indices arr[[0, 0]]
  • Object obj := {x: a, y: b}
  • Number (f64) n := 5.3
  • Boolean t := true
  • Link link { 1 2 "hi" false }
  • Custom Rust objects using Arc<Mutex<Any>>
  • Functions without return fn foo() { ... } and with return fn foo() -> { ... return x }
  • Functions as mathematical expresisons f(x) = x / (x - 1)
  • Optional namespaces with shared aliases ns program::example::test
  • Lifetime checker (no garbage collector is needed) fn foo(mut a, b: 'a) { a.x = b }
  • Return lifetime fn id(x: 'return) -> { return x }
  • Mutability checker fn foo(mut a) { bar(mut a) }
  • Checks type at runtime when mutating variable a = 2.0 // ERROR: Expected assigning to number
  • Objects inserts new key with a.x := 0 and checks existence and type with a.x = 0
  • Named argument syntax based on snake case foo(bar: b) is equal to foo__bar(b)
  • If expression a := if b < c { 0 } else { 1 }
  • For loop for i := 0; i < 10; i += 1 { ... }
  • Short For loop for i 10 { ... } and with offset for i [2, 10) { ... }
  • Infer range from loop body for i { println(list[i]) }
  • Packed loop for i, j { println(list[i][j]) }
  • ∑/sum, ∏/prod, min, max, sift, ∃/any, ∀/all loops
  • Secrets derived from loops why(any i { list[i] > 3 })
  • Link loop
  • Infinite loop loop { ... }
  • Unlabeled break loop { break } and unlabeled continue loop { continue }
  • Labeled break 'a: loop { break 'a } and labeled continue 'a: loop { continue 'a }
  • Use return as a variable without exiting return = 8
  • Dynamic modules m := unwrap(load("script.dyon")) then call(m, "main", [])
  • Import to module prelude m := unwrap(load(source: "script.dyon", imports: [window, graphics]))
  • Add a custom Rust function using Module::add
  • Option values with none() or some(x)
  • Result values with ok(x) or err(x)
  • ? operator to propagate errors, e.g. x := foo()?, maps option to result automatically
  • unwrap(x) prints trace of propagated error
  • functions() returns sorted list of all available functions in a module
  • Optional type system fn could(list: []) -> f64
  • Ad-hoc types fn players() -> [Player str] { ... }
  • Current objects fn render() ~ world { ... }
  • Go-like coroutines with go thread := go foo()
  • In-types concurrency receiver := in foo with for-in loops for x in a {print(x[0]}
  • Closures \(x) = x + 1
  • Grab expressions \(x) = (grab a) + x
  • Lazy invariants fn intersect(a: [] => [], b: [] => []) -> [] { ... }
  • Simple refinement types (vec4) -> vec4
  • 4D vectors with f32 precision (x, y, z, w)
  • 4D matrices with f32 precision mat4 {1,2,3,4; 5,6,7,8; 9,10,11,12; 13,14,15,16}
  • Un-loop for 4D vectors vec4 i f(i)
  • Unpack 4D vectors f(xy v)
  • Swizzle 4D vectors (yxz v, 1)
  • HTML hex colors #fab3ee
  • Meta parsing
  • Macros for embedding in Rust dyon_fn!{fn say_hello() { println!("hi!"); }}
  • Transitive Modules for making Dyon modules behave similar to external functions

Why the name Dyon?

Dyon is a hypothetical particle predicted by several grand unified theories in physics with both electrical and magnetic charge. See this Wikipedia article for more information.

The name Dyon fits because, just like the particle, there are things that are yet to be discovered about language design. However, this language was not born out of a grand new vision, but is the result of exploring and testing new ideas.

Motivation and goals

Sven Nilsen started this project in early 2016. The idea was to make a simple, but convenient scripting language that integrated well with Rust.

  • During the first week of coding, a way to do lifetime checking on function arguments was discovered
  • A different approach to code organization was explored by adding the ability to dynamically load modules
  • For nice error handling, added option, result and ? operator
  • To test the design of the language, created a demo for interactive coding
  • Mutability check to improve readability
  • Short For loop to improve readability and performance
  • Mathematical loops and Unicode symbols to improve readability
  • Go-like coroutines to add multi-thread support
  • 4D vectors with unpack and swizzle to make 2D and 3D programming easier
  • Html hex colors to make copying colors from image editors possible
  • Optional type system to help scaling a project
  • Ad-hoc types for extra type safety
  • Current objects to improve prototyping and tailored environments
  • Macros for easier embedding with Rust
  • Secrets to automatically derive meaning from mathematical loops
  • Closures that can be printed out, use current objects and grab from closure environment
  • Type safety for secrets, easy load/save of Dyon data
  • Link loop for easier and faster code generation and templates
  • In-types for easy cross thread communication
  • Lazy invariants, simple refinement types and binary operator overloading
  • Transitive modules for making Dyon modules behave similar to external functions

Main goals:

  • Integrate well with Rust
  • Flexible way of organizing code

Performance will be optimized for the cycle:

coding -> parsing -> running -> debugging -> coding

Sub goals:

  • Safety

Non-goals:

  • Rust equivalent performance
  • Replace Rust to build libraries
  • Interfacing with other languages than Rust

License

Licensed under either of

  • Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
  • MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT) at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you shall be dual licensed as above, without any additional terms or conditions.

GitHub Issues· 0 开放

在 GitHub 查看全部

暂无开放 Issues,或尚未同步最近议题。

核心特点

  • •Array arr := [a, b, c] with lookup arr[0] and lookup with array of indices arr[[0, 0]]
  • •Object obj := {x: a, y: b}
  • •Number (f64) n := 5.3
  • •Boolean t := true
  • •Link link { 1 2 "hi" false }
  • •Custom Rust objects using Arc<Mutex<Any>>
  • •Functions without return fn foo() { ... } and with return fn foo() -> { ... return x }
  • •Functions as mathematical expresisons f(x) = x / (x - 1)
  • •Optional namespaces with shared aliases ns program::example::test
  • •Lifetime checker (no garbage collector is needed) fn foo(mut a, b: 'a) { a.x = b }

> 标签

Rustdynamicdyonscripting-language

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言