C OMP 110 – I NTRODUCTION TO P ROGRAMMING Instructor: Jason Carter
C OMPUTER W ORLD HardwareMemory Operating SystemMemory Page ProgramMemory Word ProcessorMemory Address Instruction (e.g. add 2 to 5)Running a Program Source CodeInteractive Program Object CodeNon-interactive (Batch) Program Programming LanguageProgram arguments Machine LanguageRuntime ProgrammersEditor Library (of Code)Editing Programs Translator (Compilers/Interpreter)Lexical Error UsersSyntax Error DisksSemantics Error Logic Error Debugging Style Principles
T HEATER A NALOGY Play Concert Talk Speech Cooking Lessons Town Hall Meeting
T HEATER W ORLD – P ART 1 Performer Theater Performer Stage Audience Performs RealTrial Performance Script Follows Performance Language Written in Notebook or Teleprompter Stored in Archive Fetched from Stagehand Assists Management Manages
T HEATER W ORLD – P ART 2 Performance Script Performance Language Written in Original Script Script Language Written in Translator Translator (Interpreter) Writes entire script Reads entire script Speaks sentence Hears sentence
T HEATER W ORLD – P ART 3 Original Script Script Language Written in Script Writer Written by Typewriter, Text Editor Uses Secretary Reference Material Links Syntax, Semantics, Logic, & Style Problems Checked by Word Processor, Script Writer Translator / Interpreter, Stagehand, Performer Word Processor, Script Writer Translator / Interpreter, Stagehand, Performer
C OMPUTER W ORLD – P ART 1 Processor Computer Users Interacts with RealDebugging Object Code Follows Machine Language Written in Memory Stored in Disk, Tape Fetched from Runtime Assists Operating System Manages
C OMPUTER W ORLD – P ART 2 Object Code Machine Language Written in Source Code Programming Language Written in Compiler Interpreter Writes entire source code Reads source code Writes statement Reads statement
Processor Compiler Interpreter Source Code Platform Independent Intermediate Code Platform Specific Machine Code T RANSLATING U SING B OTH A C OMPLIER AND A N I NTERPRETER
T HEATER W ORLD – P ART 3 Source Code Programming Language Written in Programmer Written by Typewriter, Text Editor Uses Linker Libraries Links Syntax, Semantics, Logic, & Style Problems Checked by Editor, Programmer, Translator, Operating System Runtime, Processor Editor, Programmer, Translator, Operating System Runtime, Processor
C OMPUTER VS. T HEATER ComputerTheater HardwareTheater Operating SystemTheater Management ProgramPerformance ProcessorPerformer Instruction (e.g. add 2 to 5)Performance action (e.g. walk 3 steps.) Source CodeOriginal Script Object CodePerformance Script Programming LanguageScript Language (e.g. German) Machine LanguagePerformance Language (e.g. English) ProgrammersScript Writers Library (of Code)Reference Material (from Books) Translator (Compilers/Interpreter)Translator (Before/During Performance) UsersAudience DisksArchival Storage Areas MemoryScript performance notebook accessible to performers HardwareTheater
C OMPUTER VS. T HEATER ComputerTheater Memory PageA Notebook Page Memory WordA Notebook Line Memory Address (Page Number, Word Number) Line Identification (Page Number, Line Number) Running a ProgramPerforming a Script Interactive ProgramPerformance with audience participation Non-interactive (Batch) ProgramPerformance with no audience participation Program argumentsSpecial instructions at start of performance RuntimeStage-Hands EditorTypewriter/Wordprocessor Editing ProgramsWriting Scripts Lexical ErrorSpelling Error Syntax ErrorGrammar Error Semantics ErrorInconsistencies in Script Logic ErrorExecution Error DebuggingStaging trial performances Style Principles
C OMPUTER VS. T HEATER CPU is fast: can do several performances at one time. CPU is dumb: no improvisation possible. Machine language much lower-level than programming language.
W HY J AVA Modern, modular (object-oriented) language. Good Error Detection. Rich Library Embodying Many Good Programming Principles Can Write Teaching Tool (ObjectEditor)
J AVA V ERSIONS, D IALECTS & P ROGRAMMING E NVIRONMENT JDK 1.5+ Eclipse IDE Programming Environment