lunedì 25 gennaio 2010

Programming, this obscure science. The basics.

Hello everyone. I'm Morg, a programmer and student currently studying to obtain a Degree in Computer Science at the University of Bologna, Italy.

Today I've decided to start a new blog (among a ton of other projects) to help the newcomers join the awesome, mind opening, magical world of computer development. Probably if you stumbled upon this blog page, you either:
a) Hit the wrong link
b) Got spammed by me
c) Are mildly interested in learning how to program a computer.

Now, given the majority of people will probably be just from point a and b, I'll try to capture the interest of everyone, even the ones not really focused on learning how to program.

This post will be the first of a long (hopefully) series of tutorials related to general programming techniques and terminology (for starters) that will not be focusing on a single programming language to give the readers the possibility of choosing their own pace/language when learning. There are so many dialects out there that it's probably best not to get focused on a single programming language; in the end being flexible (especially in software development) pays off a big deal and if you ever plan to keep going this way, you will learn it.

To get started, I'll be covering some aspects of programming theory, laying in front of you readers a few choices and ways to get engrossed into the world of computers.

What is a computer?

What most of you refer with the word "computer" is a tool that allows you to get linked and connected to the net, to browse forums, blogs, facebook, twitter and keep in touch with people from the other side of the globe through Skype and MSN. If you ever wondered what's inside the plastic box and how does it work, then you're on the good track and have the will to become a real programmer. The "how" is always (and I mean, always) the first and most important question you should be asking yourselves, in every context, both real life and IT.
Back to the topic, inside a computer's case there are some stupid magical entities (fairies) that, while they are not working, wait for someone to tell them what to do. I won't go into many details here because I'm not enough qualified and it's way too complex to cover in a single blog post, however the most important part you have to remember is that every single fairy in your computer has got a "work context" and it's only proficient with that. All the fairies are allowed to speak with each other but they all (most likely) speak different languages and every single one of them is fundamental for the machine.

But... how does a computer work?

A computer, an assembly of magical fairies, is stupid. It doesn't know how to work or what to do. When you press the power button it doesn't learn anything. When you repeat the same combination of buttons over and over again, every day, the computer doesn't understand. It doesn't recognize you and isn't aware of his surroundings. No matter how advanced, interactive and "alive" it seems to be, a computer is just a stupid, motionless (mostly) piece of metal lying on your desktop. There is only one (one and only) thing it's good at: following instructions. All it does, every day, from boot time to poweroff is following instructions. To put it bluntly, it's your little bitch. If you know how to hand it informations, instructions and commands, it can basically do everything in its power.

How do I make a computer follow my instructions?

This is the first question a real programmer asks himself (I already told you, the "How" is more important than the "Why"). Sometimes you get frustrated when some software on your machine is not working, when there's a bug or when your computer gets stuck and you can't do anything short of restarting. That's when you start asking yourself if you could've done it better than the person who programmed it. Most likely than not, nope. The guys developing software for home uses are usually proficient enough (save few exceptions) that you will never top their products before at least 10 years in software development. Anyhow, you have the good spirit to start and build something upon it; all you have to do is keep reading and you will learn how to transform your machine into your machine.

The language of the computer.

Currently, I'm writing in English. Why is that? Because I'm trying to give you some informations and the only way I can transfer the thoughts from my brain to yours is using a standardized communication channel that the receivers (you readers) are able to understand and decode into thoughts. That is the language. The same thing is applied to computer development (IT = Information Technology) where we, the programmers, are going to manipulate data (thoughts) and communicate it to the computer through a language. Mostly all the computers (the ones in your houses at least) speak one single language: Binary. The binary language is a "simple" (not easy) language formed by sequences of '0' and '1'. Every 0 means off and every 1 means on, but on/off what exactly? Those numbers (called bits - do not confuse them with Bytes!) keep track of the state of the mind of a computer. Through the combinations of different bits you get different states in the mind of the computer and through the shifting of those little on/off buttons you can tell your machine to compute algebric functions, or display stuff on the screen.

You're telling me I have to write in a bunch of 0s and 1s?

Fortunately, the great developers of the past eased the work for us and made our life as computer programmers easier (sometimes it's way too easy actually). They invented linkers and compilers. Those are programs (yes, other software made of 0s and 1s) that take a bunch of typed words and symbols and transform it into binary code for us. Those binary coded lists are executable files (.exe if you are under a Windows-based System) which, if double clicked, will inject their code into the computer that will read it and run it. To be more specific, the compiler is the software that takes your written words and transforms them into Assembly code which, then, will be "eaten" by the linker that will turn it into machine code (your .exe).

I got it, where do I type my instructions then?

Whoa... hold on a second, don't be too impatient here. The first steps of learning programming are the most important ones, a bad background usually leads to spaghetti code and horribly implemented algorithms, so please, hold your horses and keep calm, you will learn how to program well one day. After all, Rome was not built in one day now, was it? Anyway, as I was trying to say earlier, there are a lot of different dialects with their related compilers that can be used to develop software on a computer, the choice of which usually depends on the programmer himself. You have to keep track of what you are trying to achieve, how you want it to be done and how much hours/days/weeks/months/years/decades are you willing to invest in the project. Every language has its own pros and cons and that is the reason why there is such a huge array of choices out there, because there can never be a best programming language.

Here I will list some good programming languages among which you can decide what fits your interest best:

- LISP / COMMON LISP / SCHEME

- C / C++

- Pascal / Object Pascal

- Perl

- Python

- Basic / Visual Basic

- Java

- C# / Visual C#

- Javascript

- PHP

- ASP.NET

- Ruby

As you can see, there are a lot of different programming languages / dialects and this post is getting bigger and bigger as I keep typing. That is the reason why I decided to cut my first tutorial lesson here and let you readers flick through all those wikipedia articles. That will give you a better idea of what you want to actually accomplish and how. In the next tutorial I will quickly go over most of these languages listing some pros and cons, then I will continue defining different programming techniques. Please stay tuned for the next chapter of this tutorial.

I hope this was useful to some of you, if it was please feel free to comment for positive feedback or criticize my work, I'm always open to debate and negative feedback as well. I'm still a student so please (PLEASE) do not EVER take everything I say for an absolute truth. I make mistakes, you make mistakes, everyone does.

Cheers.

1 commento: