library=
[dependencies]
-git://onyxlang.io/repo/http-server=0.1.19
-git://onyxlang.io/repo/postgres-orm=0.0.24
-git://onyxlang.io/repo/otmp=0.0.6
+git://onyxlang.io/repo/http-server=0.1.22
+git://onyxlang.io/repo/postgres-orm=0.0.25
+git://onyxlang.io/repo/otmp=0.0.7
[dependency_folders]
git://onyxlang.io/repo/http-server=http-server
+use core {package, *}
+use runtime
+use otmp
+use http
+use http.server {Req :: Request, Res :: Response, route}
+
#inject runtime.vars {
Enable_Heap_Debug :: true
Debug :: true
}
-use core
-use http.server {Req :: Request, Res :: Response, route}
-
reg: otmp.TemplateRegistry;
#inject Res {
render :: (r: &Res, template: str, vars: any) {
res->render("pages/homepage", null);
}
+
+@route.{.GET, "/ovmwasm"}
+(req: &Req, res: &Res) {
+ res->render("pages/ovmwasm", null);
+}
+
@route.{.GET, "/docs"}
(req: &Req, res: &Res) {
res->render("pages/docs", null);
res->render("pages/docs/install", null);
}
-@route.{.GET, "/news"}
+@route.{.GET, "/news/:article"}
(req: &Req, res: &Res) {
- if a := req.query->get_opt("a"); a {
- filename := tprintf("www/news-articles/{}.html", a.value);
- if os.file_exists(filename) {
- article := os.get_contents(filename);
- defer delete(&article);
-
- res->render("pages/news_article", &.{
- article = article
- });
- }
+ // TODO: Safety / error checking here
+ filename := tprintf("www/news-articles/{}.html", req.url_params["article"]);
+
+ if os.file_exists(filename) {
+ article := os.get_contents(filename);
+ defer delete(&article);
+
+ res->render("pages/news_article", &.{
+ article = article
+ });
} else {
- articles := make([..] str);
+ res->status(404);
+ }
+}
- for os.list_directory("www/news-articles") {
- name := it->name();
- if string.ends_with(name, ".html") {
- articles << string.temp_copy(name[0 .. name.length-5]);
- }
- }
+@route.{.GET, "/news"}
+(req: &Req, res: &Res) {
+ articles := make([..] str);
- res->render("pages/news", &.{
- articles = articles
- });
+ for os.list_directory("www/news-articles") {
+ name := it->name();
+ if string.ends_with(name, ".html") {
+ articles << string.temp_copy(name[0 .. name.length-5]);
+ }
}
+
+ res->render("pages/news", &.{
+ articles = articles
+ });
}
main :: () {
logger := http.server.logger();
app->pipe(&logger);
- app->serve(8080);
+ app->serve(8081);
println("Server stopping...");
}
--- /dev/null
+<div class="container">
+ <h1>Onyx's Custom Runtime</h1>
+
+ <p>
+ As Onyx targets WebAssembly (WASM) exclusively, running code outside of the browser requires a <a href="https://webassembly.github.io/spec/core/appendix/embedding.html">WASM embedder</a>.
+ The job of the embedder is to translate the WASM Virtual Instruction Set Architecture into a "real" architecture that can be executed on the host system.
+ There are many great WASM embedders that exist for running WASM outside the browser. Here's a small, non-comprehensive list:
+ </p>
+ <ul>
+ <li><a href="https://wasmer.io">Wasmer</a></li>
+ <li><a href="https://wasmtime.dev">Wasmtime</a></li>
+ <li><a href="https://github.com/wasm3/wasm3">Wasm3</a></li>
+ <li><a href="https://wasmedge.org">WasmEdge</a></li>
+ </ul>
+
+ <p>
+ All of these embedders are great in their own way, but the one thing they are not <em>great</em> at is providing a great developer experience for Onyx. For this reason, Onyx maintains support for two WASM embedders: <em>Wasmer</em> and <em>OVM-Wasm</em>. Wasmer is used as the faster, production-ready embedder, while OVM-Wasm is used as the development embedder.
+ </p>
+
+ <p>
+ OVM-Wasm stands for <em>Onyx Virtual Machine for WASM</em>. The Onyx Virtual Machine (OVM) started as a separate project with the goal of providing a separate compile-target for Onyx; however, to reduce complexity, OVM-Wasm was created as a wrapper around OVM, that provides a <a href="https://github.com/WebAssembly/wasm-c-api">wasm-c-api</a> compatible interface, making it a WASM embedder.
+ Since OVM-Wasm is entirely specific to Onyx and can be easily modified to suit the needs of developing Onyx.
+ It has more features compared to a normal WASM embedder, such a <em>debugging interface</em> that is compatible with the Debug Adapter Protocol.
+ </p>
+
+ <p>
+ Currently, it does not run as fast as it could.
+ This is due to several reason, but largely because it simply compiles WebAssembly down to an <em>interpreted</em> instruction stream, not machine-native instructions.
+ This was done to make OVM-Wasm more portable, but does come at a significant performance cost.
+ To compound onto this fact, the instruction stream itself is not optimized <em>at all</em>.
+ It is the most literal, WASM to OVM conversion possible.
+ This helps make the initial startup time faster, but does incur wasted performance.
+ It is on the (rather large) list of to-dos to add simple optimizations to the embedding process to make OVM-Wasm not <em>horribly</em> slow.
+ </p>
+</div>
margin: 0 auto;
}
+.container > p {
+ margin-top: 20px;
+}
+
+.container ul {
+ padding-left: 20px;
+}
+
.container.center {
display: flex;
justify-content: center;
/* Nagivation */
.navbar-container {
max-width: 1200px;
+ width: 1200px;
margin: 0 auto;
}
text-align: justify;
}
+
+main {
+ min-height: 100vh;
+ display: grid;
+ grid-template-rows: auto 1fr auto;
+}
+
"for", "while", "do",
"switch", "case",
"break", "continue", "return", "defer", "fallthrough",
- "as", "cast", "sizeof", "alignof", "typeof"
+ "cast", "sizeof", "alignof", "typeof"
],
literal: "true false null null_proc null_str",
- type: "i8 u8 i16 u16 i32 u32 i64 u64 f32 f64 rawptr str cstr i8x16 i16x8 i32x4 i64x2 f32x4 f64x2 v128 type_expr any",
+ type: "i8 u8 i16 u16 i32 u32 i64 u64 f32 f64 rawptr str cstr dyn_str i8x16 i16x8 i32x4 i64x2 f32x4 f64x2 v128 type_expr any",
built_in: "math map set array random iter list conv type_info",
},
{{block "content"}}
-{% partial "partials/navbar" %}
-
<main>
+ {% partial "partials/navbar" %}
+
<div class="container">
<h1>404 - Page not found</h1>
</div>
<ul>
<li><a href="/docs/install">Installation</a></li>
<li>Getting Started</li>
- <li>Language Reference</li>
- <li>Useful Packages</li>
+ <li>Language Reference Book</li>
+ <li>Packages</li>
+ <ul>
+ <li><a href="https://docs.onyxlang.io/packages/core">Core packages</a></li>
+ </ul>
</ul>
</div>
<div class="container">
<h1>Installing Onyx</h1>
+ <p>
+ <a href="#online">Online</a>
+ <a href="#linux">Linux</a>
+ <a href="#windows">Windows</a>
+ <a href="#macos">MacOS</a>
+ </p>
</div>
-<div class="container light">
+<div class="container light" id="online">
<h2>Try Online</h2>
<p>
Onyx is available to try online for free in <a href="/playground/">Onyx Playground</a>.
- It allows you learn the syntax from examples, without installing the language.
+ It allows you learn the syntax from examples, without installing the language onto your system.
</p>
</div>
-<div class="container">
+<div class="container" id="linux">
<h2>Linux</h2>
+ <p>
+ </p>
</div>
-<div class="container">
+<div class="container" id="windows">
<h2>Windows</h2>
+ <p>
+ </p>
</div>
-<div class="container">
+<div class="container" id="macos">
<h2>MacOS</h2>
+ <p>
+ MacOS support is not being actively worked on at the moment. In theory, if the compiler would work on MacOS, WebAssembly binaries would have no problem running using Wasmer, Wasmtime, or a similar runtime. Onyx is always open for contributions from others on its <a href="https://github.com/onyx-lang/onyx/pulls">pull requests</a>.
+ </p>
</div>
<ul style="font-size: larger;">
<li>Runs everywhere using <a href="https://webassembly.org">WebAssembly</a></li>
<li>Fast compilation times (300,000+ lines / second)</li>
- <li>Self-hosted, debuggable runtime using <a href="/ovmwasm">OVM-Wasm</a></li>
+ <li>Self-hosted, debuggable runtime using <a href="/news/ovmwasm">OVM-Wasm</a></li>
<li>Secure runtime using <a href="https://wasmer.io">Wasmer</a></li>
</ul>
</div>
- <pre class="hljs" style="overflow-y: scroll; width: 40%; border: 2px solid black; padding: 8px; display: block"><code class="language-onyx">use core
+ <pre class="hljs" style="overflow-y: scroll; width: 40%; border: 2px solid black; padding: 8px; display: block"><code class="language-onyx">use core {println}
main :: () {
f := factorial(10);
<div class="panel-container">
<div>
<h3>Portable</h3>
- <p>By targetting WASM, Onyx can used in the browser, or natively with a custom runtime.</p>
+ <p>By targetting WASM, Onyx can be used in the browser, or natively with a <a href="/news/ovmwasm">custom runtime</a>.</p>
</div>
<div>
<h3>Data-Oriented</h3>
<ul>
{{ foreach $article in $articles }}
<li>
- <a href="/news?a={% $article %}">{% $article %}</a>
+ <a href="/news/{% $article %}">{% $article %}</a>
</li>
{{ endforeach }}
</ul>
{{block "content"}}
-{% partial "partials/navbar" %}
-
<main>
+ {% partial "partials/navbar" %}
+
<div class="container">
{% $article %}
</div>
<main>
{% partial "partials/navbar" %}
-{% block "page_content" %}
+<div>
+ {% block "page_content" %}
+</div>
{% partial "partials/footer" %}
</main>