hugo website for pit
This commit is contained in:
30
website/content/_index.md
Normal file
30
website/content/_index.md
Normal file
@@ -0,0 +1,30 @@
|
||||
---
|
||||
title: "ƿit"
|
||||
---
|
||||
|
||||
```javascript
|
||||
// hello.ce — a simple actor
|
||||
log.console("Hello, ƿit!")
|
||||
$stop()
|
||||
```
|
||||
|
||||
```bash
|
||||
pit hello
|
||||
```
|
||||
|
||||
## Why ƿit
|
||||
|
||||
- **Actors, not threads** — isolated memory, message passing, no shared state. Concurrent programs that are safe by default.
|
||||
- **Everything is stoned** — `stone()` makes values permanently immutable. Messages between actors are frozen automatically. No defensive copying.
|
||||
- **Prototypes, not classes** — objects inherit directly from other objects. No class hierarchies, no `new`, no `this` confusion.
|
||||
- **C when you need it** — drop a `.c` file in your package and it becomes a native module. No FFI bindings, no build scripts.
|
||||
- **Small and predictable** — DEC64 numbers with no rounding errors. No `undefined`. Strict equality only. A runtime that fits in your head.
|
||||
|
||||
<div class="home-art">
|
||||
<img src="/images/wizard.png" alt="ƿit wizard">
|
||||
</div>
|
||||
|
||||
<div class="home-links">
|
||||
<a href="/start/">Get Started</a>
|
||||
<a href="/docs/">Documentation</a>
|
||||
</div>
|
||||
154
website/content/start/_index.md
Normal file
154
website/content/start/_index.md
Normal file
@@ -0,0 +1,154 @@
|
||||
---
|
||||
title: "Getting Started"
|
||||
description: "Install ƿit and write your first program"
|
||||
---
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- A C compiler (gcc or clang)
|
||||
- [Meson](https://mesonbuild.com/) build system
|
||||
- Git
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
# Clone the repository
|
||||
git clone https://gitea.pockle.world/john/cell
|
||||
cd cell
|
||||
|
||||
# Bootstrap the build
|
||||
make bootstrap
|
||||
```
|
||||
|
||||
This compiles the ƿit runtime and installs the `pit` binary. The ƿit shop is created at `~/.pit/`.
|
||||
|
||||
Verify your installation:
|
||||
|
||||
```bash
|
||||
pit version
|
||||
```
|
||||
|
||||
## Hello World
|
||||
|
||||
Create a file called `hello.ce`:
|
||||
|
||||
```javascript
|
||||
// hello.ce
|
||||
log.console("Hello, ƿit!")
|
||||
$stop()
|
||||
```
|
||||
|
||||
Run it:
|
||||
|
||||
```bash
|
||||
pit hello
|
||||
```
|
||||
|
||||
You should see `Hello, ƿit!` printed to the console.
|
||||
|
||||
Every `.ce` file is an **actor** — an independent unit of execution. The `$stop()` call tells the actor to shut down when it's done.
|
||||
|
||||
## A Counting Actor
|
||||
|
||||
Actors can schedule work over time. Create `counter.ce`:
|
||||
|
||||
```javascript
|
||||
// counter.ce
|
||||
var count = 0
|
||||
|
||||
$clock(function(dt) {
|
||||
count = count + 1
|
||||
log.console(`tick ${count}`)
|
||||
if (count >= 5) {
|
||||
$stop()
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
```bash
|
||||
pit counter
|
||||
```
|
||||
|
||||
The `$clock` intrinsic calls your function every tick. The actor runs until you stop it.
|
||||
|
||||
## Two Actors Talking
|
||||
|
||||
The power of ƿit is in actors communicating through messages. Create two files:
|
||||
|
||||
```javascript
|
||||
// greeter.ce
|
||||
$receiver(function(msg, reply) {
|
||||
reply({greeting: `Hello, ${msg.name}!`})
|
||||
})
|
||||
```
|
||||
|
||||
```javascript
|
||||
// main.ce
|
||||
$start(function(greeter) {
|
||||
$send(greeter, {name: "world"}, function(response) {
|
||||
log.console(response.greeting)
|
||||
$stop()
|
||||
})
|
||||
}, "greeter")
|
||||
```
|
||||
|
||||
```bash
|
||||
pit main
|
||||
```
|
||||
|
||||
`$start` launches a new actor. `$send` sends a message and provides a callback for the reply. Messages are automatically serialized — actors never share memory.
|
||||
|
||||
## Using Modules
|
||||
|
||||
Modules (`.cm` files) return a value that is cached and frozen. Create a module:
|
||||
|
||||
```javascript
|
||||
// math_helpers.cm
|
||||
function square(x) {
|
||||
return x * x
|
||||
}
|
||||
|
||||
function distance(x1, y1, x2, y2) {
|
||||
var math = use('math/radians')
|
||||
var dx = x2 - x1
|
||||
var dy = y2 - y1
|
||||
return math.sqrt(dx * dx + dy * dy)
|
||||
}
|
||||
|
||||
return {
|
||||
square: square,
|
||||
distance: distance
|
||||
}
|
||||
```
|
||||
|
||||
Use it from an actor:
|
||||
|
||||
```javascript
|
||||
// calc.ce
|
||||
var helpers = use('math_helpers')
|
||||
|
||||
log.console(helpers.square(5)) // 25
|
||||
log.console(helpers.distance(0, 0, 3, 4)) // 5
|
||||
|
||||
$stop()
|
||||
```
|
||||
|
||||
## Creating a Package
|
||||
|
||||
To share code or manage dependencies, create a `pit.toml`:
|
||||
|
||||
```toml
|
||||
package = "myproject"
|
||||
version = "0.1.0"
|
||||
|
||||
[dependencies]
|
||||
```
|
||||
|
||||
Your package can now use `pit build`, `pit test`, and install dependencies.
|
||||
|
||||
## What's Next
|
||||
|
||||
- [**ƿit Language**](/docs/language/) — full syntax reference
|
||||
- [**Actors and Modules**](/docs/actors/) — the execution model in depth
|
||||
- [**Packages**](/docs/packages/) — code organization and sharing
|
||||
- [**Standard Library**](/docs/library/) — built-in modules
|
||||
Reference in New Issue
Block a user