Common data types like numbers, strings, tags, lists, maps, and objects are available. Type coercion happens where it makes sense and becomes stricter as the user introduces gradual typing. To see a comprehensive overview of the language, see the Documentation.
Cyber plans to implement gradual typing. The types in Cyber is not just for type checking, but also for generating fewer and more efficient bytecode resulting in faster script execution. See the Recursive Fibonacci benchmark for an example of this.
With the help of libtcc, Cyber makes binding to existing C ABI compatible libraries simple. This allows you to call into dynamic libraries created in C or other languages. Calling into external functions is JIT compiled which makes them fast. To learn how it works, see FFI Docs.
Unlike other dynamic languages, Cyber uses ARC or automatic reference counting to manage memory. ARC consumes less memory overhead and reduces GC pauses which makes Cyber suitable for realtime applications. ARC is also deterministic unlike tracing GCs which usually run on a separate thread(s).
Minimal reference counting.
Due to the compiler design in Cyber, the number of retain/release operations is reduced since the compiler can infer value types even though they are dynamically typed to the user. Arguments passed to functions are only retained depending on the analysis from the callsite. ARC expressions do not retain temporary values unless it is required for the happy path. In the rare case that a temporary value is released before it is used, the value behaves as if it was the `none` value.
No memory leaks.
By default, references that outlive the first release op are tracked by the VM. The VM then checks for abandoned reference cycles automatically and frees them. The check can also be explicitly triggered in the user's script. For embedders, the automatic check can be turned off and triggered manually by the VM host.
To reduce the amount of references the VM has to keep track of, Cyber provides a `weak` type annotation. A weak reference does not retain the underlying object and automatically becomes the `none` value when it is freed by the VM.
Cyber supports cooperative concurrency with fibers. It also plans to support preemptive concurrency as async/await mechanisms. Multithread support will be implemented as actors/channels.
Cyber exposes fibers to the user with the `coinit`, `coresume`, and `coyield` keywords. Just like other objects in Cyber, fibers are allocated and freed by ARC. Due to the design of the VM, the execution context can be switched quickly which makes fibers fast in Cyber. Fibers can start on any function call and yield from anywhere down the call stack. You can see the Fibers benchmark to see how Cyber compares with other VMs.
Async/await mechanisms are planned in Cyber.
Cyber wants to give user scripts the ability to run code in parallel while being easier to reason about. These conditions make the actor model and channels great ideas for multi-threading.
Tag types in Cyber is similar to enums in other languages. New tag types can be declared with the `tagtype` keyword. Once a value is known to be tagged, it can be assigned with a tag literal. Tag literals used by themselves also get their own unique id unrelated to any tag types. This allows them to be global unique symbols.
You can embed Cyber into your app, game, or engine. One of the goals for Cyber is to provide the host more control over user script execution.
Cyber will allow the host to insert gas mileage checks in user scripts. This allows the host to control how long a script can run.
There is still quite some work to complete the features described and to become more stable as a language. There are also 1.0 features that are too early to mention at this time.
If you like Cyber, please consider supporting the project via Github Sponsors or Patreon!