CS 330 Programming Languages 09 / 06 / 2007 Instructor: Michael Eckmann.

23
CS 330 Programming Languages 09 / 06 / 2007 Instructor: Michael Eckmann
  • date post

    21-Dec-2015
  • Category

    Documents

  • view

    214
  • download

    0

Transcript of CS 330 Programming Languages 09 / 06 / 2007 Instructor: Michael Eckmann.

Page 1: CS 330 Programming Languages 09 / 06 / 2007 Instructor: Michael Eckmann.

CS 330Programming Languages

09 / 06 / 2007

Instructor: Michael Eckmann

Page 2: CS 330 Programming Languages 09 / 06 / 2007 Instructor: Michael Eckmann.

Michael Eckmann - Skidmore College - CS 330 - Fall 2007

Today’s Topics• Introduction• Review the syllabus• Review the policies on academic dishonesty and

improper collaboration• First chapter stuff• Fill out a questionnaire

Page 3: CS 330 Programming Languages 09 / 06 / 2007 Instructor: Michael Eckmann.

Homework• Read chapter 1 in Sebesta before class Tuesday. Sections 1.3

and 1.4 are important so please read them carefully.

• I will email and post to our webpage a written assignment to be due 11:59 pm. September 11 via email to [email protected]

• I prefer plain text files, but will accept the typical word processing format.

• I'll email the whole class and ask that you each reply to me (not reply all) so I know I have your email address correct. Please also let me know if you want me to send email to additional addresses.

Michael Eckmann - Skidmore College - CS 330 - Fall 2007

Page 4: CS 330 Programming Languages 09 / 06 / 2007 Instructor: Michael Eckmann.

Michael Eckmann - Skidmore College - CS 330 - Fall 2007

Work• I designed the course and the assignments

with purpose in mind.

• Different types of assignments will require different types of thinking and skills.

• My intent is that they will be informative and challenging as well as have theoretical and practical value.

Page 5: CS 330 Programming Languages 09 / 06 / 2007 Instructor: Michael Eckmann.

Michael Eckmann - Skidmore College - CS 330 - Fall 2007

Reason to study Prog. Langs.• Increased ability to express ideas

– Hard to conceptualize what you can't describe

– Limited grasp of lang. -> limited complexity of thought

– (read paragraph from text) page 2.

– May be able to apply what is learned in one language to another. How?

• For choosing appropriate languages

– The more you know, the better you can fit the job to the language

– What language will you choose if you only know one language?

– What advantages are there to choosing the one you know?

Page 6: CS 330 Programming Languages 09 / 06 / 2007 Instructor: Michael Eckmann.

Michael Eckmann - Skidmore College - CS 330 - Fall 2007

Reason to study Prog. Langs.• Understand significance of implementation

– Use language more intelligently, e.g. Faster execution, avoid certain features, find bugs easier

• Ability to design new languages

• Overall advancement of computing

Page 7: CS 330 Programming Languages 09 / 06 / 2007 Instructor: Michael Eckmann.

Michael Eckmann - Skidmore College - CS 330 - Fall 2007

Syllabus

• Office hours

• Text book

• Class room

• Assignments – programs– homeworks

• Collaboration policy

• Grading scheme

• Attendance

• Workload

• Readings

Note: The most up-to-date syllabus will be found on the course web page.

Page 8: CS 330 Programming Languages 09 / 06 / 2007 Instructor: Michael Eckmann.

Application Areas of Prog. Langs.• Question: What are some differences between the needs of a scientific

