Download presentation
Presentation is loading. Please wait.
Published byReginald Brooks Modified over 9 years ago
1
Department of Computer and Information Science, School of Science, IUPUI Dale Roberts, Lecturer Computer Science, IUPUI E-mail: droberts@cs.iupui.edu CSCI 230 Introduction to Computers - Languages
2
Computer Organization A Typical Von-Neumann Architecture Example: 1. Input unit 2. Output unit 3. Memory unit 4. Arithmetic and logic unit (ALU) 5. Central processing unit (CPU) 6. Secondary storage unit Control Circuit (ex: PC: Program Counter) ALU MemoryI/O CPU
3
Programming Languages 1. Machine languages (machine dependent) Native tongue of a particular kind of computer. Each instruction is a binary string. The code is used to indicate the operations to be performed and the memory cells to be addressed. This form is easiest form of computers to understand, but is most difficult for a person to understand. Strings of numbers giving machine specific instructions Example:+1300042774 +1400593419+1200274027
4
Programming Languages (cont.) 2.Assembly languages (machine dependent) English-like abbreviations representing elementary computer operations (translated via assemblers) Again specific to only one type of computer. Uses descriptive names for operations and data, e.g., “LOAD value”, “ADD delta”, “STORE value”. Assemblers will translate these to machine languages. Intermediate level. Somewhat descriptive, but basically following the machine instructions. Example:LOAD BASEPAY ADD OVERPAY STORE GROSSPAY
5
Programming Languages (cont.) 3. High-level languages (machine independent) Codes similar to everyday English High-level languages: Write program instructions called statement that resemble a limited version of English. e.g., the statement “value = value + delta”. Portable, meaning it can be used on different types of computers without modifications. Compilers translate them to machine languages. Examples are FORTRAN, PASCAL, COBOL, C, C++, BASIC etc. Use mathematical notations (translated via compilers) Example: grossPay = basePay + overTimePay Example: a= a + b Statement: a= a + b 10 7 17 7 a b a b Before After
6
Programming Languages (cont.) Structured programming Disciplined approach to writing programs Clear, easy to test and debug and easy to modify Multitasking Specifying that many activities run in parallel (still timesliced) Language Application Area FORTRANScientific programmingFormula Translation COBOLBusiness data ProcessingCommon Business-Oriented Language LispArtificial Intelligence (AI)List Processing CSystem ProgrammingPredecessor B PrologAILogic Programming AdaReal-time distributed systemsAda Augusta Byron & Charles Babbage SmalltalkGUI, OOPObjects “talk” via message C++Supports object & OOPC (++ is the increment operator) JAVASupportsWeb programmingOriginally named “Oak” Origin of Name
7
Semantic Gap A “semantic gap” exists between the amount of information conveyed in assembly language v high level languages. Consider the following C single statement: x = x + 3; This single statement may require many assembly language statements (operations): Load memory location 24 into accumulator Add a constant 3 to the accumulator Store accumulator in memory location 24 The number of executable statement expands greatly during the translation process from a high level language into assembly language.
8
C Programming Language C High-level general-purpose language developed in 1972 at AT&T Bell Lab. By Dennis Ritchie from two previous programming BCPL and B Originally developed to write the UNIX operating system Hardware independent (portable) By late 1970's C had evolved to "Traditional C" Today, virtually all new operating systems are written in C or C++. The current standard in C is ANSI C. C++ is a more advanced version of C, incorporating among other things, the object-oriented constructs Standardization Many slight variations of C existed, and were incompatible Committee formed to create a "unambiguous, machine-independent" definition Standard created in 1989, updated in 1999 C has become a popular language industry due its power and flexibility
9
The C Standard Library C programs consist of pieces/modules called functions A programmer can create his own functions Advantage: the programmer knows exactly how it works Disadvantage: time consuming Programmers will often use the C library functions Use these as building blocks Avoid re-inventing the wheel If a pre-made function exists, generally best to use it rather than write your own Library functions carefully written, efficient, and portable
10
The C Standard Library (cont.) The Key Software Trend: Objects in C++ and JAVA Reusable software components that model items in the real world Meaningful software units: ex: Date objects, time objects, audio objects, video objects, file objects, record objects…a ny noun can be represented as an object More understandable, better organized, and easier to maintain than procedural programming Favor modularity
11
The C Standard Library #include #include main(){ int i; int i; for (i = 0; i ++; i < 10) for (i = 0; i ++; i < 10) { printf ("Hello World!\n"); printf ("Hello World!\n"); }}
12
A Typical C Program Development Environment 1.Edit 2.Preprocess 3.Compile 4.Link 5.Load 6.Execute Disk Loader Linker Compiler Preprocessor Editor Disk Primary Memory CPU Primary Memory 1.Program is created in the editor and stored on disk 2.Preprocessor program processes the code 3.Compiler creates object code and stores it on disk. 5.Loader puts program in memory. 4. Linker links the object code with the libraries 6.CPU takes each instruction and executes it, possibly storing new data values as the program executes Phases of C Programs:
13
A Typical C Program Development Environment (cont.) Procedure to Prepare a C Program for ExecutionProcedure to Prepare a C Program for Execution Enter the program code and save as a source (*.c) file using Word Processor (editor) The linker links the new object file with other object files The loader places the executable file into memory Executable program in memory Failure Success Source (.c) file on disk (Format: text) Revised source file New object (*.obj) files (Format: binary) Executable (*.exe, *.out) file (Format: binary) Welcome to CSCI230 Other object (*.obj) files Correct syntax errors List of errors Compiler attempts to translate the program into machine code Input data Results
14
Constructs in C Language Type Declarations: ex: Type Declarations: ex: int, float,… I/O: ex: I/O: ex: printf(), scanf() Arithmetic and Logical Operations: ex: Arithmetic and Logical Operations: ex: +,-,*,/,%,>,<,==,… Arrays, Pointers, Structures, Unions, … Functions Arguments & return values Recursion Control Mechanisms: ex: Control Mechanisms: ex: if, else, while, for,… Characters & Strings: ex: Characters & Strings: ex: strcat(), strcpy(), … File Processing: ex: File Processing: ex: fopen(), fclose(), … Pre-processor: ex: Pre-processor: ex: #define …Misc. bit operations,...
15
Operation System (OS) Responsibilities: Communicating with the computer user Managing allocation of memory, of processor time, and of other resources for various tasks I/O handling: BIOS vs DOS services (Interrupts) Read/Write data from secondary storage Evolution of Operating Systems Batch processing: do only one job or task at a time Operating systems: manage transitions between jobs and Increase throughput (amount of work computers process) Multiprogramming: Computer resources are shared by many jobs or tasks Timesharing: Technique used to implement multiprogramming where the computer runs a small portion of one user’s job then moves on to service the next user Command-line Interface Graphical User Interface (GUI) UNIXMacOS MS_DOSWindows VMSX Windows (linux and solaris)
16
Application Software Developed to assist a computer user in accomplishing special tasks ex: word processing applications: MS-word or Word-perfect ex: Spreadsheet applications: Lotus1-2-3, Excel ex: Database: Oracle, MS-Access Software Development Life Cycle (SDLC) Problem: specify the problem requirements Analysis: analyze the problem Design: design the algorithm to solve the problem Implementation: Implement the algorithm Testing: test and verify the completed program Maintenance: maintain and update the program
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.