From efefd704f788c85b2731045ad927738b670b2de9 Mon Sep 17 00:00:00 2001 From: Jeff Date: Tue, 26 Dec 2023 23:30:33 -0500 Subject: [PATCH] Write README; Fix bench script --- README.md | 31 +++++++++++++++++++++++-------- scripts/bench.fish | 15 ++++++++------- 2 files changed, 31 insertions(+), 15 deletions(-) mode change 100644 => 100755 scripts/bench.fish diff --git a/README.md b/README.md index 67083a6..86cf48a 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ Dust is an interpreted, strictly typed language with first class functions. It e - Simplicity: Dust is designed to be easy to learn. - Speed: Dust is built on [Tree Sitter] and [Rust] to prioritize performance and correctness. See [Benchmarks] below. -- Concurrency: A safe approach to parallelism. +- Concurrency: Safe, effortless parallel code using thread pools. - Safety: Written in safe, stable Rust. - Correctness: Type checking makes it easy to write good code. @@ -59,10 +59,9 @@ Dust is an interpreted, strictly typed language with first class functions. It e Dust is an experimental project under active development. At this stage, features come and go and the API is always changing. It should not be considered for serious use yet. -To get help with the shell you can use the "help" tool. - -```dust -(help) # Returns a table with tool info. +```sh +cargo install dust-lang +dust -c "(output 'Hello world!')" ``` ## Installation @@ -140,6 +139,7 @@ Variables have two parts: a key and a value. The key is always a string. The val - boolean - list - map +- option - function Here are some examples of variables in dust. @@ -168,7 +168,6 @@ numbers <[number]> = [integer float] stuff <[any]> = [string integer float] ``` - ### Lists Lists are sequential collections. They can be built by grouping values with square brackets. Commas are optional. Values can be indexed by their position using a colon `:` followed by an integer. Dust lists are zero-indexed. @@ -221,10 +220,10 @@ for number in list { ### Functions -Functions are first-class values in dust, so they are assigned to variables like any other value. It is good practice to write the type definition for functions, otherwise the argument types and return type are set to `any`. +Functions are first-class values in dust, so they are assigned to variables like any other value. ```dust -# This simple function has no arguments. +# This simple function has no arguments and no return value. say_hi = (fn) { (output "hi") } @@ -240,6 +239,22 @@ add_one = (fn number ) { You don't need commas when listing arguments and you don't need to add whitespace inside the function body but doing so may make your code easier to read. +### Option + +The **option** type represents a value that may not be present. It has two variants: **some** and **none**. Dust includes built-in functions to work with option values: `is_none`, `is_some` and `either_or`. + +```dust +say_something = (fn message ) { + (either_or message, "hiya") +} + +(say_something some("goodbye")) +# goodbye + +(say_something none) +# hiya +``` + ### Concurrency Dust features effortless concurrency anywhere in your code. Any block of code can be made to run its contents asynchronously. Dust's concurrency is written in safe Rust and uses a thread pool whose size depends on the number of cores available. diff --git a/scripts/bench.fish b/scripts/bench.fish old mode 100644 new mode 100755 index 47ba13f..e35006e --- a/scripts/bench.fish +++ b/scripts/bench.fish @@ -1,3 +1,4 @@ +#!/usr/bin/fish # This script is has the following prerequisites (aside from fish): # - hyperfine # - dust (can be installed with "cargo install dust-lang") @@ -6,11 +7,11 @@ # - nushell # - dielectron.json (can be downloaded from https://opendata.cern.ch/record/304) -hyperfine - --shell none - --parameter-list data_path examples/assets/seaCreatures.json,examples/assets/jq_data.json,dielectron.json - --warmup 3 - "dust -c '(length (from_json input))' -p {data_path}" - "jq 'length' {data_path}" - "node --eval \"require('node:fs').readFile('{data_path}', (err, data)=>{console.log(JSON.parse(data).length)})\"" +hyperfine \ + --shell none \ + --parameter-list data_path examples/assets/seaCreatures.json,examples/assets/jq_data.json,dielectron.json \ + --warmup 3 \ + "dust -c '(length (from_json input))' -p {data_path}" \ + "jq 'length' {data_path}" \ + "node --eval \"require('node:fs').readFile('{data_path}', (err, data)=>{console.log(JSON.parse(data).length)})\"" \ "nu -c 'open {data_path} | length'"