Introduction
Variables
Input/Output
Control Structures
Arrays
Structs
Functions
Imports
Extra
Contact
Introduction

Noodle is a new programming language created for the purpose of education and collaborating on small programming projects. It is extremely lightweight, consisting of only basic language concepts with a view to remove much of the baggage of modern languages to aid the learning of new programmers. The language is browser based where users can import others’ code to help their own projects.

If the philosophy of Noodle is to be summarised in one word it would be ABSTRACTION. The user does not need to know unnecessary details, they just need the fundamental tools to build their program. The other main points of the language are below.

  • Types must be respected (unless obvious implicit casting is possible) (WELL FORMED)
  • Ugly characters must be avoided (PRETTINESS)
  • As simple as possible without reducing intuitiveness and readability (SIMPLE)
  • Lightweight (expanded by libraries) (LIGHTWEIGHT)
  • Style, although good practice and is encouraged, is in general not enforced (FREEDOM)

Noodle has no semicolons. Expressions are separated by line breaks. Code blocks i.e. if statements are ended with end statments (no curly braces). Indentation is not required (although is good practice).

There are two types of files you can make on Noodle Create - programs and libraries. Programs are regular noodle programs which contain a main function and produce some kind of output. Libraries are similar to programs except that they do not contain a main function. They can be imported into other libraries and programs. For example, a library containing math functions like rounding can be imported into a program calculating areas of circles. The library import means that the functions do not need to be redefined.

Variables

Variables are the basic building blocks of computer programs. They are named containers for values. For example, if you wanted to store a number and do something interesting with it, you would store the number in a variable. A variable has a data type associated with it. For example, storing a number would require a variable with a number data type. There are two main data types - primitive types and composite types. Primitive types are built into the language and can always be used.

There are 5 primitive data types for Noodle:

  • int - Integers (whole numbers)

  • float - Floating Point numbers (numbers with a decimal point)

  • char - Single characters

  • string - Sequences of characters

  • bool - True or False

Example:
                        
  int i = 4
  i = i - 5
                        
                      

Composite data types are made up of primitive data types. Examples are arrays and structs which are explored in later sections.

Variables can be defined either locally or globally. Local variables can only be used in the block in which they have been defined. Global varibales can be used everywhere in the program. It is best practice to avoid using global variables where possible. There are some important reasons for this:

  • Local variable names can be reused in different blocks since they are out of scope of each other. Once a global variable is defined, its name cannot be used for any other variable.
  • Once the block containing a local variable has been completed, the variable is destroyed - this frees up memory.

A local variable can simply be defined in its block when it is required. A global variable needs to be declared in a define block. Example:
                          
  define
    int num = 8
  end

  func main()
    print num
  end
                          
                        
Input/Output

To make any useful program, you need to have some way of inputting data to be processed and some way of getting an output in a meaningful form.

The command to input data is read. read can be used like a variable. You can place it in declarations and assignments.

                      
  int i = read
                      
                    

The command to output data is print. print is used as a stand-alone statement which can take two forms. You can print a single variable.

                      
  int i = 8
  print i
                      
                    

The second form allows you to print a string

                      
  print "Hello World!"
                      
                    

You can include expressions in the second form enclosed in {}

                      
  int i = 8
  print "The value of i is {i}. Double i is {i * 2}"
                      
                    
Control Structures

To make your programs powerful, you need to have some way of controlling the flow of the program though loops and conditions.

If statments:

                            
  if (x == 8 && y > 5)
    print "Chow"
  else
    print "Ramen"
  end
                            
                        
While loops
                            
  while (x > 0)
    print x
  end
                            
                        
Do while loops
                            
  do while (x > 0)
    print x
  end
                            
                        
There are 4 types of for loops. Type 1 - used for simply looping x times. No stepper variable is needed.
                            
  for (5)
    print "Chow"
  end
                            
                        
Type 2 - used for looping x times and a stepper variable is needed to index an array for example. The stepper variable starts at 0 and the loop terminates when the stepper ¡ the limit. If you want to change the
                            
  for (x, 5)
    print x
  end
                            
                        
For loops type 3
                            
  for (x, 2, 5)
    print x
  end
                            
                        
For loops type 4
                            
  for (x, 2, 5, 2)
    print "Chow"
  end
                            
                        

Arrays

You can create arrays of primitive types. You are able to choose a static array or a dynamic array. If you put a number x between the square brackets, a static array of length x will be created. If no number is between the square brackets, a dynamic array will be created.

                            
  int[3] i = [4,5,6] //Static array, length 3
  int[] i            //Dynamic array
                            
                        

Structs

You can create structures.

                            
  struct person
    string name
    int age
  end
                            
                        
Create an instance of a structure like so
                            
  person ross = ("Ross", 19)
                            
                        
Access properties of a structure like so
                            
  int rossAge = ross.age
                            
                        
You can also create arrays of structures
                            
  person p1 = ("Ross", 19)
  person p2 = ("Mary", 48)
  person p3 = ("John", 35)
  person[3] people = [p1,p2,p3]
                            
                        

Functions

Sometimes you need to reuse sections of your code. Instead of copying and pasting the same code, you can use functions. The main function is the function which is called first. From there you can call other self-defined functions. For example, if you wanted to calculate the area of 3 different circles you could make a function to calculate the area of one circle with an arbitrary radius and call this function for the 3 circles - no code duplication!

A function can return a value (but it doesn't have to). The return value must have a return type which is specified in the function definition. A function must have a name and it may have parameters (or arguments). These arguments must themselves have a type which is specificed in the definition. Here is an example of a function.

                        
  func(int) divideTwo(int x)
    return x/2
  end
                        
                    
This function is called divideTwo, it promises to return an int and it takes one int parameter called x. The function returns the passed value divided by two, as specified in the return statement.

Here is an example of a function which doesn't return a value.

                        
  func printString(string s)
    print s
  end
                        
                    
Here is an example of a function with no parameters.
                        
  func printHelloWorld()
    print "Hello World!"
  end
                        
                    
Imports

When making larger programs, you may need to use external functions created by other people. This means you don't have to make them yourself which can save you a lot of time. For example, if you are making a program to calculate the difference between two dates, it would be useful to import a library which calculates the number of days/hours in a year/month etc.

To import a library use the import keyword to start the block. In the block, individual imports are made with the username of the creator of the library followed by a / and the library name. Here is an example program which imports a library.

                        
  import
    noodle/math
  end

  func main()
    float num = 7.8
    int roundedNum = round(num)
  end
                        
                    
This program imports the library math made by the user noodle. The library contains a function round which is used in this program.

Structs defined in imported libraries are also useable.

Make sure there are no name clashes with functions/structs defined in the program and imported library. Also, two functions with the same name in two different imported libraries will cause a clash as well.

Extra
Generics

Sometimes you do not know the exact type of a variable. A generic type T can be used for this.

                        
  func printGeneric(T x)
    print x
  end
                        
                    
Future

In future versions of Noodle, the following features may be included:

  • n-dimensional arrays (n > 2)

  • Functional programming

  • Graphics

  • Error throwing and assertions

  • Switch statements

  • Enums

Contact
Support

If you have spotted any issues or need help, contact support@noodlecreate.com

Enquiries

For business enquiries, contact enquiries@noodlecreate.com

Social Media