why learn new programming languages
play

Why learn new [programming] languages? ! Communicate ideas better - PDF document

Why learn new [programming] languages? ! Communicate ideas better Become a better communicator (programming skills) CSCI: 4500/6500 Programming Translate ideas to words Languages Become a better listener ( compile information


  1. Why learn new [programming] languages? ! Communicate ideas better » Become a better communicator (programming skills) CSCI: 4500/6500 Programming – Translate ideas to words Languages » Become a better listener ( ‘ compile ’ information efficiency) – Translate words to ideas ! Comprehension: Motivation & Big Picture » Speakers ability to translate ideas into language » Listeners ability to translate work into ideas 1 2 Maria Hybinette, UGA Maria Hybinette, UGA Why study programming language concepts? What is programming language? ! Translator between you (ideas), the programmer ! One School of thought in Linguists: and the computer’s native language » A Language “ shapes the way we think ” and determines ! Computer’s native language: “ what we can think about ” [Whorf-Sapir Hypothesis 1956] » Programmers only skilled in one language may not have a » A computer is composed of on/off switches that tells deep understanding of concepts of other languages, the computer what to do. whereas those who are multi-lingual can solve problems in – 01111011 01111011 01111011 � many different ways. ! Help you choose appropriate languages for different ! How? application domains » Read by assemblers, compilers and interpreters and ! Increased ability to learn new languages converted into machine code that the computer » Concepts have more similarities understands ! Easier to express ideas ! Helps you make better use of whatever language you do use 3 4 Maria Hybinette, UGA Maria Hybinette, UGA What are components of a Programming Language programming language? Definition ! Syntax ! Like English -- each programming language has » Similar to the grammar of a natural language its own grammar, syntax (more details on this » Most languages defined uses a context free grammar (Chomsky ’ s type next week) and semantics. 2 grammar which can be described by non-deterministic PDA): – Production rules: A ! " , where A is a single non terminal and " is string of terminals and non terminals (regular languages are more restrictive " # { $ , aA, a } ) – Example: the language of properly matched parenthesis is generated by the grammar: S ! | SS | (S) | $ – <if-statement> ::= if (<expression>) <statement> [else <statement>] ! Semantics » What does the program “ mean ” ? » Description of an if-statement [K&R 1988]: – An if-statement is executed by first evaluating its expression, which must have arithmetic or pointer type, including all side-effects, and if it compares unequal to 0, the statement following the expression is executed. If there is an else part, and the expression is 0, the statement following the else is executed. 5 6 Maria Hybinette, UGA Maria Hybinette, UGA

  2. Why are there so many programming languages? Some Application Domains ! Evolution: We learn ‘ better ’ ways of doing ! Scientific computing: Large number of floating point things over time computations (e.g. Fortran) ! Business applications: Produce reports, use decimal ! Application Domains: Different languages are numbers and characters (e.g. COBOL) good for different application domains with different needs that often conflict (next slide) ! Artificial intelligence: Symbols rather than numbers manipulated (e. g. LISP) » Special purpose: Hardware and/or Software ! Systems programming: Need efficiency because of ! Socio-Economical: Proprietary interests, continuous use, low-level access (e.g., C) commercial advantage ! Web Software: Eclectic collection of languages: ! Personal Preferences: For example, some markup (e.g., XHTML-- not a programming language), prefers recursive thinking and other prefers scripting (e.g., PHP), general-purpose (e.g., Java) iterative thinking ! Academic: Pascal, BASIC 7 8 Maria Hybinette, UGA Maria Hybinette, UGA What makes a language successful? What makes a good language? No universal accepted metric for design. ! Expressiveness: Easy to express things, easy use The “ Art “ of designing programming languages once fluent, "powerful ” (C, Common Lisp, APL, Algol-68, Perl) Lets look at some characteristics and see how they ! Learning curve: Easy to learn (BASIC, Pascal, LOGO, affect the criteria below [Sebesta]: Scheme) ! Implementation: Easy to implement (BASIC, Forth) ! Readability: the ease with which programs can be ! Efficient: Possible to compile to very good (fast/small) read and understood code (Fortran) ! Writability: the ease with which a language can be ! Sponsorship: Backing of a powerful sponsor (COBOL, PL/1, Ada, Visual Basic) used to create programs ! Cost: Wide dissemination at minimal cost (Pascal, ! Reliability: conformance to specifications (i.e., Turing, Java) performs to its specifications) ! Cost: the ultimate total cost (includes efficiency) 9 10 Maria Hybinette, UGA Maria Hybinette, UGA Characteristics Compactness (Raymond) ! Simplicity: ! Compact : Fits inside a human head Too small Just right Too large » Modularity, Compactness » Test: Does an experienced user normally need a (encapsulation, abstraction) Bug Density manual? » Orthogonality (mutually » Not the same as weak (can be powerful and flexible) independent; well separated) » Not the same as easily learned ! Expressivity – Example: Lisp has a tricky model to learn then it becomes simple ! Syntax » Not the same as small either (may be predictable ! Control Structures and obvious to an experienced user with many pieces) ! Data types & Structures 0 200 400 600 800 ! Semi-compact: Need a reference or cheat Module Size (logical lines) ! Type checking sets of library or system sheet card calls runs up against human cognitive constraints ! Exception handling producing Hatton ’ s U-Curve ] Raymond ’ s The Art of Unix Programming] � 11 12 Maria Hybinette, UGA Maria Hybinette, UGA

  3. Compactness Orthogonality ! Mathematically means: ” Involving right angles ” ! The Magical Number Seven, Plus or Minus Two: Some ! Computing: Operations/Instructions do not have side Limits on Our Capacity for Processing Information effects; each action changes just one thing without [Miller 1956] affecting others. » Does a programmer have to remember more than seven ! Small set of primitive constructs can be combined in a entry points? Anything larger than this is unlikely to be strictly compact. relatively small number of ways (every possible combination is legal) ! C & Python are semi-compact » Example monitor controls: ! Perl, Java and shells are not (especially since serious – Brightness changed independently of the contrast level, color shell programming requires you to know half-a-dozen balance independently of both. other tools like sed(1) and awk(1)). ! Don ’ t repeat yourself rule: Every piece of knowledge must ! C++ is anti-compact -- the language's designer has have a single , unambiguous, authoritative representation admitted that he doesn't expect any one programmer within a system, or as Kernighan calls this: the Single Point to ever understand it all. Of Truth or SPOT rule. ! Easier to re-use mutually independent and well separated 13 14 Maria Hybinette, UGA Maria Hybinette, UGA Affects Readability while vs goto � � Simplicity x ! Overall simplicity while ( incr < 20 ) � loop 1: � � { � � if ( incr >= 20 ) � » Compactness Control Structures x � while ( sum <= 100 ) � � � goto out; � � � { � » Few “ feature multiplicity ” (c+=1, c++) loop 2: � Data types & x � � sum += incr; � � if ( sum > 100 ) � Structures – (means of doing the same operation) � � } � � � goto next; � Syntax Design x » Minimal operator overloading � incr++; � � sum += incr; � � } � � goto loop 2; � Support Abstraction ! Orthogonality next: � � Expressivity ! Syntax considerations � incr++; � � goto loop 1; � ! Comparison of a nested loop » Special words for compounds (e.g., end if .) Type Checking out: � versus doing the same task in a » Identifier forms (short forms of Fortran example) Exception Handling language without adequate control ! Control statements Restrictive Aliasing statements. » Data structures facilities (true/1) ! Which is more readable? » Control structures ( while vs goto example next ! 15 16 Maria Hybinette, UGA Maria Hybinette, UGA Affect Writability Affects Reliability ! Simplicity and orthogonality ! Type checking Simplicity x Simplicity x » Few constructs, a small number of » Testing for type errors Orthogonality Orthogonality primitives, a small set of rules for ! Exception handling Control Structures x Control Structures x combining them » Intercept run-time errors and take Data types & x ! Support for abstraction Data types & x corrective measures Structures Structures » The ability to define and use complex ! Aliasing Syntax Design x Syntax Design x structures or operations in ways that » Presence of two or more distinct Support Abstraction x allow details to be ignored Support x referencing methods for the same Abstraction memory location ! Expressivity Expressivity x Expressivity x ! Readability and writability » A set of relatively convenient ways of Type Checking x » A language that does not support specifying operations Type Checking Exception Handling x “ natural ” ways of expressing an » Example: the inclusion of for Exception Handling algorithm will necessarily use Restrictive Aliasing x statement in many modern languages “ unnatural ” approaches, and hence Restrictive Aliasing reduced reliability 17 18 Maria Hybinette, UGA Maria Hybinette, UGA

Recommend


More recommend