Write README; Fix bench script
This commit is contained in:
parent
226c1e806f
commit
efefd704f7
31
README.md
31
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 <num>) <num> {
|
||||
|
||||
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 <option(str)>) <str> {
|
||||
(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.
|
||||
|
15
scripts/bench.fish
Normal file → Executable file
15
scripts/bench.fish
Normal file → Executable file
@ -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'"
|
||||
|
Loading…
Reference in New Issue
Block a user