Improve writeup.
This commit is contained in:
@@ -7,6 +7,9 @@ Rhai is an embedded scripting language and evaluation engine for Rust that gives
|
||||
to add scripting to any application.
|
||||
|
||||
|
||||
This Book is for version {{version}} of Rhai.
|
||||
Versions
|
||||
--------
|
||||
|
||||
This Book is for version **{{version}}** of Rhai.
|
||||
|
||||
For the latest development version, see [here]({{rootUrl}}/vnext/).
|
||||
|
@@ -6,9 +6,10 @@ Licensing
|
||||
Rhai is licensed under either:
|
||||
|
||||
* [Apache License, Version 2.0]({{repoHome}}/LICENSE-APACHE.txt), or
|
||||
|
||||
* [MIT license]({{repoHome}}/LICENSE-MIT.txt)
|
||||
|
||||
at your option.
|
||||
at your choice.
|
||||
|
||||
Unless explicitly stated otherwise, any contribution intentionally submitted for inclusion in this crate,
|
||||
as defined in the Apache-2.0 license, shall be dual-licensed as above,
|
||||
|
@@ -18,21 +18,38 @@ It doesn't attempt to be a new language. For example:
|
||||
|
||||
* No first-class functions - Code your functions in Rust instead, and register them with Rhai.
|
||||
|
||||
There is, however, support for simple [function pointers] allowing runtime dispatch by function name.
|
||||
There is, however, support for simple [function pointers] to allow runtime dispatch by function name.
|
||||
|
||||
* No garbage collection - this should be expected, so...
|
||||
|
||||
* No closures - do your closure magic in Rust instead; [turn a Rhai scripted function into a Rust closure]({{rootUrl}}/engine/call-fn.md).
|
||||
|
||||
But you can [curry][currying] a [function pointer] with arguments to simulate it somewhat.
|
||||
|
||||
* No byte-codes/JIT - Rhai has an AST-walking interpreter which will not win any speed races. The purpose of Rhai is not
|
||||
to be extremely _fast_, but to make it as easy as possible to integrate with native Rust applications.
|
||||
|
||||
|
||||
Do Not Write The Next 4D VR Game in Rhai
|
||||
---------------------------------------
|
||||
|
||||
Due to this intended usage, Rhai deliberately keeps the language simple and small by omitting advanced language features
|
||||
such as classes, inheritance, first-class functions, closures, concurrency, byte-codes, JIT etc.
|
||||
|
||||
Avoid the temptation to write full-fledge application logic entirely in Rhai - that use case is best fulfilled by
|
||||
more complete languages such as JavaScript or Lua.
|
||||
|
||||
Therefore, in actual practice, it is usually best to expose a Rust API into Rhai for scripts to call.
|
||||
All your core functionalities should be in Rust.
|
||||
|
||||
Thin Dynamic Wrapper Layer Over Rust Code
|
||||
----------------------------------------
|
||||
|
||||
In actual practice, it is usually best to expose a Rust API into Rhai for scripts to call.
|
||||
|
||||
All the core functionalities should be written in Rust, with Rhai being the dynamic _control_ layer.
|
||||
|
||||
This is similar to some dynamic languages where most of the core functionalities reside in a C/C++ standard library.
|
||||
|
||||
Another similar scenario is a web front-end driving back-end services written in a systems language.
|
||||
In this case, JavaScript takes the role of Rhai while the back-end language, well... it can actually also be Rust.
|
||||
Except that Rhai integrates with Rust _much_ more tightly, removing the need for interfaces such
|
||||
as XHR calls and payload encoding such as JSON.
|
||||
|
Reference in New Issue
Block a user