Presentation on theme: "INTRODUCTION "When the only tool you have is a hammer, everything looks like a nail" (Abraham Maslow)"— Presentation transcript:
1 INTRODUCTION"When the only tool you have is a hammer, everything looks like a nail" (Abraham Maslow)
2 Administrivia This is me: Cyndi Rader You can reach me:Or find me here: BB 280DClass notes here:Office Hours: 8-9:15 T/Thand by appointment
3 Why study programming languages? LUA MEL Others??To enhance your ability to learn new languagesTo allow you to choose an appropriate tool for a given taskTo gain an appreciation for the challenges involved in implementing a languageLet’s see, should I use a scripting language, do I need speed & reliability, …What does that compiler message mean?Why did they design the languagethat way???
4 Why study programming languages? To expand your ability to express your ideas (effectively) using a given languageTo see some very different styles of programming (e.g., Ruby, Haskell)To avoid being a language zealotBecause it's fun!
6 Course Evaluation 45% homework, projects 5% class participation 50% exams and quizzes
7 Programming Domains Pick your tool – often depends on your domain… Scientific applications - FortranLarge number of floating point computationsEfficiency (compete with assembly)Business applications - COBOLProduce reports, use decimal numbers and charactersArtificial intelligence - LISPSymbols rather than numbers manipulatedLinked structures rather than arraysSystems programming - CNeed efficiency because of continuous useNeed low-level features to interface with hardwareWeb SoftwareEclectic collection of languages: markup (e.g., XHTML), scripting (e.g., PHP), general-purpose (e.g., Java)Pick your tool – often depends on your domain…
8 Language Evaluation Criteria What criteria would you use to evaluate/choose a language?
9 Language Evaluation Criteria Writability: how easy is it to write a program?Readability: how easy is it to read a program?Reliability: does it include features that help to produce more reliable software?Cost: what’s the ultimate cost?
10 Writeable and Readable SimplicitySupport for abstractionControl statementsData typesSyntaxOrthogonalityExpressivityWhat aspects of a language might make it easier to read than write (or vice versa)?
11 OrthogonalityA relatively small set of primitive constructs can be combined in a relatively small number of waysEvery possible combination is legalChanging one thing has no effect on anotherAs stated by Michael Scott:Orthogonality means that features can be used in any combination, the combinations all make sense, and the meaning of a given feature is consistent regardless of other features with which it is combined.261 example: arrays
12 ExpressivityFind something to share with the class – turn in for attendance pointsprogramming.htmlranked-by-expressiveness/when-referring-to-programming-languagesprogramming-language-literature.html
13 Evaluation Criteria: Reliability Type checkingTesting for type errorsException handlingIntercept run-time errors and take corrective measuresAliasingPresence of two or more distinct referencing methods for the same memory locationReadability and writabilityA language that does not support “natural” ways of expressing an algorithm will necessarily use “unnatural” approaches, and hence reduced reliabilityWhat do you think of this (from“I know that some readers will be looking at this code and thinking how unsafe it is. But what the hell – it fails fast, and in all the years I’ve had map in my toolkit I’ve never once messed it up.”
14 Evaluation Criteria: Cost Training programmers to use languageWriting programs (closeness to particular applications)Compiling programsExecuting programsLanguage implementation system: availability of free compilers (Ada vs Java)Reliability: poor reliability leads to high costsMaintaining programsHow does this relate to programming languages?
16 Language Design Trade-Offs Reliability vs. cost of executionConflicting criteriaExample: Java demands all references to array elements be checked for proper indexing but that leads to increased execution costsReadability vs. writabilityAnother conflicting criteriaExample: APL provides many powerful operators (and a large number of new symbols), allowing complex computations to be written in a compact program but at the cost of poor readabilityWritability (flexibility) vs. reliabilityExample: C++ pointers are powerful and very flexible but not reliably used. Not included in Java.
20 Programming Methodologies Influences 1950s and early 1960s: Simple applications; worry about machine efficiencyLate 1960s: People efficiency became important; readability, better control structuresstructured programmingtop-down design and step-wise refinementLate 1970s: Process-oriented to data-orienteddata abstractionMiddle 1980s: Object-oriented programmingData abstraction + inheritance + polymorphism
21 Language Categories Imperative/Procedural Functional Logic Central features are variables, assignment statements, and iterationExamples: C, Pascal, scripting languages such as PerlFunctionalMain means of making computations is by applying functions to given parametersExamples: LISP, SchemeLogicRule-based (rules are specified in no particular order)Example: Prolog, SQLObject-orientedData abstraction, inheritance, late bindingExamples: Java, C++, C#MarkupNew; not a programming language per se, but used to specify the layout of information in Web documentsExamples: XHTML, XMLWhat about CSS?
23 Implementation Methods CompilationPure InterpretationHybrid Implementation Systems
24 Think like a compilerScanner (lexical analyzer): identifies the tokens of a program statementParser (syntax analyzer): determines whether the statement is valid, based on the language definition/grammarint count = 20;Tokens:intcount=20;Grammar:Based on BNF
26 Additional Compilation Terminologies Load module (executable image): the user and system code togetherLinking and loading: the process of collecting system program and linking them to user program
29 Hybrid Implementation Systems A compromise between compilers and pure interpretersA high-level language program is translated to an intermediate language that allows easy interpretationFaster than pure interpretationExamplesPerl programs are partially compiled to detect errors before interpretationInitial implementations of Java were hybrid; the intermediate form, byte code, provides portability to any machine that has a byte code interpreter and a run-time system (together, these are called Java Virtual Machine)