User Tools

Site Tools


computer_basics:programming_fundamentals

This is an old revision of the document!


View page as slide show

Programming Fundamentals

Mithat Konar
with material from Capron's “Essentials of Computing”, 2/e

What is programming?

  • programming: the discipline of creating computer software.
  • computer program:
    • a set of step-by-step instructions
    • that directs the computer to do the tasks you want it to do
    • and produce the results you want.
  • Programmer → computer program → software.

What programmers do

  • “Write programs”
    • Prepare the instructions of a computer program.
    • Test and correct programs.
    • Document the way a program works.
    • Interact with other programmers, systems analysts, clients.

Programming languages

  • programming language:
    • a set of rules used to write computer programs.
    • a way of telling the computer what operations to perform.
  • Computers are binary machines.
    • Use only ON/OFF switches to control internal states
    • Only understand instructions that are expressed in ON/OFF (or 1/0) terms.
  • To make it easier for humans to program computers, various programming languages have been invented.

Levels of language

  • Programming languages exist on a spectrum of low to high level.
    • low level: close to the 1/0 language the computer directly uses.
    • high level: closer to natural language or mathematics.
  • Five levels:
    • machine language
    • assembly languages
    • high level languages
    • very high level languages
    • natural language programming

Machine language

  • The lowest level of language.
  • Consists of 1’s and 0’s.
10110110100100101101011101001010
10110110110101101101011011000111
  • Each type of computer processor has its own machine language.

Assembly language

  • Use alphanumeric abbreviations or mnemonic codes as substitutes for machine language
    • ADD for Add, CMP for Compare, MOV for Move, etc.
MOV AL, 1h
MOV CL, 2h
MOV DL, 3h
  • An assembler program converts an assembly language program into machine language.

High-level languages

  • Use general notation systems that most humans can understand.
    • Often English-like or math-like.
  • Much more convenient to write and repair.
  • Allows programmer to think less about language details and more about solving problem.
  • “Write once, run anywhere.”

Very high-level languages

  • Try to come closer to natural language than high-level languages.

Natural language programming

  • Tries to let people program using everyday language.
  • “Show a list of names from the contact list,” works just as well as “Display the names of everyone in the contact list.”

Kinds of translation

  • High-level languages need to be translated into machine language.
  • Three approaches to translation:
    • interpreted: translate one line of the program, run it, move to the next.
    • compiled: translate the whole program at once; produces a machine code file that is executed.
    • hybrid: translate the whole program into an in-between language; execute the in-between language in an interpreter.

Kinds of errors

  • syntax error: you broke a language rule.
  • semantic or logic error: the program runs and doesn't complain, but it doesn't produce the desired result.
  • runtime error: you ask the program to do something it can't, like divide A by B when B happens to be zero.

Programming process

  1. Define the problem.
  2. Design a solution.
  3. Code the solution.
  4. Test the solution.
  5. Document the solution.

Define the problem

  • Undefined problems cannot be solved.
  • May be formal or informal.
  • Sometimes simple, often not.

Design a solution

  • Design your solution before you try to build it!
  • 80/20 rule: spend 80% of your time designing, 20% writing.

Code the solution

  • Write the programming language statements and other resources you need to implement the design.

Test the solution

  • debugging: detecting, locating, and fixing mistakes.
  • desk checking: working through your code without running it to find mistakes.

Document the solution

  • documentation: a written detailed description of the programming cycle and specific facts about the program.
  • Many languages let you include some documentation in the program code.
  • Documentation is needed:
    • to help organize program planning
    • to help communicate with others about your program.
    • to help remind you what your program is doing.
  • Very important!!!

Programming tools

  • code editor: used to write the program code (i.e., source code).
  • translator: used to translate source code into a form the computer can execute.
  • debugger: used to interactively run a program and observe its internal state.
  • project manager: used to organize source code and other files associated with a program.
  • IDE (integrated development environment): integrates a number of these tools into one unified environment to help increase productivity.

Fin

<html> <script> var uls = document.getElementsByTagName('ul'); for(var i=0,j=uls.length;i<j;++i){uls[i].setAttribute('class','incremental')} </script> </html>

computer_basics/programming_fundamentals.1534988793.txt.gz · Last modified: 2018/08/23 01:46 by mithat

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki