Languages
Every script in Waiso is written in one of nine languages, and all of them run in the same worker, in the same sandbox, with the same Inputs card, Output tab and triggers. What changes between them is how the entry point is written, how a parameter is declared and how the result is handed back. This page puts them side by side.
- Write the entry point each language expects
- Declare inputs and return a result in each language
- Know which languages install packages and which do not
- Find where SQL fits
Nine languages, one worker
Python runs on CPython, TypeScript and JavaScript run on Bun (TypeScript needs no build step), C and C++ are compiled with gcc / g++ and Go with the Go toolchain right before the run — the compiled binary is cached, so a second run of unchanged code skips the compiler — and Bash, PHP and Ruby run on their own interpreters. All of them run inside the same isolated sandbox, which has no network access: a script reaches data through its inputs, the project’s integrations, variables and state.
The language is chosen when the script is created and cannot change later — it decides the file’s extension, the runtime and the language server. A new script starts from a small Hello template in its language, which is the quickest way to see the conventions below in practice.
The same script in every language
A word counter with one text input. Paste any variant into a new script of that language and press Run: the Inputs card shows a text field filled with the default, the log prints the count, and the Output tab shows the result.
def main(text: str = "the quick brown fox"):
words = text.split()
print(f"{len(words)} words")
return {"words": len(words), "chars": len(text)}{
"words": 4,
"chars": 19
}Python
Define def main(...). Each parameter becomes an input, typed by its annotation (str, int, float, bool, lists, dicts, Literal…); the value main returns is the result, turned into JSON. Anything printed goes to the logs. main is called as a normal function, so keep it synchronous — call asyncio.run(...) inside it if you need async code.
TypeScript and JavaScript
Export a function named main — export async function main(...) is the template’s form, and a plain synchronous function works too; a returned promise is awaited. Parameters are matched by name, so main(text) receives the text input, and a missing optional input arrives as undefined, letting the JavaScript default apply. TypeScript types (and JavaScript defaults) type the inputs. Returning nothing gives null.
C and C++
A C or C++ script is an ordinary program with int main(int argc, char *argv[]). Inputs are declared with comment lines at the top — // @param name type = default, types string, int, float, bool, json or list — and read with the SDK: waiso_arg_str, waiso_arg_int, waiso_arg_double, waiso_arg_bool and waiso_arg_json in C (#include "waiso.h"), waiso::argStr, argInt, argDouble, argBool in C++ (#include "waiso.hpp"). The same values also arrive as argv, in declaration order. Hand the result back as JSON text with waiso_set_result(json) / waiso::setResult(json); stdout and stderr are the logs, and a non-zero exit code fails the run.
Go
Write package main with func Main(...) — capital M, because Waiso supplies the real main. Each parameter is an input, typed by its Go type (string, int, float64, bool, slices, maps, structs), matched in order. Return (value, error): the value becomes the JSON result, a non-nil error fails the run with its message. The library is import "waiso.dev/waiso" (waiso.Run, waiso.Flow, waiso.StateGet…); only the standard library is available besides it.
Bash
Inputs are the positional arguments, declared the usual way: name="$1" is a required input, count="${2:-5}" an optional one with a default (its type is read from it). Everything printed is a log; the last line printed is the result — JSON when it is JSON, else text — unless you call waiso_result '{"ok":true}'. The library is already loaded: waiso_run, waiso_flow, waiso_state_get / waiso_state_set. A non-zero exit fails the run.
PHP and Ruby
Define function main(...) (PHP) or def main(...) (Ruby). Inputs are matched by name to the parameters; PHP types (string, int, float, bool, array) and Ruby defaults type them, and keyword arguments work in Ruby. What main returns is the JSON result. The library is loaded for you: Waiso::run, Waiso::flow, Waiso::stateGet in PHP; Waiso.run, Waiso.flow, Waiso.state_get in Ruby.
Side by side
| Language | Runs on | Entry point | Inputs | Result | Packages |
|---|---|---|---|---|---|
| Python | CPython 3.15 (3.14 beside it) | def main(...) | Parameters with type hints | Return value | From PyPI, detected from imports |
| TypeScript | Bun 1.4 (1.3 beside it) | export async function main(...) | Typed parameters | Return value | From npm, detected from imports |
| JavaScript | Bun 1.4 (1.3 beside it) | export async function main(...) | Parameters and their defaults | Return value | From npm, detected from imports |
| C | gcc 14 | int main(int argc, char *argv[]) | // @param lines + waiso_arg_* | waiso_set_result(json) | None — the C library, math.h and waiso.h |
| C++ | g++ 14 | int main(int argc, char *argv[]) | // @param lines + waiso::arg* | waiso::setResult(json) | None — the standard library and waiso.hpp |
| Go | Go 1.27 | func Main(...) (any, error) | Typed parameters, in order | Return value | None — the standard library and waiso.dev/waiso |
| Bash | Bash 5 | The script itself | name="$1", n="${2:-5}" | The last line printed, or waiso_result | None — the system’s commands |
| PHP | PHP 8.4 | function main(...) | Typed parameters, by name | Return value | None — PHP’s built-in functions |
| Ruby | Ruby 3.3 | def main(...) | Parameters by name, typed by their defaults | Return value | None — the standard library |
The exact versions, and how a script moves to a newer one, are on Runtime versions. How packages are found, pinned and frozen at publish is on Dependencies. Python, TypeScript, JavaScript, C and C++ can also import another script of their own language from the same project — see Import your own scripts.
And SQL?
A script can also be PostgreSQL or MySQL. It runs against one of the project’s database connections, picked in the editor’s Connection menu (Choose a connection to run this query. until one is set). Its inputs are :name placeholders, optionally declared with -- @param name type = default. How connections are made, and the Workbench for exploring a database, are covered in Integrations and SQL Workbench.
Limits that apply to every language
- A run may take 5 minutes by default. Change it per script in the editor menu → Script settings → Timeout, up to the installation’s ceiling (1 hour unless your administrator raised it). A run that goes over fails with the
timeoutcode. - No network from user code, in any language. Data comes in through inputs and the SDK.
- C and C++ cannot install libraries: they are compiled with gcc’s defaults and linked with the math library and the Waiso SDK only.
- A C or C++ library imported by another script must not define
main.