JavaScript, but proper.
A delightfully British superset of JavaScript with more civilized keywords.
Installation • Quick Start • Syntax • Examples
Install ProperScript globally via npm:
npm install -g properscript- Create a file
hello.ps:
changeable message = "Hello, ProperScript!";
announce(message);We have a Visual Studio Code extension to give you ProperScript IntelliSense. Check it out here.
- Compile it:
proper compile hello.ps- Run the compiled JavaScript:
node hello.js| ProperScript | JavaScript | Description |
|---|---|---|
changeable |
let |
Mutable variable |
persistent |
const |
Immutable variable |
announce |
console.log |
Print to console |
inform |
console.warn |
Print warning |
blunder |
error |
Print error |
sorry |
error |
Error |
terribly sorry |
fatal error |
Fatal error message |
queue |
await |
Async await |
please |
then |
Promise then |
correct |
true |
Boolean true |
mistaken |
false |
Boolean false |
acquire |
import |
Import modules |
whether |
if |
Conditional statement |
period |
while |
While loop |
heretofore |
while(true) |
Infinite loop |
changeover |
switch |
Switch statement |
goback |
return |
Return statement |
respectively |
for |
For loop |
visit |
goto |
Goto statement |
For complete documentation, see docs/.
ProperScript (hello.ps):
persistent greeting = "Hello, World!";
announce(greeting);
Compiles to (hello.js):
const greeting = "Hello, World!";
console.log(greeting);ProperScript (counter.ps):
persistent stopNum = 10;
changeable count = 0;
heretofore {
whether (count === stopNum) {
goback;
}
announce('Current count:', count);
count++;
}
Compiles to (counter.js):
const stopNum = 10;
let count = 0;
while(true) {
if (count === stopNum) {
return;
}
console.log('Current count:', count);
count++;
}ProperScript (async.ps):
async function fetchData() {
changeable response = queue fetch('https://api.example.com/data');
changeable data = queue response.json();
goback data;
}
fetchData()
.please(data => announce('Received:', data))
.catch(sorry => announce('terribly sorry:', sorry));
Compiles to (async.js):
async function fetchData() {
let response = await fetch('https://api.example.com/data');
let data = await response.json();
return data;
}
fetchData()
.then(data => console.log('Received:', data))
.catch(error => console.log('fatal error:', error));ProperScript (errors.ps):
try {
throw new Error("terribly sorry");
} catch (blunder) {
inform("A blunder occurred:", blunder.message);
}
Compiles to (errors.js):
try {
throw new Error("fatal error");
} catch (error) {
console.warn("A error occurred:", error.message);
}More examples in examples/.
# Compile a single file
proper compile file.ps
# Compile multiple files
proper compile file1.ps file2.ps file3.ps
# Show version
proper --version
# Show help
proper --helpWe welcome contributions! Here's how to get started:
- Fork and clone the repository:
git clone https://github.com/ingStudiosOfficial/properscript.git
cd properscript- Install dependencies:
npm install- Make your changes and test:
node packages/cli/index.cjs compile examples/hello.ps- Submit a pull request
See CONTRIBUTING for more details.
Licensed under Apache-2.0. See LICENSE for details.
Made with 💖 by (ing) Studios and Ethan Lee
Original idea from a r/programmingmemes comment
Keep calm and code proper 🫖