Documente Academic
Documente Profesional
Documente Cultură
+ Programming
Computer Hardware and Software 1.1 What Is a Computer? 1.2 Computer Organization 1.4 Computer Languages and Levels 1.9 Key Software Trend: Object Technology Computer Languages and IDEs 1.7 Early Procedural High-Level Languages 1.5 C and C++ 1.6 Java Python Integrated Development Environment (IDE) 1.8 Microsoft .NET Framework Tutorial 1.10 Compiling and Running C++ Applications 1.11 Test-Driving the Applications 1.12 Internet and Web Resources Lab and Homework Assignment
Copyright 19922005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.
Copyright 19922005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.
1.1
What Is a Computer?
Computers are designed to meet a specific set of requirements. Computer History In the early days, these requirements were to meet some military, science, civil, or commercial need. For the military, it was predominately the calculation of ballistic tables. For science to calculate the motion of the planets or the weather. For civil keeping track of people and commercial keeping track of the money. To meet these requirements the computer was conceived and described by its hardware and it instruction set. Hardware components for all modern day computers, were codified by Von Neumann in his landmark paper describing the architecture of the EDVAC computer the instruction set is a list of all the instructions the computer can understand The Language of the Machine
Copyright 19922005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.
1.2
Computer Organization
Output
Places computer-processed information on output devices (making it available for use outside of the computer)
Memory
Usually volatile (data is lost after computer shuts off
Copyright 19922005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.
1.2
Control
Oversees all computer activities
Copyright 19922005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.
1.2
We are all familiar with the memory hierarchy (Figure 1) if not by name by experience. As we spiral out from the cpu memory becomes slower, larger, and more inexpensive. But where did the hierarchy come from and why does it exist at all. The earliest computer architects recognized the need for a hierarchical memory structure. Ideally one would desire an indefinitely large memory capacity such that any particularword would be immediately availableWe are forced to recognize the possibility of constructing a hierarchy of memories, each of which has greater capacity that the preceding but which is less quickly accessible.
A.W. Burks, H.H. Goldstine, and J. von Neumann, Preliminary Discussion of the Logical Design of an Electronic Computing Instrument (1946).
Copyright 19922005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.
1.2
Copyright 19922005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.
1.2
That the memory hierarchy works at all is a direct result of the Locality of Reference.
As a general rule-of-thumb a program spends 90% of its execution time in only 10% of the code. An implication of locality is that based on the programs recent past, one can predict with reasonable accuracy what instructions and data a program will use in the future.
Hennessy and Patterson 1st Edition
This hypothesis leads directly to the Principle of Locality which has two dimensions: Temporal locality (locality in time) If an item is reference, it will tend to be referenced again soon. Spatial locality (locality in space) If an item is referenced, nearby items will tend to be referenced soon.
Copyright 19922005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.
1.4
Machine Languages The language of the computer Example: grossPay = basePay + overtimePay 9100 0100 9110 0102 0f01 9300 0101 The numbers in the above example are in base 16 (hexadecimal) Number Systems Assembly Languages (ex. AVR, 80x86, ARM, MIPS, Itanium,) Machine language in a human readable form using mnemonics Assemblers convert assembly languages to machine languages lds r16, basePay lds r17, overtimePay add r16, r17 sts grossPay, r16
Copyright 19922005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.
1.4
High-Level Languages (ex. Basic, Fortran, COBOL, Ada, Pascal) Compilers convert to machine languages
1.9
Procedural Programming Languages (verb) Focus on actions. Good analogy is a Cooking Recipes.
Objects (noun)
Object Circle Properties the attributes of an object (adjective). Methods what the object can do (adverb). May also be referred to as behaviors or functions. Class
1.7
BASIC
Beginners All-Purpose Symbolic Instruction Code (BASIC) For simple programs and teaching novices
COBOL
Still used in business software
A very Verbose Language
Pascal
Designed for teaching structured programming (a precursor to Objects)
Ada
Sponsored by the Department of Defense Named after Lady Ada Lovelace (the first computer programmer)
Copyright 19922005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.
1.5
C and C++
C is a middle-level computer language, combining the elements of highlevel languages with the functionality of assembly language C is portable, not tied to any particular hardware or operating system. The C programming language was developed at Bell Labs circa 1969 1973 as a system implementation language for the nascent Unix operating system. C was a direct descendant of the language B. The language B was developed by Ken Thompson in 1970 for the new UNIX OS. B was a descendant of the language BCPL designed by Martin Richards, a Cambridge University student visiting MIT.
Sources: http://www.hitmill.com/programming/cpp/cppHistory.html http://cm.bell-labs.com/cm/cs/who/dmr/chist.html
Copyright 19922005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.
1.5
C and C++
C++ was written by Bjarne Stroustrup at Bell Labs during 1983-1985. C++ is an extension of C. Prior to 1983, Bjarne Stroustrup added features to C and formed what he called "C with Classes". He had combined the Simula's use of classes and object-oriented features with the power and efficiency of C. The term C++ was first used in 1983. Hybrid language C style Provides capabilities for Object-Oriented Programs (OOPs)
Copyright 19922005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.
1.5
C++ is a vast language that has evolved over many years. C++ is a mainstream language used in industry, engineering, and education. C++ is a lean language in that you add to it libraries that your particular program(s) require and exclude overhead libraries that are not needed. The hope is to create reusable code and minimize redundancy...this is the notion of OOP or Object Orientated Programming.
Copyright 19922005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.
1.6
Java
Java and Python are general-purpose interpreted, object-oriented, highlevel programming languages Java was developed by James Gosling at Sun Microsystems and released in 1995. The language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities. Java applications are typically compiled to bytecode (class file) that can run on any Java Virtual Machine (JVM) regardless of computer architecture. It is intended to let application developers "write once, run anywhere". Java is currently one of the most popular programming languages in use, and is widely used from application software to web applications.
Source: http://en.wikipedia.org/wiki/Java_%28programming_language%29
Copyright 19922005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.
Python
Like Java, Python is a general-purpose interpreted, objectoriented, high-level programming language.
Work on Python started in December 1989 by Guido van Rossum in the Netherlands as a successor to the ABC programming language
C provided some of Python's syntax, One of the early objectives of Python was to be easily learnable and not too arcane in its syntax and semantics, reaching out to non-programmers this is no longer an active concern.
Source: http://en.wikipedia.org/wiki/History_of_Python
Copyright 19922005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.
An IDE is a software application that provides comprehensive facilities to computer programmers for software development. An IDE normally consists of: a source code editor a compiler and/or an interpreter build automation tools a debugger Typically an IDE is dedicated to a specific programming language, providing a feature set for the programming paradigms of the language. Some multiple-language IDEs are in use, such as Eclipse, NetBeans, and Microsoft Visual Studio to name a few.
Copyright 19922005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.
1.8
The Microsoft .NET Framework is a software framework for Microsoft Windows operating systems. The .NET Framework supports several programming languages (Visual Basic, C++, C#) which allows language interoperability (each language can use code written in other languages). All .NET programs are by definition high-level running on an application virtual machine, so that programmers need not consider the capabilities of the specific CPU (Platform independent). The .NET Framework includes a large library
The library provides user interface, data access, database connectivity, cryptography, web application development, numeric algorithms, and network communications.
The class library is used by programmers, who combine it with their own code to produce applications. The .NET library is available to all the programming languages that .NET supports.
Copyright 19922005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.
1.10 Files
Compilation
Turns high-level source code into machine language code Command prompt Allows text instructions to be given to the computer
Copyright 19922005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.
What is it? Its a right-click context menu that opens a command prompt window at the current working directory, wherever you pop up the context menu. How? In Windows Explorer, simply hold the Shift key and right-click the folder you want to set as working directory, choose Open Command Window here.
Source: http://www.windows7hacker.com/index.php/2009/08/how-to-open-dos-promptcommand-here-in-windows-7-and-more
Copyright 19922005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.
1.10
Figure 1.1
Copyright 19922005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.
1.10
Figure 1.2
Copyright 19922005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.
1.11
Test-Driving the Car Payment Calculator and Guess the Number Applications
Open Command Prompt Start > All Programs > Accessories > Command Prompt Change directories Type cd C:\Examples\Tutorial01\CarPayment Type cd C:\Examples\Tutorial01\GuessNumber Run an application Type CarPayment Type GuessNumber
Copyright 19922005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.
1.11
Figure 1.3
Test-Driving the Car Payment Calculator and Guess the Number Applications (Cont.)
Changing to the Car Payment Calculator applications directory.
Copyright 19922005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.
1.11
Figure 1.4
Test-Driving the Car Payment Calculator and Guess the Number Applications (Cont.)
Running the Car Payment Calculator application.
Copyright 19922005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.
1.11
Figure 1.5
Test-Driving the Car Payment Calculator and Guess the Number Applications (Cont.)
Car Payment Calculator with data entered.
Copyright 19922005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.
1.11
Figure 1.6
Test-Driving the Car Payment Calculator and Guess the Number Applications (Cont.)
Car Payment Calculator application displaying calculation results.
Close box
1.11
Figure 1.7
Test-Driving the Car Payment Calculator and Guess the Number Applications (Cont.)
Changing to the Guess the Number applications directory.
Copyright 19922005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.
1.11
Figure 1.8
Test-Driving the Car Payment Calculator and Guess the Number Applications (Cont.)
Running the Guess the Number application.
Copyright 19922005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.
1.11
Figure 1.9
Test-Driving the Car Payment Calculator and Guess the Number Applications (Cont.)
Entering an initial guess.
Copyright 19922005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.
1.11 Test-Driving the Car Payment Calculator and Guess the Number Applications (Cont.)
Figure 1.10 Entering a second guess and receiving feedback.
Copyright 19922005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.
1.11
Figure 1.11
Test-Driving the Car Payment Calculator and Guess the Number Applications (Cont.)
Guessing the correct number.
Copyright 19922005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.
1.12
Copyright 19922005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.
Answer and Turn-in Tutorial 1 Questions at the end of the Chapter. Always write the question followed by the answer. Remember to highlight the answer.
Search the Web for a Good Hello World Tutorial using the Microsoft Visual Studio IDE. Include as question 1.16. For the answer write the URL and in a few sentences why you like the tutorial. Web Tutorial may be a website or a video. Due next Wednesday
Copyright 19922005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.