Rook
РусскийRU

What is Rook

Rook is a language with the semantics of JavaScript, Go-style syntax and static types. Its main feature is goroutines: go f(x) runs a function in a thread of its own, on another processor, and channels pass values between them, as in Go. It compiles to readable JavaScript: what you write is what runs, and what JS cannot do alone, such as channels, a small runtime does. To make the language features concrete, this guide follows a small task board for one workspace, growing its task list and operations step by step.

Goroutines and channels

go f(x) runs a function on another processor, and channels and select connect goroutines: see Goroutines.

Like JavaScript

The same values, objects, arrays, classes and modules. Any JS library can be used.

Like Go

func, the type after the name, several results, errors as a second value, defer and a single for loop.

Types

The compiler checks the program before it runs, null included: a ?User cannot be used without a check.

Markup and components

<button> in code creates a real DOM element, and a component with state updates its markup by itself.

Every example has a JavaScript tab with the code generated by the compiler, which runs right on this page. Run runs the example, and Open in playground opens it in the editor at the bottom of the page.

// Functions are declared with func, and the type goes after the name, as in Go
func greet(name string) string {
    return `Hello, ${name}!`
}

console.log(greet("Rook"))