Language

Hello world

Select your preferred language from the dropdown above.

Now it's time to say hello:

package main

import (
    "fmt"
    // no need to import "hookscript"
)

func Hook() {
    fmt.Println("Hello, world!")
}
use Hookscript; # implies use strict; use warnings; use feature ":5.20"

say "Hello, world!";
:- use_module(library(hookscript)).

hook :-
    writeln("Hello, world!").
import hookscript

print("Hello, world!")

A program running on Hookscript is called a script. Most scripts start by importing the hookscript library. This automates some low-level, repetitive details.

A script's code is run each time an incoming HTTP request arrives at the script's URL. A script can access the request, but we'll get to that later.

Anything the script sends to its stdout becomes the HTTP response body. Most programming languages have good defaults for generating output on stdout. It also means that a script which runs well on your local terminal should run, with minimal modifications, on Hookscript. Compare for a moment the program above with the language's traditional hello world program.

Next