14.04.2014 Views

Hello Processing - Vula

Hello Processing - Vula

Hello Processing - Vula

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

An Introduction To Programming With <strong>Processing</strong><br />

println(5+3);<br />

Consists of two parts, first the function println() which accepts a parameter. In<br />

this case the second part of the statement, the parameter, is an expression and the<br />

expression is 5+3 which evaluates to 8.<br />

One of the basic features of <strong>Processing</strong> is it's ability to act as a calculator when<br />

computing values separated by mathematical operators such as + (plus), - (minus),<br />

* (multiply), / (divide) and % (modulus). But this inherent ability of <strong>Processing</strong><br />

extends a lot further than simply evaluating numerical expressions, as expressions<br />

amongst other types of data can also consist of other typographic characters that<br />

can be evaluated. For example the statement:<br />

println(“h” + “i”);<br />

This statement evaluates to “hi”. Using a mathematical operator in this way is<br />

known as operator overloading and is an inherent quality of <strong>Processing</strong> that<br />

comes from it being a C based programming language. Operator overloading is a<br />

common feature in higher level languages and simply refers to the level of<br />

abstraction built into a higher or mid level programming language that allows us<br />

to use the same operator in more ways than one. For example the plus sign can be<br />

used to add numbers or other typographic characters, but not numbers and<br />

characters at the same time without the use of a process known as typecasting<br />

(which we will cover in more detail later).<br />

What makes operator overloading so useful is that we often don't need to be<br />

aware of it, because the way that the operator is used will be determined by the<br />

context in which the programmer has used it and this is something that the<br />

program converting our human readable code into a version that is more machine<br />

readable will handle for us.<br />

An example of operator overloading and typecasting in <strong>Processing</strong>'s PDE<br />

An Analysis of a Computer Program 24

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!