Understanding the Importance of Programming Language Study
Explore the benefits of studying programming languages, including enhanced idea expression, better language selection, and improved learning abilities. Dive into language evaluation criteria and readability factors like simplicity, orthogonality, and control structures. Gain insights into readability through ALGOL, control statements, and syntactic expression rules.
Uploaded on Sep 28, 2024 | 0 Views
Download Presentation
Please find below an Image/Link to download the presentation.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. Download presentation by click this link. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.
E N D
Presentation Transcript
Why study Programming Languages? Increase your capacity to express ideas (both programming and in general) Increase your ability to select a PL for a specific use Increase your ability to learn new languages Provide you with a better understanding of implementation issues in programming Increase your ability to design a new PL Provide you with a better understanding of computational theory
Language Evaluation Criteria We will evaluate languages based on 5 criteria: Readability Writability Reliability Cost Tradeoffs Characteristic Readability * Writability * Reliability * Simplicity/ Orthogonality Control Structures Data types/ Structures Syntax Design * * * * * * * * * * * Support for Abstraction Expressitivity * * * * Type Checking Exception Handling Restricted Aliasing *
Readability The characteristic of code being easy to understand Factors include simplicity of instructions simpler is better (consider how many ways you can incr in C++/Java) orthogonality of instructions are operators/operations similar between types? for instance, do you add ints and floats in the same way? a lack of orthogonality leads to exceptions that is, using different approaches for different types consider in Java that you use == for primitives but the equals method for objects too much orthogonality can cause problems though, in Smalltalk, everything is an object, even a number operator and method/function overloading keeps instructions orthogonal
Readability Continued Two more factors of readability were introduced starting with ALGOL 60 control statements early languages had insufficient control structures leading to extensive use of GO TO statements most modern languages have adequate control statements so that GO TO statements are not needed and in many cases, not part of the language if/if-then/nested if-then multi-way statement (switch, case) two or three types of loops what about statements like break and continue? data Types and Structures enumerable types, boolean type, add to readability
More on Readability Another issue that impacts readability is of syntactic expression identifier rules early languages restricted length of names modern languages may differentiate between upper and lower case letters special words those words that make up the language are known as special (or reserved) words, the choice of words can make a language more readable explicit end statements (endif, endfor, enddo)? form and meaning are words reserved or based on context? in C, the usage of static is based on context in FORTRAN, INTEGER and REAL can be types and names INTEGER REAL REAL INTEGER // REAL is an INTEGER // INTEGER is a REAL
Writability Simplicity and Orthogonality simplicity has the same meaning as with readability, but the opposite effect the more complex an instruction, the better for the programmer C s for loop is very flexible good for writing, not so good for reading we still want orthogonal languages if you have to learn different ways to accomplish some task in different contexts, it becomes more difficult to learn the language Support for Abstraction data abstraction (for data structures) procedural abstraction (for modularity) Expressitivity does the language offer convenient ways to express ideas are there sufficient control structures? is the definition for a data type difficult or not available? etc.
Reliability How reliable can a program be written in the given language? Features include type checking does the language perform compile-time type checking? how thoroughly are variables checked? a strongly typed language will find all type mismatches at compile time unfortunately few languages are strongly typed subprogram parameter and global variable type checking is difficult exception handling introduced in PL/I in the early 60s, it was largely absent from languages until the late 1980s but now has become a component in most recent languages
Reliability Continued Additional reliability features include Aliasing two or more variables reference the same named item most commonly associated with pointers and parameters changing the item through one of the aliased names may be an unnoticed or undesired side effect most languages do nothing to prevent aliases Readability and Writability the more readable the language, the more reliable it will be the less writable the language, the greater the chance of hard-to-find errors
Cost Cost is primarily a function of time training/learning curve readability positively influences this, writability requires more training time to write programs writability positively influences this compilation speed/efficiency affects programmer time execution speed/efficiency execution speed is desired because this what the user sees most languages will sacrifice compilation speed for execution speed maintenance a language that is more readable and reliable is easier to maintain
Other Factors Portability Java excels here as do scripting languages Generality most languages today are general enough but some are too paradigm-specific (e.g., strictly functional languages) Well-definedness and standardization Lack of legacy issues modern languages generally don t have legacy issues Language selection can often be a tradeoff between readability and flexibility/writability (more flexible makes it less readable) cost and expressiveness type checking/reliability and abstraction/flexibility
Language Categories and Domains Historically, languages developed to solve particular types of problems FORTRAN math and science COBOL business applications/database accesses LISP AI (list processing and recursion) Languages were divided into programming paradigm Imperative (procedural like C, Pascal) Functional (LISP, F# among others) Declarative (Prolog) Object-oriented High-level languages can be classified as compiled vs interpreted scripting languages are interpreted although most also have compilers
PL Paradigms Procedural earliest form, still used today when OOP is not being used (e.g., in C or Java with only a single class) represent data code operates on data usually group code into subroutines for modularity OOP similar except that data and code are grouped together rather than thinking in terms of subroutines, you think in terms of a class, its functionality (what the class does) and its behavior (how it does it) OOP and procedural are similar in terms of types of programming language constructs and how you go about solving problems
PL Paradigms Continued Functional no (or few) local variables, instead mathematical functions which compute based (usually) solely on parameters disallow side effects f(x) should always return the same value for a given x recursion used extensively functional programming is the opposite of OOP Declarative no (or few) programming instructions declare what you know, ask a question language contains its own built-in processing (e.g., chaining, unification)