Before you go, check out these stories!

0
Hackernoon logoGetting Started with the Neuron Language by@underpig

Getting Started with the Neuron Language

Author profile picture

@underpigunderpig

A step-by-step guide to developing with Neuron.

Install Neuron

With

npm
installed, type the following into your command line:

npm install --global neuron-lang

Create a new file

Create a file with the name

main.neuron
. This will contain our program. In the command line, navigate to the directory with the file:

cd path/to/main.neuron

Create a simple Hello, World! program

In

main.neuron
, type the following:

sayHello {
 log(Hello #0!);
}

This is the standard function and object syntax, with

#0
being the first parameter passed as an argument to the function
sayHello
. The function can now be called as follows:

sayHello(world);

This will now log “Hello world!”

Inline functions

We can create a new function that can return a value as well. In main.neuron:

sayHello {
 return(Hello #0); // or return: Hello #0
}

log([sayHello => world] in Neuron!);

When run in the command line with

neuron main.neuron
, it should log “Hello world in Neuron!”

Passing multiple parameters

Now we can pipe the output of another function into our

sayHello
function:

add {
 return(#0 plus #1 is [#0 + #1].);
}

sayHello {
 log(Hello! It appears as though [add => #0 #1]!);
}

sayHello(0, 1);

The output of our program should be “Hello! It appears as though 0 plus 1 is 1.”

Iterators

We can further extend the capabilities of our program with iterators:

for (i => 10) {
 sayHello(#i, [#i  -  1]);
}

This will now log “Hello! It appears as though 0 plus -1 is 0.” and “Hello! It appears as though 1 plus 0 is 1.” until the iterator, represented by

#i
, has reached nine.

Other features of the Neuron programming language capable of being integrated in our program include conditionals, variables, iterators, and objects.

Running the program

With Neuron installed through

npm
, the file can be executed as such:

neuron main.neuron

What next?

Neuron can be used for web applications in the browser as well. Neuron is an incredibly efficient language for front-end web development. If you are interested in the Neuron language and would like to know more, visit the repository. The documentation contains information about the Neuron language, various tutorials, and a reference for the Neuron language. Neuron is currently under heavy development, and your contributions and support are welcome!

Resources

Tags

Join Hacker Noon

Create your free account to unlock your custom reading experience.