NothScript programming language. It is built using TypeScript and JavaScript and requires Node.js version 18 or higher.
To use NothScript, make sure you have Node.js installed.
$ npm i -g pebrianz/nothscript#distThen, you can run your code using the provided interpreter.
$ ns index.nsx:num = 10;
In NothScript, you can declare variables using the : symbol, followed by the type of the variable (num, str, bool, or none).).
x = 30;
You can assign values to variables without specifying the type.
fn add a:num b:num ::num {
rn a + b;
}
Define functions using the fn keyword, followed by the function name, parameters with their types, and the return type specified after ::.
add(10, 20);
Call functions by using their names and passing arguments inside parentheses.
fn add a:num b:num ::num => a + b;
Arrow functions provide a more concise way to define simple functions.
fn add a:num b:num ::num => a + b;
fn add a:str b:str ::str {
rn "{a} {b}";
}
if 10 > 5 {
print "hello";
} else {
print "world";
}
Make decisions using if and else statements with conditions enclosed in curly braces.
while x < 100 {
print "hello world";
x = x + 1;
}
Execute a block of code repeatedly with a while loop.
print "hello world";
x:num = number(input("your age: "));
print "your age is {x}";
Use print to display output and input to receive user input. Note that number is used to convert the input to a numeric value.
fn factorial n:num ::num {
if n <= 1 {
rn 1;
} else {
rn n * factorial(n - 1);
}
}
x:num = 5;
result:num = factorial(x);
print "Factorial of {x} is {result}.";
This example demonstrates how to use recursion to calculate the factorial of a number in YourLanguageName.
NothScript is released under the MIT License. See LICENSE for more information.