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.
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.
$ 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.
function sum(values: number[]): number {
return values.reduce((total, value) => total + value, 0);
}
console.log(sum([8, 13, 21]));$ tsc --noEmit
$ porf counter.tsProbe the runtime
With no arguments, porf starts a REPL. For a fast one-off check, -p evaluates and prints an expression.
$ porf -p '[3, 5, 8].map(n => n * 2)'
[ 6, 10, 16 ]If one file works, decide whether you want a retained executable, an HTTP server, or to bring over a larger project.