Some advanced programming languages are in the C Family of Languages.
The C Family of Languages consists of:
- C
- C Sharp
- C++
- Java
- JavaScript
Java / Processing
Today, we coded in a program called Processing. Processing is quite different from Python in terms of syntax, but are similar in other ways.
Processing doesn't use indents. Instead, they use curly brackets {}. Also, instead of defining a function, it uses a syntax called void.
Void means that while it carries out a function, it won't return anything back (a number/message, etc). Hence the definition of void.
Our goal today was to make a smiley face by coding in Processing. This is what I made (a Pikachu!):
I made the face with the following codes:
As you can see, the syntax is very different from Python, yet perform the same function.
Loops
For example, in Python, if you want to repeat something, you say:
On the other hand, Processing has a diffent way of using a repeat function:
This defines a variable called i, which is equal to 1. While 'i' is less than '10', then the loop will continue.
'i++' means increase by 1 every loop. 'print(i)' will print the number that 'i' currently is.
Conditionals
In Java (Processing), everything after conditionals are in parenthesis. Everything inside the curley brackets {} are executed.
Functions
Instead of using "def _______():" to define a function, Processing has its own unique way to define it. One way is called void.
As stated earlier, using void as a function will not return anything back. It will just execute the code and won't give you a message/number.
Triginometry in Processing
Of course, there will always be mathematics in coding. Trigonometry can be used to create waves and movements in Processing.
Sine (up/down, y) and cosine (sideways, x) are mainly used in right triangles. Below is what I create using those terms: