From: Brendan Hansen Date: Sat, 14 Oct 2023 23:54:43 +0000 (-0500) Subject: misc improvements X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=2fe8b27e20187ed4e8a9b957d3576e9198a46bcf;p=onyxlang.io.git misc improvements --- diff --git a/src/app.onyx b/src/app.onyx index 2eee6d8..f7f7083 100644 --- a/src/app.onyx +++ b/src/app.onyx @@ -7,13 +7,14 @@ use core.encoding.json #inject runtime.vars { Enable_Heap_Debug :: true - // Debug :: true + Debug :: true } reg: otmp.TemplateRegistry; #inject Res { render :: (r: &Res, template: str, vars: any) { - s := reg->render_template(template, &r.writer, .{ vars.data, vars.type }); + m := misc.any_to_map(vars) ?? make(Map(str, any)); + s := reg->render_template(template, &r.writer, &m); if s != .None { log(.Warning, "Template Renderer", tprintf("{}", s)); diff --git a/www/static/css/new_style.css b/www/static/css/new_style.css index 077bb77..d542f18 100644 --- a/www/static/css/new_style.css +++ b/www/static/css/new_style.css @@ -137,7 +137,11 @@ a:visited { h1 { min-width: 100px; - font-size: 2.5rem; + font-size: 3rem; +} + +h2 { + font-size: 2rem; } h1, h2, h3, h4, h5, h6 { @@ -206,6 +210,11 @@ navbar div { navbar a span { display: inline-block; padding: 12px 24px; + transition: all 0.3s; +} + +navbar a span.active { + border-bottom: 3px solid var(--active-color); } navbar a span:hover { @@ -313,13 +322,14 @@ main { } main pre { - border: 2px solid var(--dark-background-color); - border-radius: 4px; + border: 0px solid var(--dark-background-color); + border-radius: 6px; box-shadow: 0px 1px 6px 1px rgba(0, 0, 0, 0.2); padding: 8px; display: block; overflow-y: auto; overflow-x: auto; + margin-top: 10px !important; } pre code { diff --git a/www/templates/pages/base.html b/www/templates/pages/base.html index 31b8108..dd5329c 100644 --- a/www/templates/pages/base.html +++ b/www/templates/pages/base.html @@ -14,6 +14,7 @@ diff --git a/www/templates/pages/docs.html b/www/templates/pages/docs.html index 1413ecc..613d866 100644 --- a/www/templates/pages/docs.html +++ b/www/templates/pages/docs.html @@ -2,6 +2,8 @@ Onyx Documentation {{ endblock }} +{{ let navbar_page = "docs" }} + {{ block "page_content" }}
diff --git a/www/templates/pages/docs/install.html b/www/templates/pages/docs/install.html index 474bb52..cfc1e74 100644 --- a/www/templates/pages/docs/install.html +++ b/www/templates/pages/docs/install.html @@ -1,5 +1,7 @@ {{block "title"}}Onyx Installation{{endblock}} +{{ let navbar_page = "docs" }} + {{ block "page_content" }}
diff --git a/www/templates/pages/docs/setup.html b/www/templates/pages/docs/setup.html index f20ed39..2592aa7 100644 --- a/www/templates/pages/docs/setup.html +++ b/www/templates/pages/docs/setup.html @@ -1,9 +1,14 @@ {{block "title"}}Onyx Environment Setup{{endblock}} +{{ let navbar_page = "docs" }} + {{ block "page_content" }}

Setting Up Your Environment for Onyx

+ +

The following sections will help set up an environment for you to program Onyx effectively.

+

LSP Vim / Neovim @@ -11,9 +16,13 @@ Sublime text Emacs

+ +

