{"id":13440030,"url":"https://github.com/PistonDevelopers/dyon","last_synced_at":"2025-03-20T09:31:34.900Z","repository":{"id":41461648,"uuid":"50216100","full_name":"PistonDevelopers/dyon","owner":"PistonDevelopers","description":"A rusty dynamically typed scripting language","archived":false,"fork":false,"pushed_at":"2024-02-28T23:49:25.000Z","size":2795,"stargazers_count":1766,"open_issues_count":64,"forks_count":56,"subscribers_count":63,"default_branch":"master","last_synced_at":"2024-10-14T22:41:11.031Z","etag":null,"topics":["dynamic","dyon","scripting-language"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PistonDevelopers.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"bvssvni"}},"created_at":"2016-01-23T00:30:05.000Z","updated_at":"2024-10-12T06:06:02.000Z","dependencies_parsed_at":"2023-01-30T18:45:44.545Z","dependency_job_id":"fb04ae2c-4de6-4726-b7f0-2e35d43ba8b2","html_url":"https://github.com/PistonDevelopers/dyon","commit_stats":{"total_commits":982,"total_committers":17,"mean_commits":57.76470588235294,"dds":0.02647657841140527,"last_synced_commit":"065afa9de8548d3ff155fbb461e55f0ec7ea2bd6"},"previous_names":["pistondevelopers/dynamo"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PistonDevelopers%2Fdyon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PistonDevelopers%2Fdyon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PistonDevelopers%2Fdyon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PistonDevelopers%2Fdyon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PistonDevelopers","download_url":"https://codeload.github.com/PistonDevelopers/dyon/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221745212,"owners_count":16873738,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dynamic","dyon","scripting-language"],"created_at":"2024-07-31T03:01:19.129Z","updated_at":"2025-03-20T09:31:34.894Z","avatar_url":"https://github.com/PistonDevelopers.png","language":"Rust","readme":"# Dyon\nA rusty dynamically typed scripting language\n\n```\nfn main() {\n    println(\"hello world!\")\n}\n```\n\n[Tutorial](https://www.piston.rs/dyon-tutorial/)  \n[Dyon-Interactive](https://github.com/PistonDevelopers/dyon/tree/master/interactive)  \n[Dyon Snippets](https://github.com/PistonDevelopers/dyon_snippets)  \n[/r/dyon](https://www.reddit.com/r/dyon/)\n\nDyon script files end with `.dyon`.\n\nTo install Dyon REPL, type:\n\n```\ncargo install --example dyon dyon\n```\n\nThen, to run the Dyon REPL, type:\n\n```\ndyon\n```\n\nTo run Dyon script files from command line, type:\n\n```\ncargo install --example dyonrun dyon\n```\n\nThen, to run a script file you type:\n\n```\ndyonrun \u003cfile.dyon\u003e\n```\n\n### Editor-plugins\n\n[Dyon for Atom](https://github.com/PistonDevelopers/atom-language-dyon)  \n[Dyon for Vim](https://github.com/thyrgle/vim-dyon)  \n[Dyon for Visual Studio Code](https://github.com/martinlindhe/vscode-language-dyon)  \n\n![coding](./images/code.png)\n\n### List of features\n\n- Array `arr := [a, b, c]` with lookup `arr[0]` and [lookup with array of indices](https://github.com/PistonDevelopers/dyon/issues/590) `arr[[0, 0]]`\n- Object `obj := {x: a, y: b}`\n- Number (f64) `n := 5.3`\n- Boolean `t := true`\n- [Link](https://github.com/PistonDevelopers/dyon/issues/227) `link { 1 2 \"hi\" false }`\n- Custom Rust objects using `Arc\u003cMutex\u003cAny\u003e\u003e`\n- Functions without return `fn foo() { ... }` and with return `fn foo() -\u003e { ... return x }`\n- Functions as mathematical expresisons `f(x) = x / (x - 1)`\n- [Optional namespaces with shared aliases](https://github.com/PistonDevelopers/dyon/issues/434) `ns program::example::test`\n- [Lifetime checker](https://github.com/PistonDevelopers/dyon/issues/173) (no garbage collector is needed) `fn foo(mut a, b: 'a) { a.x = b }`\n- [Return lifetime](https://github.com/PistonDevelopers/dyon/issues/173) `fn id(x: 'return) -\u003e { return x }`\n- [Mutability checker](https://github.com/PistonDevelopers/dyon/issues/112) `fn foo(mut a) { bar(mut a) }`\n- [Checks type at runtime when mutating variable](https://github.com/PistonDevelopers/dyon/issues/19) `a = 2.0 // ERROR: Expected assigning to number`\n- [Objects inserts new key](https://github.com/PistonDevelopers/dyon/issues/19) with `a.x := 0` and checks existence and type with `a.x = 0`\n- [Named argument syntax](https://github.com/PistonDevelopers/dyon/issues/26) based on snake case `foo(bar: b)` is equal to `foo__bar(b)`\n- If expression `a := if b \u003c c { 0 } else { 1 }`\n- For loop `for i := 0; i \u003c 10; i += 1 { ... }`\n- [Short For loop](https://github.com/PistonDevelopers/dyon/issues/116) `for i 10 { ... }` and with offset `for i [2, 10) { ... }`\n- [Infer range from loop body](https://github.com/PistonDevelopers/dyon/issues/116) `for i { println(list[i]) }`\n- [Packed loop](https://github.com/PistonDevelopers/dyon/issues/116) `for i, j { println(list[i][j]) }`\n- [`∑`/`sum`, `∏`/`prod`, `min`, `max`, `sift`, `∃`/`any`, `∀`/`all` loops](https://github.com/PistonDevelopers/dyon/issues/119)\n- [Secrets derived from loops](https://github.com/PistonDevelopers/dyon/issues/266) `why(any i { list[i] \u003e 3 })`\n- [Link loop](https://github.com/PistonDevelopers/dyon/issues/418)\n- Infinite loop `loop { ... }`\n- Unlabeled break `loop { break }` and unlabeled continue `loop { continue }`\n- Labeled break `'a: loop { break 'a }` and labeled continue `'a: loop { continue 'a }`\n- [Use `return` as a variable without exiting `return = 8`](https://github.com/PistonDevelopers/dyon/issues/169)\n- [Dynamic modules](https://github.com/PistonDevelopers/dyon/issues/170) `m := unwrap(load(\"script.dyon\"))` then `call(m, \"main\", [])`\n- [Import to module prelude](https://github.com/PistonDevelopers/dyon/issues/170) `m := unwrap(load(source: \"script.dyon\", imports: [window, graphics]))`\n- [Add a custom Rust function](https://github.com/PistonDevelopers/dyon/issues/171) using `Module::add`\n- [Option values](https://github.com/PistonDevelopers/dyon/issues/172) with `none()` or `some(x)`\n- [Result values](https://github.com/PistonDevelopers/dyon/issues/82) with `ok(x)` or `err(x)`\n- `?` operator to propagate errors, e.g. `x := foo()?`, [maps option to result automatically](https://github.com/PistonDevelopers/dyon/issues/172)\n- `unwrap(x)` [prints trace of propagated error](https://github.com/PistonDevelopers/dyon/issues/82)\n- `functions()` returns sorted list of all available functions in a module\n- [Optional type system](https://github.com/PistonDevelopers/dyon/issues/84) `fn could(list: []) -\u003e f64`\n- [Ad-hoc types](https://github.com/PistonDevelopers/dyon/issues/236) `fn players() -\u003e [Player str] { ... }`\n- [Current objects](https://github.com/PistonDevelopers/dyon/issues/224) `fn render() ~ world { ... }`\n- [Go-like coroutines with `go`](https://github.com/PistonDevelopers/dyon/issues/163) `thread := go foo()`\n- [In-types concurrency](https://github.com/PistonDevelopers/dyon/issues/495) `receiver := in foo` with [for-in loops](https://github.com/PistonDevelopers/dyon/issues/520) `for x in a {print(x[0]}`\n- [Closures](https://github.com/PistonDevelopers/dyon/issues/314) `\\(x) = x + 1`\n- [Grab expressions](https://github.com/PistonDevelopers/dyon/issues/316) `\\(x) = (grab a) + x`\n- [Lazy invariants](https://github.com/PistonDevelopers/dyon/issues/640) `fn intersect(a: [] =\u003e [], b: [] =\u003e []) -\u003e [] { ... }`\n- [Simple refinement types](https://github.com/PistonDevelopers/dyon/issues/636) `(vec4) -\u003e vec4`\n- [4D vectors with `f32` precision `(x, y, z, w)`](https://github.com/PistonDevelopers/dyon/issues/144)\n- [4D matrices with `f32` precision `mat4 {1,2,3,4; 5,6,7,8; 9,10,11,12; 13,14,15,16}`](https://github.com/PistonDevelopers/dyon/issues/557)\n- [Un-loop for 4D vectors](https://github.com/PistonDevelopers/dyon/issues/201) `vec4 i f(i)`\n- [Unpack 4D vectors](https://github.com/PistonDevelopers/dyon/issues/213) `f(xy v)`\n- [Swizzle 4D vectors](https://github.com/PistonDevelopers/dyon/issues/213) `(yxz v, 1)`\n- [HTML hex colors](https://github.com/PistonDevelopers/dyon/issues/167) `#fab3ee`\n- [Meta parsing](https://github.com/PistonDevelopers/dyon/issues/168)\n- [Macros for embedding in Rust](https://github.com/PistonDevelopers/dyon/blob/master/examples/functions.rs) `dyon_fn!{fn say_hello() { println!(\"hi!\"); }}`\n\n### Why the name Dyon?\n\nDyon is a hypothetical particle predicted by several grand unified theories in physics with both electrical and magnetic charge. See this [Wikipedia article](https://en.wikipedia.org/wiki/Dyon) for more information.\n\nThe name Dyon fits because, just like the particle, there are things that are yet to be discovered about language design.\nHowever, this language was not born out of a grand new vision,\nbut is the result of exploring and testing new ideas.\n\n### Motivation and goals\n\n[Sven Nilsen](https://github.com/bvssvni/) started this project in early 2016.\nThe idea was to make a simple, but convenient scripting language that integrated well with Rust.\n\n- During the first week of coding, a way to do lifetime checking on function arguments was discovered\n- A different approach to code organization was explored by adding the ability to dynamically load modules\n- For nice error handling, added option, result and `?` operator\n- To test the design of the language, created a demo for interactive coding\n- Mutability check to improve readability\n- Short For loop to improve readability and performance\n- Mathematical loops and Unicode symbols to improve readability\n- Go-like coroutines to add multi-thread support\n- 4D vectors with unpack and swizzle to make 2D and 3D programming easier\n- Html hex colors to make copying colors from image editors possible\n- Optional type system to help scaling a project\n- Ad-hoc types for extra type safety\n- Current objects to improve prototyping and tailored environments\n- Macros for easier embedding with Rust\n- Secrets to automatically derive meaning from mathematical loops\n- Closures that can be printed out, use current objects and grab from closure environment\n- Type safety for secrets, easy load/save of Dyon data\n- Link loop for easier and faster code generation and templates\n- In-types for easy cross thread communication\n- Lazy invariants, simple refinement types and binary operator overloading\n\nMain goals:\n\n- Integrate well with Rust\n- Flexible way of organizing code\n\nPerformance will be optimized for the cycle:\n\n```\ncoding -\u003e parsing -\u003e running -\u003e debugging -\u003e coding\n```\n\nSub goals:\n\n- Safety\n\nNon-goals:\n\n- Rust equivalent performance\n- Replace Rust to build libraries\n- Interfacing with other languages than Rust\n\n## License\n\nLicensed under either of\n * Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)\n * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)\nat your option.\n\n### Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally submitted\nfor inclusion in the work by you shall be dual licensed as above, without any\nadditional terms or conditions.\n","funding_links":["https://github.com/sponsors/bvssvni"],"categories":["Libraries","Rust","Uncategorized","库 Libraries","库"],"sub_categories":["Scripting","Uncategorized","脚本 Scripting","脚本编写"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FPistonDevelopers%2Fdyon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FPistonDevelopers%2Fdyon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FPistonDevelopers%2Fdyon/lists"}