POCA is a powerful, JavaScript/ECMAScript-like scripting language with advanced features including prototype-based and class-based OOP, functional programming, coroutines, and multithreading support. Implemented in Object Pascal, POCA offers JIT compilation for enhanced performance on x86-32/x86-64 platforms.
The VS Code extension provides comprehensive language support for POCA:
- Syntax Highlighting - Color-coded syntax for keywords, operators, strings, numbers, and comments
- Language Configuration - Automatic indentation and bracket matching
- JavaScript/ECMAScript-like syntax with enhanced capabilities
- Dynamic typing with weak type coercion
- Multiple programming paradigms: OOP (prototype and class-based), functional, procedural
- Everything is an expression - even statements return values
- Advanced scoping:
var(function-scoped),letandconst(block-scoped) - Coroutines and threads for concurrent programming
- Regular expressions, exceptions, pattern matching
- First-class functions and closures
- Just-In-Time (JIT) compilation for improved performance on x86-32/x86-64 platforms
- Fast functions for performance-critical code
- Modules and namespaces for code organization
- Built-in standard library for common tasks
- Interoperability with Pascal code
var x = 10; // Function-scoped, stored in hash table
let y = 20; // Block-scoped, stored in registers/frame storage
const PI = 3.14; // Block-scoped constant// Standard function
function add(a, b) {
return a + b;
}
// Fast function (optimized, no var support)
fastfunction multiply(let a, let b) {
return a * b;
}
// Lambda expressions
let square = (x) => x * x;
let cube = (x) => x * x * x;
// Closures
function makeCounter() {
let count = 0;
return function() {
count += 1;
return count;
};
}
let counter = makeCounter();
puts(counter()); // 1
puts(counter()); // 2
// And more...// Prototype-based
let proto = {
greet: function() {
puts("Hello!");
}
};
// Class-based
class Person {
var name;
constructor(let n) {
this.name = n;
}
function sayHello() {
puts("Hello, I'm " ~ this.name);
}
}// Standard if/else, for, while
if (x > 0) {
puts("Positive");
} else {
puts("Non-positive");
}
// Pattern matching with when
when(value) {
case(1..10) { puts("1-10"); }
case(20, 30, 40) { puts("20, 30, or 40"); }
else { puts("Other"); }
}
// Exception handling
try {
// risky code
} catch(error) {
// handle error
} finally {
// cleanup
}- Install the extension in VS Code
- Open or create a
.pocafile - Start coding with syntax highlighting and IntelliSense support
For comprehensive documentation, see:
- Syntax Guide - Complete language syntax reference
- Script API - Built-in functions and APIs
- Examples - Sample POCA programs
To compile and run POCA programs:
# Compile the POCA compiler/interpreter (requires Free Pascal or Delphi)
cd src
fpc -O3 -Sd pocarun.dpr
# Run a POCA script
./pocarun yourscript.poca- VS Code 1.50.0 or higher
- POCA interpreter (for running scripts)
This extension contributes the following settings:
- Language association for
.pocafiles - Syntax highlighting theme
- Code formatting preferences
Please report issues at: GitHub Issues
See the POCA.pas beginning for licensing information.
Enjoy coding in POCA!