Skip to main content
Porffor includes an interactive REPL (Read-Eval-Print Loop) for quick JavaScript experimentation and testing.

Usage

Run porf without any arguments:
porf

Examples

$ porf
Welcome to Porffor v0.61.10
> 

Features

The REPL provides:
Type JavaScript expressions and see results immediately
> 100 / 4
25
> [1, 2, 3].map(x => x * 2)
[2, 4, 6]
Write functions and complex expressions across multiple lines
> function greet(name) {
...   return `Hello, ${name}!`;
... }
undefined
> greet('World')
'Hello, World!'
Variables remain available throughout the session
> let counter = 0
undefined
> counter++
0
> counter++
1
> counter
2
Special REPL commands for convenience
> .help      // Show help
> .clear     // Clear context
> .exit      // Exit REPL

REPL Commands

.help
command
Show available REPL commands and help information
> .help
.clear
command
Clear the REPL context (reset all variables and functions)
> let x = 10
> x
10
> .clear
Clearing context...
> x
ReferenceError: x is not defined
.exit
command
Exit the REPL (same as Ctrl+D or Ctrl+C twice)
> .exit
.break
command
Cancel current multi-line input
> function incomplete() {
... .break
>

Keyboard Shortcuts

Ctrl+C
shortcut
  • Once: Cancel current line
  • Twice: Exit REPL
Ctrl+D
shortcut
Exit REPL (on empty line)
Up/Down Arrows
shortcut
Navigate command history
Tab
shortcut
Auto-completion (if supported)

Example Session

$ porf
> 5 + 3
8
> let radius = 10
undefined
> Math.PI * radius * radius
314.1592653589793

Use Cases

Quick Testing

Test JavaScript expressions and functions quickly

Learning

Explore JavaScript features and Porffor’s capabilities

Debugging

Test isolated pieces of code to debug issues

Prototyping

Experiment with algorithms before writing full scripts

Multi-line Input

The REPL automatically detects incomplete expressions:
> function add(a, b) {
...   return a + b;
... }
undefined

> if (true) {
...   console.log('yes');
... }
yes
undefined

> const obj = {
...   x: 1,
...   y: 2
... }
undefined

Output Display

> 42
42
> 'hello'
'hello'
> true
true

Implementation

Porffor’s REPL uses Node.js’s built-in node:repl module, providing:
  • Standard REPL functionality
  • Command history
  • Tab completion (limited)
  • Multi-line editing
  • Syntax highlighting (terminal dependent)

Limitations

Porffor’s REPL has the same limitations as regular Porffor execution:
  • Limited async support (Promise/await bugs)
  • No variables between scopes (except args and globals)
  • No eval() or Function() (AOT compilation)
  • Limited standard library support

Troubleshooting

Unexpected behavior

// Clear context and try again
> .clear
Clearing context...

Exit not working

# Press Ctrl+C twice
# Or press Ctrl+D on empty line
# Or type .exit

Multi-line input stuck

// Use .break to cancel
> function incomplete() {
... .break
>

Comparison with Node.js REPL

FeaturePorffor REPLNode.js REPL
Basic evaluation
Multi-line
History
Tab completionLimited
Async/awaitLimited
Full stdlib
AOT compiled
Fast startup

Advanced Usage

> // Inline Wasm
> Porffor.wasm.i32.add(5, 3)
8

Tips

Paste multi-line code directly into REPL
> function fibonacci(n) {
...   if (n <= 1) return n;
...   return fibonacci(n-1) + fibonacci(n-2);
... }
Arrow keys navigate previous commands
  • Up: Previous command
  • Down: Next command
Fastest way to exit: Ctrl+D on empty line
If context gets messy, use .clear

Version Info

Check Porffor version in REPL:
> globalThis.version
'0.61.10'
Or from command line:
porf --version
porf -v

Next Steps

Run Scripts

Execute JavaScript files

Profile Code

Analyze performance

Debug

Interactive debugging

Compile

Build Wasm binaries

Build docs developers (and LLMs) love