COMPUTATIONAL PHYSICS PROGRAMMING SHAHBAZ BHATTI Lecture 01
COMPUTATIONAL PHYSICS PROGRAMMING SHAHBAZ BHATTI Lecture 01
Physicists Course
Code: PHY-306
Lecture 01
First, it is indeed true that traditional forms of programming are useful for just a few people. But,
programming as we the authors understand it is useful for everyone: the administrative secretary
who uses spreadsheets as well as the high-tech programmer. In other words, we have a broader
concept of programming in mind than the traditional one. We explain our idea in a moment.
Second, we teach our idea of programming with a technology that is based on the principle of
minimal intrusion (burden). Hence, our concept of programming teaches problem-analysis and
problem-solving skills without imposing the overhead of traditional programming notations and
tools.”
By designing programs, we learn many skills that are important for all professions. These skills
can be summarized as:
Critical reading
Analytical thinking
Creative synthesis
What skills are needed?
Programming is an important activity as people life and living depends on the programs one
make. Hence while programming one should
Paying attention to detail.
Think about the reusability.
Think about user interface.
Understand the fact the computers are stupid.
Comment the code liberally (freely).
Program design recipe
‘How to design programs’ by Matthias Felleisen and the co-worker, the idea of design recipe
has been stated very smartly as
“Learning to design programs is like learning to play soccer. A player must learn to trap a ball, to
dribble with a ball, to pass, and to shoot a ball. Once the player knows those basic skills, the
next goals are to learn to play a position, to play certain strategies, to choose among feasible
strategies, and, on occasion, to create variations of a strategy because none fits. “
The author then continue to say that:
“A programmer is also very much like an architect, a composers, or a writer. They are creative
people who start with ideas in their heads and blank pieces of paper. They conceive of an idea,
form a mental outline, and refine it on paper until their writings reflect their mental image as
much as possible. As they bring their ideas to paper, they employ basic drawing, writing, and
playing music to express certain style elements of a building, to describe a person's character, or
to formulate portions of a melody. They can practice their trade because they have honed their
basic skills for a long time and can use them on an instinctive level.
To design a program properly, we must:
◦ Analyze a problem statement, typically expressed as a word problem.
◦ Evaluate and revise the activities in light of checks and tests and
Program, program and program, not just writing code, but the whole process of design and
development.
Lecture 02
We’ll discuss today
Software Categories
System Software
Application Software
History of C/C++ language
Development Environment of ‘C/C++’
Software Categories
Software is categorized into two main categories
System Software
Application Software
System Software
The system software controls the computer. It communicates with computer’s hardware (key
board, mouse, modem, sound card etc) and controls different aspects of operations. Sub
categories of system software are:
Operating system
Device drivers
Utilities
Application Software
A program or group of programs designed for end users. For example a program for accounting,
payroll, inventory control system and guided system for planes, GPS (global positioning system)
anther application software is being used in vehicles which through satellite determines the
The Compiler read the whole program and translates it into machine language completely.
The difference between interpreter and compiler is that compiler will stop translating if it finds an
error and there will be no executable code generated whereas Interpreter will execute all the lines
before error and will stop at the line which contains the error.
So Compiler needs syntactically correct program to produce an executable code. We will be using
compiler in our course.
Debugger
Another important tool is Debugger.
Every programmer should be familiar with it.
Debugger is used to debug the program i.e. to correct the logical errors.
Using debugger we can control our program while it is running.
We can stop the execution of our program at some point and can check the values in different
variables, can change these values etc.
In this way we can trace the logical errors in our program and can see whether our program is
producing the correct results.
This tool is very powerful, so it is complex too.
Thank You to bear
Linker
Most of the time our program is using different routines and functions that are located in
different files, hence it needs the executable code of those routines/functions.
Linker is a tool which performs this job, it checks our program and includes all those routines or
functions which we are using in our program to make a standalone executable code and this
process is called Linking.
Loader
After an executable program is linked and saved on the disk and it is ready for execution.
We need another process which loads the program into memory and then instruct the
processor to start the execution of the program from the first instruction (the starting point of
every C program is from the main function).
This processor is known as loader. Linker and loaders are the part of development environment.
These are part of system software. The following figure represents a graphical explanation of all
the steps involved in writing and executing a program.