dust/README.md

87 lines
2.7 KiB
Markdown
Raw Normal View History

2023-08-22 15:40:50 +00:00
# Dust
High-level programming language with effortless concurrency, automatic memory management, type safety and strict error handling.
2024-02-19 20:35:27 +00:00
2024-02-19 22:22:14 +00:00
![Dust version of an example from The Rust Programming Language.](https://git.jeffa.io/jeff/dust/raw/branch/main/docs/assets/example_0.png)
2023-10-13 15:37:07 +00:00
2023-08-23 21:28:19 +00:00
<!--toc:start-->
- [Dust](#dust)
2024-02-19 16:24:54 +00:00
- [Easy to Read and Write](#easy-to-read-and-write)
- [Effortless Concurrency](#effortless-concurrency)
- [Helpful Errors](#helpful-errors)
2024-02-19 16:24:54 +00:00
- [Debugging](#debugging)
- [Automatic Memory Management](#automatic-memory-management)
- [Installation and Usage](#installation-and-usage)
2023-08-23 21:28:19 +00:00
<!--toc:end-->
2024-02-19 16:24:54 +00:00
## Easy to Read and Write
2023-11-16 03:33:58 +00:00
Dust has simple, easy-to-learn syntax.
```js
output('Hello world!')
```
2024-02-19 16:24:54 +00:00
## Effortless Concurrency
2023-11-16 03:33:58 +00:00
Write multi-threaded code as easily as you would write code for a single thread.
```js
async {
output('Will this one print first?')
output('Or will this one?')
output('Who knows! Each "output" will run in its own thread!')
}
```
## Helpful Errors
Dust shows you exactly where your code went wrong and suggests changes.
2024-02-19 22:22:14 +00:00
![Example of syntax error output.](https://git.jeffa.io/jeff/dust/raw/branch/main/docs/assets/syntax_error.png)
## Static analysis
2024-02-19 22:22:14 +00:00
Your code is always validated for safety before it is run. Other interpreted languages can fail halfway through, but Dust is able to avoid runtime errors by analyzing the program *before* it is run.
2024-02-19 22:22:14 +00:00
![Example of type error output.](https://git.jeffa.io/jeff/dust/raw/branch/main/docs/assets/type_error.png)
2024-02-19 16:24:54 +00:00
## Debugging
Just set the environment variable `DUST_LOG=info` and Dust will tell you exactly what your code is doing while it's doing it. If you set `DUST_LOG=trace`, it will output detailed logs about parsing, abstraction, validation, memory management and runtime.
2024-02-19 22:22:14 +00:00
![Example of debug output.](https://git.jeffa.io/jeff/dust/raw/branch/main/docs/assets/debugging.png)
2024-02-19 16:24:54 +00:00
## Automatic Memory Management
2024-02-19 22:22:14 +00:00
Thanks to static analysis, Dust knows exactly how many times each variable is used. This allows Dust to free memory as soon as the variable will no longer be used, without any help from the user.
## Error Handling
2024-02-19 22:22:14 +00:00
Runtime errors are no problem with Dust. The `Result` type represents the output of an operation that might fail. The user must decide what to do in the case of an error.
```dust
match io:stdin() {
Result::Ok(input) -> output("We read this input: " + input)
Result::Error(message) -> output("We got this error: " + message)
}
```
2024-02-19 16:24:54 +00:00
## Installation and Usage
2024-02-19 22:22:14 +00:00
There are two ways to compile Dust. Either way, you must have `rustup`, `cmake` and a C compiler installed.
To install from the git repository:
```fish
git clone https://git.jeffa.io/jeff/dust
cd dust
cargo build --release
```
To install with cargo:
```fish
cargo install dust-lang
```