+ (If you don't see your favorite editor here, consider making a issue!) +

-
+

Language Server

If you are unfamiliar, a Language Server abstracts the tooling and language specific functionality out of editors and into a reusable component. @@ -80,7 +89,7 @@ lspconfig.onyx.setup { }

-
+

Vim / Neovim

Follow the instructions on the onyx.vim GitHub repo. @@ -91,7 +100,7 @@ lspconfig.onyx.setup {

-
+

Visual Studio Code

Currently, Onyx does not have a published extension for Visual Studio Code, but you are able to install it manually. In your downloaded or cloned copy of Onyx, there is a misc/vscode folder, which contains multiple versions of the Onyx extension. @@ -108,14 +117,14 @@ lspconfig.onyx.setup {

This extension does have support for the onyx-lsp, assuming that is setup.

-
+

Sublime Text

Currently, Onyx does not have a published package on Sublime Text's Package Control, but like VS Code, you are able to install it manually. In the misc folder, there is a file called onyx.sublime-syntax. Simply copy this into the Packages/User folder for Sublime Text. See more details here.

-
+

Emacs

Currently, Onyx does not have a published package for Emacs. In the misc folder, there is an Emacs Lisp file that provides an onyx-mode. You should be able to load it into your Emacs config and enable onyx-mode to get syntax highlighting. diff --git a/www/templates/pages/homepage.html b/www/templates/pages/homepage.html index f76ac90..03d1df3 100644 --- a/www/templates/pages/homepage.html +++ b/www/templates/pages/homepage.html @@ -2,48 +2,145 @@ The Onyx Programming Language {{ endblock }} +{{ let navbar_page = "home" }} + {{ block "page_content" }} -

-

The Onyx Programming Language

+
+
+

The Onyx Programming Language

+
+
+

A data-oriented, safe, and modern programming language

+
+
+ +
+

Recent News

+{% partial "partials/news_listing" %} -
-

Onyx is a data-oriented, safe, and modern programming language for application development

+
+

Overview

-
-

Overview

+

Syntax


- -
    -
  • Runs everywhere using WebAssembly
  • -
  • Lightning fast compilation
  • -
  • Self-hosted, debuggable runtime using OVM-Wasm
  • -
  • Secure and fast runtime using Wasmer
  • -
+

Onyx uses a modernized C-like syntax, similar to Jai or Odin. Start learning the syntax from official Language Reference Book.

-
use core {println}
+    
use core { printf, iter }
 
 main :: () {
-    f := factorial(10);
-    println(f);
+    for i: 1 .. 10 {
+        fact := factorial(i);
+        printf("{}! = {}\n", i, fact);
+    }
 }
 
 factorial :: (n: i32) -> i32 {
-    k := 1;
-    for 1 .. n+1 do k *= it;
-    return k;
+    return iter.as_iter(1 .. n)
+        |> iter.fold(1, (x, y) => x * y);
 }
 
+ +
+
+

Type Safety

+
+

Onyx is strictly type-checked. However, the type-inference systems in Onyx usually allow you to omit types.

+
+ +
use core { printf }
+
+main :: () {
+    // Inferred variable type
+    x := 10;
+
+    // Function with entirely infered types.
+    change_value :: x => x + 10;
+
+    // Onyx figures out the types of `change_value` when you call it.
+    printf("The value is {}.\n", change_value(x));
+}
+
+ +
+ +
+
+

Compilation

+
+

Onyx's compiler is written entirely in C and features incredibly fast compilation. The web-server for this website was compiled in 49 milliseconds.

+
+ +
$ onyx build -V ./src/app.onyx
+File search path:
+        /usr/share/onyx
+        .
+
+Type table size: 131244 bytes.
+Foreign blocks size: 8 bytes.
+Tagged procedure size: 504 bytes.
+Tagged global size: 8 bytes.
+
+Statistics:
+    Time taken: 49.000000 ms
+    Processed 20607 lines (420551.031250 lines/second).
+    Processed 107338 tokens (2190571.500000 tokens/second)
+
+
+

WebAssembly

+
+

Onyx compiles solely to WebAssembly. You can use the builtin WebAssembly runtime using onyx run, or compile to WASM and run using a WebAssembly runner, like Wasmer or Wasmtime.

+
+ +
# Compile and run directly.
+$ onyx run hello.onyx
+Hello, World!
+
+# This time target 'WASI'.
+$ onyx build -r wasi -o hello.wasm hello.onyx
+
+# Run using Wasmer.
+$ wasmer run hello.wasm
+Hello, World!
+
+
+ +
+
+

C-FFI

+
+

Onyx features built-in support for linking to native C-libraries.

+
+ +
use core {*}
+
+// Using #dyncall dynamically loads the library at runtime.
+#foreign #dyncall "libc.so" {
+    write :: (fd: i32, data: [&] u8, count: i32) -> i32 ---
+}
+
+main :: () {
+    msg: [] u8 = "Hello, libc!";
+
+    write(1, msg.data, msg.length);
+}
+    
+
+ +
+
+ + -
-

Recent News

- {% partial "partials/news_listing" %} -
{{endblock}} diff --git a/www/templates/pages/news.html b/www/templates/pages/news.html index 8842dfc..17ee123 100644 --- a/www/templates/pages/news.html +++ b/www/templates/pages/news.html @@ -1,5 +1,7 @@ {{block "title"}}Onyx News{{endblock}} +{{ let navbar_page = "news" }} + {{block "page_content"}}
diff --git a/www/templates/pages/news_article.html b/www/templates/pages/news_article.html index a19f0f2..3a9224b 100644 --- a/www/templates/pages/news_article.html +++ b/www/templates/pages/news_article.html @@ -1,5 +1,7 @@ {{block "title"}}Onyx News - {% $article.name %}{{endblock}} +{{ let navbar_page = "news" }} + {{block "content"}}
diff --git a/www/templates/partials/navbar.html b/www/templates/partials/navbar.html index 8e733af..64c16b1 100644 --- a/www/templates/partials/navbar.html +++ b/www/templates/partials/navbar.html @@ -18,10 +18,10 @@ diff --git a/www/templates/partials/news_listing.html b/www/templates/partials/news_listing.html index 2ed80be..129ceac 100644 --- a/www/templates/partials/news_listing.html +++ b/www/templates/partials/news_listing.html @@ -1,10 +1,15 @@ {{ foreach $article in $articles }} {{ endforeach }}