Presentation is loading. Please wait.

Presentation is loading. Please wait.

Programming Languages: History & Traditional Concepts CSC 2001.

Similar presentations


Presentation on theme: "Programming Languages: History & Traditional Concepts CSC 2001."— Presentation transcript:

1 Programming Languages: History & Traditional Concepts CSC 2001

2 Solution development  Three main tasks (all very important):  Understanding the problem  unambiguous, complete description  verification/testing  Solution planning  pseudocode  algorithmic design  verification/testing  Implementation  expressing solution in a manner that a computer can execute  “programming,” but being a computer programmer is more than this!!  verification/testing  Three main tasks (all very important):  Understanding the problem  unambiguous, complete description  verification/testing  Solution planning  pseudocode  algorithmic design  verification/testing  Implementation  expressing solution in a manner that a computer can execute  “programming,” but being a computer programmer is more than this!!  verification/testing

3 Implementation  Historical perspective  Traditional programming concepts  Procedural units  Language implementation  Programming language paradigms  imperative programming  object-oriented programming  Others  Alice  Programming Lego Mindstorm Robots with Drizzle  Historical perspective  Traditional programming concepts  Procedural units  Language implementation  Programming language paradigms  imperative programming  object-oriented programming  Others  Alice  Programming Lego Mindstorm Robots with Drizzle

4 History  Machines can execute instructions in machine language.  4056  Problems?  machine dependent  hard to read, write, and fix (debug)  Machines can execute instructions in machine language.  4056  Problems?  machine dependent  hard to read, write, and fix (debug)

5 Assembly language  In 1940’s, programmers developed a mnemonic notational system to help.  4056 became something like…  MOV R5, R6  had to build assemblers to translate to machine language  Pros?  more readable, easier to write  Cons?  still very low level and machine dependent  In 1940’s, programmers developed a mnemonic notational system to help.  4056 became something like…  MOV R5, R6  had to build assemblers to translate to machine language  Pros?  more readable, easier to write  Cons?  still very low level and machine dependent

6 Remaining challenges  Machine independent language  Ability to express instructions in larger increments  Why are these good goals?  What additional tools need to be built to make it work?  Can you foresee any major obstacles with this?  Machine independent language  Ability to express instructions in larger increments  Why are these good goals?  What additional tools need to be built to make it work?  Can you foresee any major obstacles with this?

7 Two early successes  FORTRAN  FORmula TRANslator  focused on scientific applications  COBOL  Common Business-Oriented Language  developed by US Navy for business applications  FORTRAN  FORmula TRANslator  focused on scientific applications  COBOL  Common Business-Oriented Language  developed by US Navy for business applications

8 Supporting tools  compilers  translated from higher level language  stores result of translation for later execution  interpreters  execute while translating  compilers  translated from higher level language  stores result of translation for later execution  interpreters  execute while translating

9 Language “generations”  First generation  machine language  Second generation  assembly language  needs assemblers  Third generation  higher level languages  needs compilers or interpreters  First generation  machine language  Second generation  assembly language  needs assemblers  Third generation  higher level languages  needs compilers or interpreters

10 High level language goals revisited  Did the third generation languages achieve their goals of machine independence and larger instruction increments?  Larger instruction increments?  Yes  Machine independent solutions?  In theory  Did the third generation languages achieve their goals of machine independence and larger instruction increments?  Larger instruction increments?  Yes  Machine independent solutions?  In theory

11 What do I mean?  We traded machine dependence for compiler dependence.  If all compilers define the language exactly the same way, we have machine independence.  This is often not the case!  We traded machine dependence for compiler dependence.  If all compilers define the language exactly the same way, we have machine independence.  This is often not the case!

12 Standards  Languages typically have a “standard” formal definition.  Compiler developers can choose to extend the language if they want to.  Using these non-standard extensions can lock you into a particular machine and compiler because no one else recognizes those extensions.  Why might a compiler developer do that?  Languages typically have a “standard” formal definition.  Compiler developers can choose to extend the language if they want to.  Using these non-standard extensions can lock you into a particular machine and compiler because no one else recognizes those extensions.  Why might a compiler developer do that?

