PythJS

From Esolang
Jump to navigation Jump to search

What happens if you take the syntax of JavaScript and take the newlines and indentation of Python? You get PythJS!

PythJS is a esolang by Mihai Popa. It's JavaScript with newlines and indentation (no brackets, no semi-colons at end of lines), just like in Python.

Examples

For Loop

Normal Python:

for i in range(0, 3):
    print("Hello, world!")

PythJS:

for (let i = 0; i < 3; i++):
    console.log("Hello, world!")

Compare with JavaScript:

for (let i = 0; i < 3; i++) {
    console.log("Hello, world!");
}

Second Example

JavaScript:

// create a function named greet()
function greet() {
    console.log("Hello World!");
}

// store a function in the displayPI variable
// this is a function expression
let displayPI = function() {
    console.log("PI = 3.14");
}

// call the greet() function
greet();

// call the reply() function
displayPI();

// Output:
// Hello World!
// PI = 3.14

PythJS:

// create a function named greet()
function greet():
    console.log("Hello World!")

// store a function in the displayPI variable
// this is a function expression
let displayPI = function():
    console.log("PI = 3.14")

// call the greet() function
greet()

// call the reply() function
displayPI()

// Output:
// Hello World!
// PI = 3.14

More in PythJS/Examples