Skip to content

the-neutron-foundation/neutron-language

Repository files navigation

The Neutron Programming Language

Codacy grade Website License Code style: black

Neutron is a high level general-purpose programming language that is inspired by C and Python.

Example

Here is how to do the guess the number game in neutron:

import "types";
import "io";
import "random::randrange";

is_not_win = true;
number = randrange(0, 100);
num_guesses = 0;

while (is_not_win) {
  guess = types::to_int(io::stdin(prompt="Enter A Number Between 0 and 100: "));
  if (guess == number) {
    io::print("You Win!");
    is_not_win = false;
  } else if (guess < number) {
    io::print("Too Low");
  } else if (guess > number) {
    io::print("Too High");
  }
}

Documentation

There is a documentation here for full documentation and installation instructions. There is also a Gitter Chat here.

Dependencies

Before installing/building/running neutron, you should first install the dependencies. you can do this via pip3 or any other package manager. The dependencies required are:

Basic Usage

To use, run the filename as the first argument. It is recommended to use the python interpreter to run the code (just run the neutron folder), like so:

python3 neutron path/to/neutron/file.ntn

The filename for neutron files is .ntn. For example, important_file.ntn. If you want to use the compiled binaries, on Unix-like systems, you could do:

./neutron.bin path/to/neutron/file.ntn

Syntax Highlighting

Text Editor Where to find
Atom Atom Package Repository (language-neutron)

Why Neutron?

  • It's actively maintained
  • It's a versatile programming language suited for many things
  • New features are constantly being added

Features

There are constantly new features being developed in neutron. To see the features that are coming and the one that are being worked on, go here.

  • Numpy arrays Builtin!!
  • Classes
  • Functions
  • Built-Ins (e.g. print, get, stdin, to_int)
  • Primitive Types (Integers, Floats, Booleans, Strings)
  • Python Lists, Tuples and Numpy Arrays Builtin
  • While loops
  • For Loops
  • Import statements
  • C-like Structs
  • Switch Statements
  • Syntax Changeable at Runtime

Tools used