13 Case study  Java  Developed by SUN with specific goal of machine independence.  Microsoft’s Java implementation violated standard.  Microsoft was told they couldn’t call it Java.  Still, you can’t assume “Java is Java.”  Lines are often more blurry with other languages.  Best to usually stick with standard unless there is a very good reason to deviate!  Java  Developed by SUN with specific goal of machine independence.  Microsoft’s Java implementation violated standard.  Microsoft was told they couldn’t call it Java.  Still, you can’t assume “Java is Java.”  Lines are often more blurry with other languages.  Best to usually stick with standard unless there is a very good reason to deviate!

14 Programming language concepts  A program consists of an ordered set of statements expressed (typically) in some high level programming language.  Statement types  Declarative statements  Imperative statements  Comments  A program consists of an ordered set of statements expressed (typically) in some high level programming language.  Statement types  Declarative statements  Imperative statements  Comments

15 Declarative statements  “define customized terminology that is used later in the program”  associates names (variables) with locations in main memory  declares the “data type” of each variable  tells computer how to interpret the bits in memory  Why is this important?  “define customized terminology that is used later in the program”  associates names (variables) with locations in main memory  declares the “data type” of each variable  tells computer how to interpret the bits in memory  Why is this important?

16 Data types  Common primitive data types  integers (int)  real (double)  character (char)  Boolean  Example declarations (notations may differ!)  int x, y, amount;  double average;  char grade;  Common primitive data types  integers (int)  real (double)  character (char)  Boolean  Example declarations (notations may differ!)  int x, y, amount;  double average;  char grade;

17 Data structures  an organization or collection of primitive data types  provides more intuitive ways to manage data  Lists (1 dimensional) or tables (multi- dimensional)  arrays  Homogeneous (same type)  enables working with them as a single unit  Example declarations (notations may differ!)  char name[12]; (character string)  float scores[120][20];  an organization or collection of primitive data types  provides more intuitive ways to manage data  Lists (1 dimensional) or tables (multi- dimensional)  arrays  Homogeneous (same type)  enables working with them as a single unit  Example declarations (notations may differ!)  char name[12]; (character string)  float scores[120][20];

18 Custom data structures  Example: managing student info  Option 1:  Have one array for each of the following:  last name, first name, SSN, email address, final average, final grade  Problems?  changing sort order?  Example: managing student info  Option 1:  Have one array for each of the following:  last name, first name, SSN, email address, final average, final grade  Problems?  changing sort order?

19 Custom data structures  Example: managing student info  Option 2:  Create a custom student data structure that holds a student’s first and last names, SSN, email address, and final average and grade.  Have a single array of “students”  Example: managing student info  Option 2:  Create a custom student data structure that holds a student’s first and last names, SSN, email address, and final average and grade.  Have a single array of “students”

20 Custom data structure  We can declare that a “student” data structure looks as follows: (notations may differ!) typedef struct { char lastName[20], firstName[20]; int SSN; char email[40]; float average; char grade; } student; What does that mean? Is Option 2 better than Option 1? Why or why not?  We can declare that a “student” data structure looks as follows: (notations may differ!) typedef struct { char lastName[20], firstName[20]; int SSN; char email[40]; float average; char grade; } student; What does that mean? Is Option 2 better than Option 1? Why or why not?

21 Data structures  Just like with primitive data types, data structures tell the computer how to interpret the bits in the memory locations associated with the variable name!

22 Variables, constants, and literals  Values of variables often change during program execution.  Values of constants and literals don’t.  Literals: explicit numbers (3.1415, 17)  Constants: descriptive names for numbers (PI)  Values of variables often change during program execution.  Values of constants and literals don’t.  Literals: explicit numbers (3.1415, 17)  Constants: descriptive names for numbers (PI)

23 Literals v. constants  Example:  Program to compute sales price:  has array of items with prices  has to include sales tax (10 %) .10  Can use literals everywhere  Problems  Readability (what does that.1 represent?)  Maintainability (need to change value of sales tax without changing the price of things costing a dime)  Use a constant called SALES_TAX (good practice)  Example:  Program to compute sales price:  has array of items with prices  has to include sales tax (10 %) .10  Can use literals everywhere  Problems  Readability (what does that.1 represent?)  Maintainability (need to change value of sales tax without changing the price of things costing a dime)  Use a constant called SALES_TAX (good practice)

24 To do…  Read chapter 6


Download ppt "Programming Languages: History & Traditional Concepts CSC 2001."

Similar presentations


Ads by Google