comp 14 introduction to programming instructor: prasun dewan (pr sün divän)

15
Comp 14 Introduction to Programming Instructor: Prasun Dewan (Prsün Divän)

Post on 21-Dec-2015

215 views

Category:

Documents


1 download

TRANSCRIPT

Comp 14Introduction to Programming

Instructor: Prasun Dewan

(Prsün Divän)

Computer WorldHardwareOperating SystemProgramProcessorInstruction (e.g. add 2 to 5)Source CodeObject CodeProgramming LanguageMachine LanguageProgrammersLibrary (of Code)Translator(Compilers/Interpreter)UsersDisks

MemoryMemory PageMemory WordMemory AddressRunning a ProgramInteractive ProgramNon-interactive (Batch)ProgramProgram argumentsRuntimeEditorEditing ProgramsLexical ErrorSyntax ErrorSemantics ErrorLogic ErrorDebuggingStyle Principles

Theater Analogy

•Play

•Concert

•Talk

•Speech

•Cooking Lessons

•Town Hall Meeting

Performer

Theater

1.1(a) The Theater World

PerformanceLanguagewritten in

Audience

performs

PerformanceScript

follows

Theater Management

managing

Notebook / Teleprompter

stored in

Stagehand

assists

Real Trial

fetched from

Archive

Performer

1.1(b) The Theater World

Original Script

written in Scriptlanguage

reads entire script

Translator

writes entirescript

Translator (Interpreter)

hears sentence

speaks sentence

PerformanceScript

PerformanceLanguagewritten in

1.1 (a) The Theater World

ReferenceMaterial

Secretarylinks

OriginalScript

Script Writer

written by

Word Processor, Script WriterTranslator / Interpreter,Stagehand, Performer

checked by

problems

Syntax, Semantics, Logic, & Style

uses

Word Processor /Typewriter

1.2(a) The Computer World

ObjectCode

MachineLanguagewritten in

User

ProcessorMemory

fetched from

Disk / Tape

stored in

Debugging

follows

interacts with

RuntimeReal

assists

managing

OperatingSystem

1.2 (b) The Computer World

SourceCode

ObjectCode

written in ProgrammingLanguage

Compiler Interpreter

reads entire code

reads statement

writes entirecode

writes statement

MachineLanguagewritten in

1.3 Translating using both a Compiler and Interpreter

Source Code

Platform-IndependentIntermediate Code

Interpreter

Platform-SpecificMachine Code

Compiler

CPU

1.2 (a) The Computer World

Libraries

SourceCode

Linkerlinks

Program Editor

uses

Programmer

written by problems

written in ProgrammingLanguage

Editor, Programmer, Translator, Operating System Runtime, Processor

checked by

Syntax, Semantics, Logic, & Style

J++

Computer Vs TheaterComputer World Theater WorldHardware TheaterOperating System Theater ManagementProgram PerformanceProcessor PerformerInstruction (e.g. add 2 to 5) Performance action (e.g. walk 3

steps.)Source Code Original ScriptObject Code Performance ScriptProgramming Language Script Language (e.g. German)Machine Language Performance Language (e.g.

English)Programmers Script WritersLibrary (of Code) Reference Material (from

Books)Translator(Compilers/Interpreter)

Translator (Before/DuringPerformance)

Users AudienceDisks Archival Storage AreasMemory Script performance notebook

accessible to performers

Computer Vs TheaterComputer World Theater WorldMemory Page A Notebook PageMemory Word A Notebook LineMemory Address (PageNumber, Word Number)

Line Identification (PageNumber, Line Number)

Running a Program Performing a ScriptInteractive Program Performance with audience

participationNon-interactive (Batch)Program

Performance with no audienceparticipation

Program arguments Special instructions at start ofperformance

Runtime Stage-HandsEditor Typewriter/WordprocessorEditing Programs Writing ScriptsLexical Error Spelling ErrorSyntax Error Grammar ErrorSemantics Error Inconsistencies in ScriptLogic Error Execution ErrorDebugging Staging trial performancesStyle Principles Style Principles

Computer Vs Theater

• CPU is fast: can do several performances at one time.

• CPU is dumb: no improvisation possible.

• Machine language much lower-level than programming language.

Why Java

• Modern, modular (object-oriented) language.

• Good Error Detection.

• Rich Library Embodying Many Good Programming Principles

• Can Write Teaching Tool (ObjectEditor)

Java Versions, Dialects & Programming Enviromnet

• JDK 1.1

• Microsoft Implementation

• Swing 1.1

• Visual J++ Programming Environment

• Will not matter