Friday, September 28, 2007

Basic Computer Architecture

Let's get started. First, I want to introduce you to the essential functional units of a computer to help you understand how the computer goes about running your code.
Everything you enter into the computer (whether you type it on the keyboard, load it using a disk, scan it, etc.), is read into the memory of the computer. This can be data or program and is commonly called input, entered using any of the several input devices. They are all placed in the memory of the computer as they are loaded. This information could be read into the processor for some kind of ... (you guessed it!) processing. After the processing is done, the resulting information, now called the output is placed right back into memory. From there, the information can be moved to a printer, to disk, on screen or through any other 'output device'. This is all handled by the operating system.

Physically speaking, most of what you do as a programmer is to (a) specify to the operating system (or the runtime of your platform) to create various kinds of locations in the memory of the computer (variables). (b) You'd then ask it to store matching kinds of data in those spaces (assignment). (c) You also specify where you data will come from. (d) And then, you specify instructions (instructions) that the system will use to operate on those data stores. (e) Finally, you provide instructions as to where the computer will direct the output to.

So, when the operating system starts your program, it loads the instructions into memory. Then it creates space, also in memory for the data. Then, it starts executing each instruction one afte the other until they finish or it encounters a halt instruction or an error. In the ordinary sense, the instructions are executed one after the other, in the order they textually appear. However, some of those instructions are jump instructions which tell the computer to jump (or branch) to another location other than the very next line of instruction.

Let's look at a sample pseudo-program and see how the computer will execute it.
Pseudo-program, otherwise known as pseudocode is not written in any programming language. It is written in some kind of tecky human language. It is just meant to specify what is yet to be coded. Often, it is convenient to express a program in pseudocode so that everyone, regardless of their programming language of choice can still understand it.
Sample code (pseudo):
  1. Enter first number as 10
  2. Enter second number as 5
  3. Store third number as firstnumber MINUS second number
  4. PRINTOUT first number - second number = third number.

Expected result will be:

10 - 5 = 5.

What just happened? The programmer specified a set of instructions. These incuded creating a space in memory for storing 3 numbers. One of them is the constant 10, another is the constant 5 and the third is a result number from an operation named MINUS . The last instruction is called PRINTOUT whose duty is to take information from a location in memory and draw it on a human interface, eg: screen or paper.

You will notice that the MINUS instruction will require the processor to do something with two numbers in specified locations in memory and produce a third number which, in this case, gets put into a third location in memory.

Most of the time, this is a summary of what programmers do for a living. As we proceed, you will see that these few lines of 'code' do actually represent nearly every kind of program every written by man to solve any conceivable kind of human problem.

See! You can do it. Stay with me.

Thursday, September 27, 2007

C# Programming Tools

For starters, you will need to put a workstation together. We will start working with a Windows computer. In due course, I will show you how to program for other operating sytems.

  • You need a Windows xp or Vista computer. I will recommend 1 Gb of RAM or more.
  • You need to download and install the following free software to your computer.

I will be introducing a few more things in the future as we go along. But let's just start with these few.

C# for New Programmers:: List of Posts

I plan for this post to hold a link to all subsequent posts in this series ... a table of contents of sorts. So, each time I post something in this series, I will come to this page and add a link to it. The idea is to provide you a portal to every lesson in this series at just one place.

Topics:
C# Programming Tools
Program and Data
Types of Data I: Representing the alphabet
Types of Data II: Bits and Bytes
Types of Data III: Common data types
Types of Data IV: Declaring intent
Variables (Memory Stores): Declaring, Initializing, Assigning, Accessing
Console output and Input.
C# Operations
Commenting your code

Opening Comments

I am very delighted to welcome you to new DotNet();, a blog site designed precisely for new coders in mind. The whole idea is that someone who knows nothing about programming can come to this site and get lots of help to start programming the computer. I will be focusing on the .NET Framework and on C# development particularly. I choose C# because it is my favorite programming language and is easy and fun to program in.
The motivation for this effort is that most blog sites on the Internet today are pitched too high for the beginner. And there are concepts that new programmers find difficult to grasp which I hope to give a fresh, whimsical approach hoping that it clicks.
I will start this site by writing a series of introductory programming lessons. In addition, I will be happy to answer beginner-type questions and entertain comments. Sometimes, I may post some comments of my own.
If you are an experienced user, there are two ways you can contribute: (a) you can direct brand new coders to this site, and (b) you may revisit this site from time to time.The comments you contribute will help enrich the viewpoints. Who knows, you may even find some nuggets for yourself as well.
So, come with me. It's going to be fun.