Monday, February 29, 2016

What is programming?

My firsts contact with programming made me think of it as a very complex task: something for hackers, and black magicians. However, after getting my first programming homework at school, I had to learn the basics. Fortunately, programming is one of the top topics discussed in the web. So I could find out how to do that homework in a short time. Actually, one may find the answer to almost any question about programming by just asking it to Google. There are many good references and documentation about programming online (stackoverflow.com, codeacademy.com, cprogramming.com, w3schools.com, and etcetera).

The definition of "program" by WordReference.com is: "a sequence of instructions enabling a computer to perform a task; piece of software". However, it is not obvious for a human being that programs like Photoshop, Excel and our favorite video-game are all just a set of instructions. But, surprise: it is exactly what they are. Complex programs, such as the ones of everyday use in our computers, are composed by hundreds, thousands, or even millions of instructions. Even though there are people who spend a lot of time programming, most of these big programs are result of the effort of many people working together (and sometime code generators are involved, too).

"Sequence" is the other important word in the "program" definition. Following the same set of instructions in different order may lead to a very different result. For example, the mathematical operation " 5 + 4 * 3 " involves one sum and one multiplication. Doing one or the other first give different results: "(5 + 4) * 3 = 27" and "5 + (4 * 3) = 17". Similarly, if you are giving directions to a friend to go from his home to yours, only God knows where he could go if he followed your instructions in different order!



So programming is all about giving instructions to the computer. For doing that, we use a set of rules given by a programming language (such rules are also referred to as the language "syntax"). Most instructions are very simple, like: add two numbers, draw a point in the screen, or write a letter into a file. However, the way they are written depends on the programming language, for example: some languages require you end each statement with a semi-colon (;), while others just need a new line to write another instruction. Choosing a programming language is sometimes matter of personal preferences, but sometimes is determined by the goal to achieve: you may not use the same language for doing complex mathematical calculations (you could use Matlab, Octave, R, or even C) and designing an interactive webpage (javascript, php, ruby, among others).

So, at the end, the mindset for programming consists basically on: understanding the goal to achieve, break it apart in small and individual steps, and translating them to the programming language we pretend to use.

Source:
Video lesson: "What is programming" in "Foundations of Programming: Fundamentals", at Lynda.com.

No comments:

Post a Comment