application and a business application? What about vs. systems applications (e.g. OS's and their support programs.)

• Scientific applications

– Fortran, Algol 60, et al.

• Business applications

– Cobol

• Artificial intelligence

– Lisp, Prolog, Scheme

• Systems programming

– C

• Scripting languages

– Perl, JavaScript, PHP, et al.

• Special-purpose languagesMichael Eckmann - Skidmore College - CS 330 - Fall 2007

Page 9: CS 330 Programming Languages 09 / 06 / 2007 Instructor: Michael Eckmann.

Language Evaluation• When we talk about Language evaluation we're talking

about evaluating how effective the features of a language are at allowing programmers to create programs that are readable, writeable, reliable, costly etc.

• In that way we can then compare languages to each other in terms of how readable, writeable, reliable, costly, etc. the programs in each of those languages tend to be.

• This is different from comparing, for instance, how readable 2 programs written in the same language are.

Michael Eckmann - Skidmore College - CS 330 - Fall 2007

Page 10: CS 330 Programming Languages 09 / 06 / 2007 Instructor: Michael Eckmann.

Language Evaluation• Readability

– Why is it important?

– Software lifecycle (time/$ spent on maintenance vs. on initial coding)

– Simplicity (1 way vs. mult., operator overloading)

– Orthogonality (set of primitives combined in few ways in all combinations to build data structures (read pg. 10))

– Control (e.g. gotos vs. loops)

– Types (e.g. Using an int where a boolean is best)

– Structures (e.g. array of records vs. arrays of individuals)

– Syntax (identifier rules (limited size, valid chars), special words can be variable names --- any advantage to this?)

Michael Eckmann - Skidmore College - CS 330 - Fall 2007

Page 11: CS 330 Programming Languages 09 / 06 / 2007 Instructor: Michael Eckmann.

Language Evaluation• Writability

– Orthogonality• if small set and all combinations make sense +

• if large set and all combinations exist but some don't make sense to ever use or would be rarely used – (could cause undetected errors)

– Abstraction (functional (methods/functions) & data (classes))• don't need to know/be reminded of/replicate the implementation

details, just need to use what you wrote

– Expressivity (powerful operators or many ways to do the same things e.g. count++, for vs. while ...)

• Reliability

– (+)Type checking (at run-time vs. compile-time vs. neither)• when is better?

– (+)Exception Handling

– (-)Aliasing (why?)Michael Eckmann - Skidmore College - CS 330 - Fall 2007

Page 12: CS 330 Programming Languages 09 / 06 / 2007 Instructor: Michael Eckmann.

Language Evaluation• Cost (time == $)

– training programmers in the language– writing --- IDEs– compiling, executing --- compiler optimization

tradeoff– Implementation system (e.g. The compiler and/or

interpreter available for free?)– Poor reliability– Maintenance (up to 4 times cost of developing)

• Can you think of others?Michael Eckmann - Skidmore College - CS 330 - Fall 2007

Page 13: CS 330 Programming Languages 09 / 06 / 2007 Instructor: Michael Eckmann.

A few Imperative Languages

• C, Pascal and many others

• C++ is imperative-based but it is OO

• Java is also imperative-based but it is OO

Page 14: CS 330 Programming Languages 09 / 06 / 2007 Instructor: Michael Eckmann.

von Neumann Architecture

Michael Eckmann - Skidmore College - CS 330 - Fall 2007

Page 15: CS 330 Programming Languages 09 / 06 / 2007 Instructor: Michael Eckmann.

von Neumann bottleneck

• transmission/piping between memory and CPU takes longer than executing instructions within the CPU.

Michael Eckmann - Skidmore College - CS 330 - Fall 2007

Page 16: CS 330 Programming Languages 09 / 06 / 2007 Instructor: Michael Eckmann.

Imperative Language Features• Imperative languages are built FOR the von

Neumann architecture – Data and programs stored in same memory– Memory is separate from CPU– Instructions and data are transmitted from CPU to

memory, results are transmitted back to CPU

• Variables model memory cells

• Assignment statements model transmission

• Iteration is efficient (b/c instructions are in adjacent memory cells) – recursion is inefficient (b/c save state of each call).

Michael Eckmann - Skidmore College - CS 330 - Fall 2007

Page 17: CS 330 Programming Languages 09 / 06 / 2007 Instructor: Michael Eckmann.

Functional vs. Imperative Languages

• Functional (e.g. Lisp, Scheme, et al.)– Apply functions to parameters– different use of variables– No assignment statements– No iteration

– Many programmers feel that there are extreme benefits to computing using functional languages. So, why aren't they used more?

Michael Eckmann - Skidmore College - CS 330 - Fall 2007

Page 18: CS 330 Programming Languages 09 / 06 / 2007 Instructor: Michael Eckmann.

Functional vs. Imperative Languages

• Because of von Neumann, that's why!

• What might be a drawback to using a functional language on a von Neumann machine?

Michael Eckmann - Skidmore College - CS 330 - Fall 2007

Page 19: CS 330 Programming Languages 09 / 06 / 2007 Instructor: Michael Eckmann.

Imperative Languages

• Von Neumann => imperative languages

• But many programmers do not realize this and think that imperative languages are the natural way to program.

Michael Eckmann - Skidmore College - CS 330 - Fall 2007

Page 20: CS 330 Programming Languages 09 / 06 / 2007 Instructor: Michael Eckmann.

The major Language Groups

• Imperative– And visual langs (drag/drop code)

• Functional• Logic

– Rule based, no order of execution

• Object-Oriented

Michael Eckmann - Skidmore College - CS 330 - Fall 2007

Page 21: CS 330 Programming Languages 09 / 06 / 2007 Instructor: Michael Eckmann.

Some Language Design Trade-offs

• Reliability vs. cost of execution– e.g. Run-time array range checking --- Java vs. C

• Readability vs. writability (expressivity)– Compactness

• Flexibility vs. safety– e.g. Multiple types allowed in same memory location

Michael Eckmann - Skidmore College - CS 330 - Fall 2007

Page 22: CS 330 Programming Languages 09 / 06 / 2007 Instructor: Michael Eckmann.

Compilation, Interpretation, Hybrids

• What is a compiler?

• What is an interpreter?

• What is a hybrid of these?– Java, Perl– Compiler generates intermediate code that is then

interpreted– Any advantages/disadvantages?

Michael Eckmann - Skidmore College - CS 330 - Fall 2007

Page 23: CS 330 Programming Languages 09 / 06 / 2007 Instructor: Michael Eckmann.

Let's think about some stuff

• Any other language evaluation criteria you can think of?

• What are the pros and cons of case sensitivity in user defined names?

Michael Eckmann - Skidmore College - CS 330 - Fall 2007