Category:Onyx (wasm): Difference between revisions

From Rosetta Code
Content added Content deleted
No edit summary
No edit summary
Line 1: Line 1:
{{stub}}{{language|site=https://onyxlang.io/}}
{{stub}}{{language|site=https://onyxlang.io/}}
Onyx is a WebAssembly-first language (`app.wasm`). WebAssembly can be used inside of a browser but is also growing in popularity in runtimes (such as Onyx provides itself) outside of the browser, in part due to projects like Wasmer, Wasmtime, and WasmEdge. These "controlled environments" could be game engines, where WASM is used as a "script" system; cloud functions, where WASM is used to respond to requests; plug-in systems for editors or tools.
Onyx is a WebAssembly first language. Onyx aims to make it as easy as possible to start working with WebAssembly. For that reason, Onyx is very well suited for the niche kinds of projects that require using WebAssembly.


Onyx uses a modernized C-like syntax, similar to Jai or Odin. Onyx is an imperative and procedural language in which statement are evaluated in the order they are written in, but does allow for functional-inspired syntax using the pipe operator.
WebAssembly is growing in popularity outside of the browser because of projects like Wasmer, Wasmtime, and WasmEdge that make it easy to run WebAssembly in a controlled environment. These "controlled environments" could be game engines, where WASM is used as a "script" system; cloud functions, where WASM is used to respond to requests; plug-in systems for editors or tools.


For example:
Onyx is an imperative language. You write a sequence of statements that should be executed in the specified order to evaluate your program. This is my preferred style of programming so it is what I made Onyx.
```c
use core { printf, iter }


main :: () {
However, I do enjoy the simplicity of a functional language. The idea of expressing a computation at a higher level appeals to me. Instead of writing a bunch of for-loops, you express what you want to happen, instead of how it should happen.
for i in 1 .. 10 {
fact := factorial(i);
printf("{}! = {}\n", i, fact);
}
}


factorial :: (n: i32) -> i32 {
For this reason, Onyx does have functional-inspired features that make that style of programming accessible.
return iter.as_iter(1 .. n)
|> iter.fold(1, (x, y) => x * y);
}
```

Revision as of 01:26, 12 March 2024

This page is a stub. It needs more information! You can help Rosetta Code by filling it in!
Language
Onyx (wasm)
This programming language may be used to instruct a computer to perform a task.
Official website
See Also:


Listed below are all of the tasks on Rosetta Code which have been solved using Onyx (wasm).

Onyx is a WebAssembly-first language (`app.wasm`). WebAssembly can be used inside of a browser but is also growing in popularity in runtimes (such as Onyx provides itself) outside of the browser, in part due to projects like Wasmer, Wasmtime, and WasmEdge. These "controlled environments" could be game engines, where WASM is used as a "script" system; cloud functions, where WASM is used to respond to requests; plug-in systems for editors or tools.

Onyx uses a modernized C-like syntax, similar to Jai or Odin. Onyx is an imperative and procedural language in which statement are evaluated in the order they are written in, but does allow for functional-inspired syntax using the pipe operator.

For example: ```c use core { printf, iter }

main :: () {

   for i in 1 .. 10 {
       fact := factorial(i);
       printf("{}! = {}\n", i, fact);
   }

}

factorial :: (n: i32) -> i32 {

   return iter.as_iter(1 .. n)
       |> iter.fold(1, (x, y) => x * y);

} ```

Pages in category "Onyx (wasm)"

The following 6 pages are in this category, out of 6 total.