Unformatted text preview:

23CS 538 Spring 2006©Lisp (List Processing Language)Example:((lambda (x) (* x x)) 10)Developed in the early 60s.A radical departure from earlierprogramming languages.Programs and data are represented ina uniform list format.Types are a property of data values,not variables or parameters.A program can build and run newfunctions as it executes.Data values were not fixed in size.Memory management was automatic.A formal semantics was developed todefine precisely what a programmeans.24CS 538 Spring 2006©Simula 67 (Simulation Algol)Example:Class Rectangle (Width, Height);Real Width, Height;Boolean Procedure IsSquare; IsSquare := Width=Height;End of Rectangle;Developed about 1967.Introduced the notion of a class (forsimulation purposes).Included objects, a garbage collector,and notions of extending a class.C++ was originally C with classes (asSimula was Algol with classes).25CS 538 Spring 2006©C and C++C was developed in the early 70’s;C++ in the mid-80s.These languages have a concise,expressive syntax; they generate highquality code sufficient forperformance-critical applications.C, along with Unix, provided theviability of platform-independentlanguages and applications.C and C++ allow programmers a greatdeal of freedom in bending andbreaking rules.Raises the issue of whether onelanguage can span both novice andexpert programmers.26CS 538 Spring 2006©Interesting issue—if most statementsand expressions are meaningful, canerrors be readily detected?if (a=b) a=0;else a = 1;27CS 538 Spring 2006©JavaDeveloped in the late 90s.Cleaner object-oriented languagethan C++.Introduced notions of dynamicloading of class definitions across theWeb.Much stronger emphasis on secureexecution and detection of run-timeerrors.Extended notions of platformindependence to systemindependence.28CS 538 Spring 2006©What Drives Research intoNew Programming Languages?Why isn’t C or C++ or C+++ enough?1. CuriosityWhat other forms can a programminglanguage take?What other notions of programmingare possible?2. ProductivityProcedural languages, including C,C++ and Java, are very detailed.Many source lines imply significantdevelopment and maintenanceexpenses.29CS 538 Spring 2006©3. ReliabilityToo much low-level detail inprograms greatly enhances thechance of minor errors. Even minorerrors can raise significant problemsin applications.4. SecurityComputers are entrusted with ever-increasing responsibilities. How canwe know that a program is safe andreliable enough to trust?5. Execution speedProcedural languages are closely tiedto the standard sequential model ofinstruction execution. We may needradically different programmingmodels to fully exploit parallel anddistributed computers.30CS 538 Spring 2006©Desirable Qualities in aProgramming LanguageTheoretically, all programminglanguages are equivalent (Why?)If that is so, what properties aredesirable in a programming language?31CS 538 Spring 2006©• It should be easy to use.Programs should be easy to read andunderstand.Programs should be simple to write,without unexpected pitfalls.It should be orthogonal, providingonly one way to do each step orcomputation.Its notation should be natural for theapplication being programed.• The language should supportabstraction.You can’t anticipate all needed datastructures and operations, so addingnew definitions easily and efficientlyshould be allowed.32CS 538 Spring 2006©• The language should support testing,debugging and verification.• The language should have a gooddevelopment environment.Integrated editors, compilers,debuggers, and version control are abig plus.• The language should be portable,spanning many platforms and operatingsystems.33CS 538 Spring 2006©• The language should be inexpensive touse:Execution should be fast.Memory needs should be modest.Translation should be fast andmodular.Program creation and testing shouldbe easy and cheap.Maintenance should not be undulycumbersome.Components should be reusable.34CS 538 Spring 2006©Programming ParadigmsProgramming languages naturally fallinto a number of fundamental stylesor paradigms.Procedural LanguagesMost of the widely-known andwidely-used programming languages(C, Fortran, Pascal, Ada, etc.) areprocedural in nature.Programs execute statement bystatement, reading and modifying ashared memory.This programming style closelymodels conventional sequentialprocessors linked to a random accessmemory (RAM).35CS 538 Spring 2006©Question:Givena = a + 1; if (a > 10) b = 10; else b = 15; a = a * b;Why can’t 5 processors each executeone line to make the program run 5times faster?36CS 538 Spring 2006©Functional LanguagesLisp, Scheme and ML are functional innature.Programs are expressions to beevaluated.Language design aims to minimizeside-effects, including assignment.Alternative evaluation mechanismsare possible, includingLazy (Demand Driven)Eager (Data Driven or Speculative)37CS 538 Spring 2006©Object-Oriented LanguagesC++, Java, Smalltalk, Pizza andPython are object-oriented.Data and functions are encapsulatedinto Objects.Objects are active, have persistentstate, and uniform interfaces(messages or methods).Notions of inheritance and commoninterfaces are central.All objects that provide the sameinterface can be treated uniformly. InJava you can print any object thatprovides thetoString method. Youcan iterate through the elements ofany Java object that implements theEnumeration interface.38CS 538 Spring 2006©Subclassing allows to you extend orredefine part of an object’s behaviorwithout reprogramming all of theobject’s definition. Thus in Java, youcan take aHashtable class (which isfairly elaborate) and create a subclassin which an existing method (liketoString) is redefined, or newoperations are added.39CS 538 Spring 2006©Logic Programming LanguagesProlog notes that most programminglanguages address both the logic of aprogram (what is to be done) and thecontrol flow of a program (how to dowhat you want).A logic programming language, likeProlog, lets programmers focus on aprogram’s logic without concern forcontrol issue.These languages have no real controlstructures, and little notion of “flowof control.”What results are programs that areunusually succinct and focused.40CS 538 Spring 2006©Example:inOrder( [] ).inOrder( [ _ ] ).inOrder([a,b|c]) :- (a<b), inOrder([b|c]).This is a complete, executablefunction that determines if a list is inorder. It is naturally polymorphic, andis not cluttered with


View Full Document

UW-Madison COMPSCI 538 - Lecture 3 Notes

Download Lecture 3 Notes
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture 3 Notes and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture 3 Notes 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?