Skip to content

ingStudiosOfficial/properscript

Repository files navigation

ProperScript Logo

ProperScript

npm version
JavaScript, but proper.
A delightfully British superset of JavaScript with more civilized keywords.

InstallationQuick StartSyntaxExamples


Installation

Install ProperScript globally via npm:

npm install -g properscript

Quick Start

  1. Create a file hello.ps:
changeable message = "Hello, ProperScript!";
announce(message);

Visual Studio Code Extension

We have a Visual Studio Code extension to give you ProperScript IntelliSense. Check it out here.

  1. Compile it:
proper compile hello.ps
  1. Run the compiled JavaScript:
node hello.js

Syntax

Keyword Reference

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/.

Examples

Hello World

ProperScript (hello.ps):

persistent greeting = "Hello, World!";
announce(greeting);

Compiles to (hello.js):

const greeting = "Hello, World!";
console.log(greeting);

Counter with Loop

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++;
}

Async/Await

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));

Error Handling

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/.

CLI Usage

# 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 --help

Contributing

We welcome contributions! Here's how to get started:

  1. Fork and clone the repository:
git clone https://github.com/ingStudiosOfficial/properscript.git
cd properscript
  1. Install dependencies:
npm install
  1. Make your changes and test:
node packages/cli/index.cjs compile examples/hello.ps
  1. Submit a pull request

See CONTRIBUTING for more details.

License

Licensed under Apache-2.0. See LICENSE for details.

Credits

Made with 💖 by (ing) Studios and Ethan Lee

Original idea from a r/programmingmemes comment


Keep calm and code proper 🫖

About

JavaScript, but proper.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •