Run code.

Start with a single, unsurprising file. The shortest Porffor feedback loop is edit, compile, execute.

Make a small program

Create hello.js. Keep the first experiment self-contained so a dependency cannot hide a compiler problem.

hello.js
const places = ['workshop', 'server', 'pocket'];

for (const place of places) {
  console.log(`Native JavaScript in the ${place}.`);
}

Compile and execute

Pass one input path. Porffor creates a temporary native program, runs it, then removes it.

terminal
$ porf hello.js
Native JavaScript in the workshop.
Native JavaScript in the server.
Native JavaScript in the pocket.

This command feels like an interpreter, but the work is still ahead-of-time compilation. Compilation repeats on every run.

Use TypeScript directly

A .ts or .mts extension turns on TypeScript parsing. Porffor erases types and can use some annotations as optimization hints; it does not replace a full type checker.

counter.ts
function sum(values: number[]): number {
  return values.reduce((total, value) => total + value, 0);
}

console.log(sum([8, 13, 21]));
terminal
$ tsc --noEmit
$ porf counter.ts

Probe the runtime

With no arguments, porf starts a REPL. For a fast one-off check, -p evaluates and prints an expression.

terminal
$ porf -p '[3, 5, 8].map(n => n * 2)'
[ 6, 10, 16 ]
Next move

If one file works, decide whether you want a retained executable, an HTTP server, or to bring over a larger project.