Kĩ thuật lập trình - Chapter 1: Overview a good programming language is a conceptual universe for thinking about programming. a. perlis

Various kinds of entities in a program have names: variables, types, functions, parameters, classes, objects, Named entities are bound in a running program to: Scope Visibility Type Lifetime

ppt31 trang | Chia sẻ: huyhoang44 | Lượt xem: 551 | Lượt tải: 0download
Bạn đang xem trước 20 trang tài liệu Kĩ thuật lập trình - Chapter 1: Overview a good programming language is a conceptual universe for thinking about programming. a. perlis, để xem tài liệu hoàn chỉnh bạn click vào nút DOWNLOAD ở trên
Programming Languages 2nd edition Tucker and NoonanChapter 1OverviewA good programming language is a conceptual universe for thinking about programming. A. PerlisContents1.1 Principles1.2 Paradigms1.3 Special Topics1.4 A Brief History1.5 On Language Design 1.5.1 Design Constraints 1.5.2 Outcomes and Goals1.6 Compilers and Virtual MachinesProgramming languages have four properties:SyntaxNamesTypesSemanticsFor any language:Its designers must define these propertiesIts programmers must master these properties1.1 PrinciplesSyntaxThe syntax of a programming language is a precise description of all its grammatically correct programs.When studying syntax, we ask questions like:What is the grammar for the language?What is the basic vocabulary?How are syntax errors detected?NamesVarious kinds of entities in a program have names: variables, types, functions, parameters, classes, objects, Named entities are bound in a running program to:ScopeVisibilityTypeLifetimeTypesA type is a collection of values and a collection of operations on those values.Simple typesnumbers, characters, booleans, Structured typesStrings, lists, trees, hash tables, A language’s type system can help to:Determine legal operationsDetect type errorsSemanticsThe meaning of a program is called its semantics.In studying semantics, we ask questions like:When a program is running, what happens to the values of the variables?What does each statement mean?What underlying model governs run-time behavior, such as function call?How are objects allocated to memory at run-time?A programming paradigm is a pattern of problem-solving thought that underlies a particular genre of programs and languages.There are four main programming paradigms:ImperativeObject-orientedFunctionalLogic (declarative)1.2 ParadigmsImperative ParadigmFollows the classic von Neumann-Eckert model:Program and data are indistinguishable in memoryProgram = a sequence of commandsState = values of all variables when program runsLarge programs use procedural abstractionExample imperative languages: Cobol, Fortran, C, Ada, Perl, The von Neumann-Eckert ModelObject-oriented (OO) ParadigmAn OO Program is a collection of objects that interact by passing messages that transform the state.When studying OO, we learn about:Sending MessagesInheritancePolymorphismExample OO languages: Smalltalk, Java, C++, C#, and PythonFunctional ParadigmFunctional programming models a computation as a collection of mathematical functions.Input = domainOutput = rangeFunctional languages are characterized by:Functional compositionRecursionExample functional languages:Lisp, Scheme, ML, Haskell, Logic ParadigmLogic programming declares what outcome the program should accomplish, rather than how it should be accomplished.When studying logic programming we see:Programs as sets of constraints on a problemPrograms that achieve all possible solutionsPrograms that are nondeterministicExample logic programming languages: PrologEvent handlingE.g., GUIs, home security systemsConcurrencyE.g., Client-server programsCorrectnessHow can we prove that a program does what it is supposed to do under all circumstances?Why is this important???1.3 Special TopicsHow and when did programming languages evolve?What communities have developed and used them?Artificial IntelligenceComputer Science EducationScience and EngineeringInformation SystemsSystems and NetworksWorld Wide Web1.4 A Brief HistoryDesign ConstraintsComputer architectureTechnical settingStandardsLegacy systemsDesign Outcomes and Goals1.5 On Language DesignWhat makes a successful language?Key characteristics:Simplicity and readabilityClarity about bindingReliabilitySupportAbstractionOrthogonalityEfficient implementationSimplicity and ReadabilitySmall instruction setE.g., Java vs SchemeSimple syntaxE.g., C/C++/Java vs PythonBenefits:Ease of learningEase of programmingA language element is bound to a property at the time that property is defined for it.So a binding is the association between an object and a property of that objectExamples: a variable and its type a variable and its valueEarly binding takes place at compile-timeLate binding takes place at run timeClarity about BindingReliabilityA language is reliable if:Program behavior is the same on different platformsE.g., early versions of FortranType errors are detectedE.g., C vs HaskellSemantic errors are properly trappedE.g., C vs C++Memory leaks are preventedE.g., C vs JavaLanguage SupportAccessible (public domain) compilers/interpretersGood texts and tutorialsWide community of usersIntegrated with development environments (IDEs)Abstraction in ProgrammingDataProgrammer-defined types/classesClass librariesProceduralProgrammer-defined functionsStandard function librariesOrthogonality A language is orthogonal if its features are built upon a small, mutually independent set of primitive operations.Fewer exceptional rules = conceptual simplicityE.g., restricting types of arguments to a functionTradeoffs with efficiencyEfficient implementation Embedded systemsReal-time responsiveness (e.g., navigation)Failures of early Ada implementationsWeb applicationsResponsiveness to users (e.g., Google search)Corporate database applicationsEfficient search and updatingAI applicationsModeling human behaviorsCompiler – produces machine codeInterpreter – executes instructions on a virtual machineExample compiled languages:Fortran, Cobol, C, C++Example interpreted languages:Scheme, Haskell, PythonHybrid compilation/interpretationThe Java Virtual Machine (JVM)1.6 Compilers and Virtual MachinesThe Compiling ProcessThe Interpreting ProcessDiscussion QuestionsComment on the following quotation: It is practically impossible to teach good programming to students that have had a prior exposure to BASIC; as potential programmers they are mentally mutilated beyond hope of regeneration. – E. Dijkstra 2. Give an example statement in your favorite language that is particularly unreadable. E.g., what does the C expression while (*p++ = *q++) mean?Course Organization (to be completed by the instructor)Class meetings:Laboratory work:Written work:Examinations and grading:Course Web siteSoftware Downloads (Clite interpreter and all other programs that appear in this book)Compilers and interpreters (for running software that accompanies this book).

Các file đính kèm theo tài liệu này:

  • pptch01_8925.ppt
Tài liệu liên quan