CIS217 Concepts of Programming Languages Chapter 1 PDF
Document Details
Uploaded by AccomplishedUniverse8955
Tags
Summary
This document provides an overview of concepts of programming languages, including the reasons for studying programming languages, programming domains, language evaluation criteria, implementation methods, and programming environments. It covers fundamental topics relevant to programming language constructs and design.
Full Transcript
CIS217 CONCEPTS OF PROGRAMMING LANGUAGES CHAPTER-1 PRELIMINARIES Outline Reasons for Studying Concepts of Programming Languages Programming Domains Language Evaluation Criteria Influences on Language Design Language Categories Language Design...
CIS217 CONCEPTS OF PROGRAMMING LANGUAGES CHAPTER-1 PRELIMINARIES Outline Reasons for Studying Concepts of Programming Languages Programming Domains Language Evaluation Criteria Influences on Language Design Language Categories Language Design Trade-Offs Implementation Methods Programming Environments Summary Reasons for Studying Concepts of Programming Languages Increased ability to express ideas – It is believed that the depth at which we think is influenced by the expressive power of the language in which we communicate our thoughts. It is difficult for people to conceptualize structures they can’t describe, verbally or in writing. Improved background for choosing appropriate languages – Many programmers, when given a choice of languages for a new project, continue to use the language with which they are most familiar, even if it is poorly suited to new projects. – If these programmers were familiar with other languages available, they would be in a better position to make informed language choices. Increased ability to learn new languages – Programming languages are still in a state of continuous evolution, which means continuous learning is essential. – The TIOBE Programming Community issues an index (https://www.tiobe.com/tiobe-index) that is an indicator of the relative popularity of programming languages. Reasons for Studying Concepts of Programming Languages Better understanding of significance of implementation – Understanding of implementation issues leads to an understanding of why languages are designed the way they are. – This in turn leads to the ability to use a language more intelligently, as it was designed to be use. Better use of languages that are already known – The more languages you gain knowledge of, the better understanding of programming languages concepts you understand. Overall advancement of computing – In some cases, a language became widely used, at least in part, because those in positions to choose languages were not sufficiently familiar with programming language concepts. Programming Domains Scientific applications – The applications require large number of floating-point computations. – Fortran was the first language developed scientific applications. – ALGOL 60 was intended for the same use. Business applications – The first successful language for business was COBOL. – Producing reports, precise ways of describing and storing decimal numbers and character data, and the ability to specify decimal arithmetic operations. – The arrival of PCs started new ways for businesses to use computers. Programming Domains Artificial intelligence – Symbolic rather than numeric computations are manipulated. – Symbolic computation is more suitably done with linked lists than arrays. – LISP, Prolog, Scheme used for AI programming Systems programming – Need efficiency because of continuous use. – A language for this domain must provide fast execution. Furthermore, it must have low-level features that allow the software interfaces to external devices to be written. – The UNIX operating system is written almost entirely in C. Programming Domains Web software – The World Wide Web is supported by an eclectic collection of languages: markup languages (e.g. HTML), scripting (e.g. PHP), general-purpose (e.g. Java) – JavaScript is used mostly as a client-side scripting language. JavaScript is embedded in HTML documents and is interpreted by a browser that finds the code in a document that is being displayed. – PHP is a scripting language used on Web server systems. Its code is embedded in HTML documents. The code is interpreted on the server before the document is sent to a requesting browser. Language Evaluation Criteria Readability – The ease with which programs can be read and understood Writability – The ease with which a language can be used to create programs Reliability – Conformance to specifications (i.e., performs to its specifications) Cost – The ultimate total cost Other Language Evaluation Criteria Portability – The ease with which programs can be moved from one implementation to another Generality – The applicability to a wide range of applications Well-defined – The completeness and precision of the language’s official defining document Language Evaluation Criteria Influences on Language Design Computer Architecture Influences on Language Design Computer Architecture – Fetch-execute-cycle (on a von Neumann architecture computer) Influences on Language Design Programming Methodologies – 1950s and early 1960s: Simple applications worry about machine efficiency – Late 1960s: Process-oriented People efficiency became important; readability, better control structures Structured programming Top-down design and step-wise refinement Late 1970s: Process-oriented to data-oriented – data abstraction Middle 1980s: Object-oriented programming – Data abstraction + inheritance + polymorphism Language Categories Imperative – Central features are variables, assignment statements, and iteration – Include languages that support object-oriented programming – Include scripting languages – Include the visual languages – Examples: C, Java, Perl, JavaScript, Visual BASIC.NET, C++ Functional – Main means of making computations is by applying functions to given parameters – Examples: LISP, Scheme, ML, F# Logic – Rule-based (rules are specified in no particular order) – Example: Prolog Markup/programming hybrid – Markup languages extended to support some programming – Examples: JSTL, XSLT Language Design Trade-Offs Reliability vs. Cost of execution – Example: Java demands all references to array elements be checked for proper indexing, which leads to increased execution costs. – C does not require index range checking – C programs execute faster than semantically equivalent Java programs, although Java programs are more reliable. Readability vs. Writability – Example: 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 readability Writability (flexibility) vs. Reliability – Example: C pointers are powerful and very flexible but are unreliable – Because of the potential reliability problems with pointers, they are not included in Java Implementation Methods The major methods of implementing programming languages are compilation, pure interpretation, and hybrid implementation – Compilation: Programs are translated into machine language – Pure Interpretation: Programs are interpreted by another program known as an interpreter – Hybrid Implementation Systems: A compromise between compilers and pure interpreters The operating system and language implementation are layered over machine interface of a computer. These layers can be thought of as virtual computers, providing interfaces to the user at higher levels Implementation Methods Implementation Methods 1. Compilation – Translate high-level program (source language) into machine code (machine language) – Slow translation, fast execution – C, COBOL, C++, and Ada are by compilers. Implementation Methods 1. Pure Interpretation – Programs are interpreted by another program called an interpreter, with no translation. – Advantage: Easier implementation of many source-level debugging operations, because all run-time error messages can refer to source-level units. – Disadvantage: Slower execution (10 to 100 times slower than compiled programs) – Significant comeback with some Web scripting languages (e.g., JavaScript and PHP). Implementation Methods 1. Hybrid Implementation Systems: – A compromise between compilers and pure interpreters – A high-level language program is translated to an intermediate language that allows easy interpretation – Faster than pure interpretation – Examples: – 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) Programming Environment The collection of tools used in software development UNIX – An older operating system and tool collection – Nowadays often used through a GUI (e.g., CDE, KDE, or GNOME) that runs on top of UNIX Borland JBuilder – An integrated development environment for Java Microsoft Visual Studio.NET – A large, complex visual environment – Used to program in C#, Visual Basic.NET, JScript (Microsoft’s version of JavaScript), F# (a functional language), and C++ NetBeans – Primarily used for Java application but also supports JavaScript, Ruby, and PHP Anaconda – Primarily used for Data Science Languages such as R, Python Evolution of the Major Programming Languages Summary The study of programming language is valuable for several important reasons: – Increases our capacity to use different constructs in writing programs – Enables us to choose languages for projects more intelligently – Makes learning new languages easier Among the most important criteria for evaluating languages are: – Readability – Writability – Reliability – Overall cost The major methods of implementing program languages are – Compilation – Pure interpretation – Hybrid implementation