Lecture 1
Programming
Programming a computer simply means
telling the computer what to do.
You have a language of your own. Your
boss all the time tells you what to do in that language of you. Everything goes
fine. Now, think that your boss and you have different languages- both of you
are reluctant to learn your languages. What do you do? Well, the most common
thing you can do is to invoke a third party so that you understand what your
boss is asking you to do and your boss can be satisfied after knowing that you
have done it! Now, you speak English and computer speaks somewhat called
assembly language. You rarely understand assembly language and computer
unfortunately fails to understand English. Big problem, no? To solve this
problem, programming languages have been developed. Both the programmer and the
computer obey some specific conventions to know each other. You may have heard
names of several programming languages like C, C++, and Java. The conventions
that you and computer obey vary from language to language but more or less they
are almost identical.
Skills for programmers
It is neither hard nor easy to
program. Well, contradiction! But one thing is undisputed that many of us are
afraid of programming! When we hear about computer programming, we say “wow!
That guy is a programmer!! Surely he has guts!” Of course, a programmer is
quite an astonishing guy, but it is not his innate or natural ability to
program. It is not about power either.
It is not strength of one as well. Then
what makes a guy programmer? Well, I can give you an analogy. Can you
differentiate between a footballer and a musician? Maradona is a very skillful
player, creative as well. But can he do what he wants to do anytime? He needs
to depend on the rules of the game and the 10 other players! What about David
Gilmour? He plays guitar and is a legend. Do you agree that maradona actually
is much more centered to a goal or aim (to win a match) than Gilmour (to
create)? Maradona is analogous to a programmer, not Gilmour! A programmer can
create many things with his brain and 10 fingers but he needs to be restricted
with the conventions so that his child- his machine can understand what he
wants to create.
Here are 4 skills that Steve Summit
said required by a programmer
Some things you do need are (1)
attention to detail, (2) stupidity, (3) good memory, and (4) an ability to
think abstractly, and on several levels. Let's look at these qualities in a bit
more detail:
- Attention to detail
In programming,
the details matter. Computers are incredibly stupid (more on this in a minute).
You can't be vague; you can't describe your program 3/4 of the way and then say
``Ya know what I mean?'' and have the compiler figure out the rest. You have to
dot your i's and cross your t's. If the language says you have to declare
variables before using them, you have to. If the language says you have to use
parentheses here and square brackets there and squiggly braces some third
place, you have to.
- Stupidity
Computers are
incredibly stupid. They do exactly what you tell them to do: no more, no
less. If you gave a computer a bottle of shampoo and told it to read the
directions and wash its hair, you'd better be sure it was a big bottle of
shampoo, because the computer is going to wet hair, lather, rinse, repeat, wet
hair, lather, rinse, repeat, wet hair, lather, rinse, repeat, wet hair, lather,
rinse, repeat.
I saw an ad by
a microprocessor manufacturer suggesting the “smart'' kinds of appliances we'd
have in the future and comparing them to “dumb'' appliances like toasters. I
believe they had it backwards. A toaster (an old-fashioned one, anyway) has two
controls, and one of them is optional: if you don't set the darkness control,
it'll do the best it can. You don't have to tell it how many slices of bread
you're toasting, or what kind. (``Modern'' toasters have begun to reverse this
trend...) Compare this user interface to most microwave ovens: they won't even
let you enter the cooking time until you've entered the power level.
When you're programming, it helps to be able to “think'' as stupidly as the computer does, so that you're in the right frame of mind for specifying everything in minute detail, and not assuming that the right thing will happen unless you tell it to.
When you're programming, it helps to be able to “think'' as stupidly as the computer does, so that you're in the right frame of mind for specifying everything in minute detail, and not assuming that the right thing will happen unless you tell it to.
(This is not to say that you have to
specify everything; the whole point of a high-level programming language
like C is to take some of the busywork burden off the programmer. A C compiler
is willing to intuit a few things--for example, if you assign an integer
variable to a floating-point variable, it will supply a conversion
automatically. But you have to know the rules for what the compiler will assume
and what things you must specify explicitly.)
- Good memory
There are a lot
of things to remember while programming: the syntax of the language, the set of
prewritten functions that are available for you to call and what parameters
they take, what variables and functions you've defined in your program and how
you're using them, techniques you've used or seen in the past which you can
apply to new problems, bugs you've had in the past which you can either try to
avoid or at least recognize by their symptoms. The more of these details you
can keep in your head at one time (as opposed to looking them up all the time),
the more successful you'll be at programming.
- Ability to abstract, think on
several levels
This is
probably the most important skill in programming. Computers are some of the
most complex systems we've ever built, and if while programming you had to keep
in mind every aspect of the functioning of the computer at all levels, it would
be a Herculean task to write even a simple program.
One of the most powerful techniques for managing the complexity of a software system (or any complex system) is to compartmentalize it into little ``black box'' processes which perform useful tasks but which hide some details so you don't have to think about them all the time.
We compartmentalize tasks all the time, without even thinking about it. If I tell you to go to the store and pick up some milk, I don't tell you to walk to the door, open the door, go outside, open the car door, get in the car, drive to the store, get out of the car, walk into the store, etc. I especially don't tell you, and you don't even think about, lifting each leg as you walk, grasping door handles as you open them, etc. You never (unless perhaps if you're gravely ill) have to worry about breathing and pumping your blood to enable you to perform all of these tasks and subtasks.
One of the most powerful techniques for managing the complexity of a software system (or any complex system) is to compartmentalize it into little ``black box'' processes which perform useful tasks but which hide some details so you don't have to think about them all the time.
We compartmentalize tasks all the time, without even thinking about it. If I tell you to go to the store and pick up some milk, I don't tell you to walk to the door, open the door, go outside, open the car door, get in the car, drive to the store, get out of the car, walk into the store, etc. I especially don't tell you, and you don't even think about, lifting each leg as you walk, grasping door handles as you open them, etc. You never (unless perhaps if you're gravely ill) have to worry about breathing and pumping your blood to enable you to perform all of these tasks and subtasks.
0 comments:
Post a Comment