New User Special Price Expires in

Let's log you in.

Sign in with Facebook


Don't have a StudySoup account? Create one here!


Create a StudySoup account

Be part of our community, it's free to join!

Sign up with Facebook


Create your account
By creating an account you agree to StudySoup's terms and conditions and privacy policy

Already have a StudySoup account? Login here

Principles of Programming Languages

by: Allie West II

Principles of Programming Languages CSCI 3155

Marketplace > University of Colorado at Boulder > ComputerScienence > CSCI 3155 > Principles of Programming Languages
Allie West II

GPA 3.51


Almost Ready


These notes were just uploaded, and will be ready to view shortly.

Purchase these notes here, or revisit this page.

Either way, we'll remind you when they're ready :)

Preview These Notes for FREE

Get a free preview of these Notes, just enter your email below.

Unlock Preview
Unlock Preview

Preview these materials now for free

Why put in your email? Get access to more of this material and other relevant free materials for your school

View Preview

About this Document

Class Notes
25 ?




Popular in Course

Popular in ComputerScienence

This 25 page Class Notes was uploaded by Allie West II on Thursday October 29, 2015. The Class Notes belongs to CSCI 3155 at University of Colorado at Boulder taught by Staff in Fall. Since its upload, it has received 14 views. For similar materials see /class/231998/csci-3155-university-of-colorado-at-boulder in ComputerScienence at University of Colorado at Boulder.


Reviews for Principles of Programming Languages


Report this Material


What is Karma?


Karma is the currency of StudySoup.

You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!

Date Created: 10/29/15
Set Types Handout C 6th June 2007 Sets of things are unordered collections of things where each thing may occur at most oncei While the usual de nition of sets on mathematics is somewhat different7 more extensive and more constructive the above simpli ed idea is what made its way into several programming languages To understand the use of sets assume for example that you want to model le access attributesi One approach would be to construct a recor TYPE Perm RECORD read write execute BOOLEAN END for this Each element of Perm could now set read wr ite and execute permis sions separate yr An alternative is to construct a set type restricted to a subset of an enu meration type with the enumerated values read write executei For each value v of this type we can separately determine whether the enumeration elements read write or execute are contained in 1 ie whether read 6 v analogously for write and execute t rst this seems like little more than a minor notational convenience and even that would be arguablei However values of set types generally allow us to express at least the set operations for union and intersection U and AyBUByC39 AyB Byc A7370 B Using these we can easily ensure eg that a le is not writable and not executable by simply performing set intersection with read implementing the same with the aforementioned record requires two statements and woul likely be less efficient Case study Java Amer Diwan Java Some similarities to Modula 3 7 Strongly typed 7 Single inheritance OO model 7 Garbage collection 7 Exceptions Some differences from Modula3 7 C family syntax 7 Name type equality 7 No UNSAFEUntraced 7 Separate interface and implementation inheritance 7 Bigger language de nition 7 400 pages excl libs Reference types Class Implements one or more explicit or implicit interfaces Array these are objects too Interface Lists a set of methods that all implementations of the interface must have Classes Single inheritance like Modula 3 Public protected private members like CH Classes may be final will not be subclassed 7 Has implications for implementation AND 7 Typing rulesH Class Object is the top of the inheritance hierarchy Problem with class inheritance class HasAPrint void print class Set extends HasAPrint void print class SortedList extends HasAPrint void print T a100 a0 new Set al new SortedList Let s change the implementation of SortedList class SortedList extends Collection void print What s the problem here Analysis of the problem Programmer used inheritance as a implementation reuse mechanism Client perceived inheritance as a subtyping mechanism A solution from the client Object a aO new Set al new SortedList Problem cannot do aiprintO Casting will be very awkward too Java s solution interfaces Interfaces are like fully abstract classes 7 No code just method declarations and constants Interfaces may use multiple inheritance Example Interface and Classes From John Mitchell s slides interface Shape public oat center public void rotate oat degrees interface Drawable public void setColorColor c public void draw class Circle implements Shape Drawable Using Java s interfaces interface HasAPrint void printO class Set extends implements HasAPrint void printO class SortedList implements HasAPrint void printO HasAPrint a aO new Set al new SortedList Clients only see interfaces and not implementation Complexity with interfaces interface Car public void driveunsigned speed interface Boat public void driveunsigned speed class AmphibiousVehicle implements Car Boat AmphibiousVehicle has two play methods What to do Interfaces are a very powerful concept Separates implementation from specification at a fine granularity 7 A class may implement many distinct interfaces Different from interfaces in languages like Modula2 and Modula3 or header files 7 Granularity 7 Inheritance of interfaces Type equality Unlike Modula 3 name equality except 7 Array types A and B are the same if they have the same element type 7 Array index type is not important since all arrays are dynamically allocated and have a compiletime unknown index type Type compatibility in Java Java expresses type compatibility in terms of narrowing and widening conversions A S lt A Wi ening T d V Narrowing Intuition behind conversions Widening 7 Subtype to supertype Always legal Narrowing 7 Supertype to subtype May or may not be legal 7 Interface type to class and vice versa May or may not be legal I ll focus on reference conversions in this lecture Conversions Narrowing and widening casts defined for both primitive and reference types 7 Widening casts are applied implicitly or explicitly 7 Narrowing casts must be explicitly applied Widening conversions subtypes Can convert from S to T if 7 ifS is a subclass ofT 7 ifS implements interface T 7 if S is NULL and T is any class type interface type or array type 7 ifS is a subinterface of T 7 ifS is an interface and T is Object 7 ifS is an array and T is Object 7 ifS is an array and T is Clonable Widening conversions continued If S is an array SC T is an array TC and 7 SC and TC are reference types and 7 widening conversion from SC to TC What if SC and TC are not reference types Sto 7S 7S 7S 7S 7S Narrowing conversions T if is superclass of T is a class T is an interface S is not a nal class is Object T is any array or interface type is an interface T is not a final class is interface T is final class and T implements S 7S T 7S Narrowing conversions cont and T are interfaces but S is not a subinterface of and they don t declare incompatible methods and T are array types and there is a narrowing conversion from their element types Narrowing conversions require runtime type tests What are the tests involved in the last narrowing rule Examples interface I interface J class S extends T implements I S to T T to S S to T T to S S to I S to J Assignment rules a A b B is allowed when 7 B A 7 B can be converted to A using widening conversions ie B lt A 7 For primitives sometimes a narrowing conversion is allowed Some implications for implementation Would be similar to Modula 3 but 7 no opaque types structural equality need less support from linker 7 invokeinterface in addition to vtables also need a more complex mechanism invokeinterface example from lVlitchell s slides interface Incrementable public void inc class IntCounter implements incrementable public void addint public void inc public int value class FloatCounter implements incrementable public void inc public void add oat public oat value Summary Type safe unchecked type errors cannot happen at runtime 7 Particular important given Java s target market Usually opts for clean over fast Mostly clean type system but perhaps not as elegant as that of M 3 Separates implementation from interface Next topic Case study Smalltalk Readings 7 Scott Sections 1061 Principles of Programming Languages Daniel von Dincklage1 1Department of Computer Science University of Colorado 20050531 L The Course http www plan cs colorado edudauielvdteachingSlSS SOS o CSCI 3155 Principles of Programming Languages 0 MTWR1100am 0245pm ECCR 105 How to contact me 0 Daniel von Dincklage danielvdcsci3155coloradoedu L The Course 7 7 Important Dates 0 June 15th Midterm 0 July lst Final Exam Office hours 0 the hour before class Textbook 0 Concepts of Programming Languages 6th ed Robert W Sebesta ISBN 0 321 19362 8 L other ts 7 i 7 Grading and Homework 30 Participation 30 Exams 40 Homeworks are due before start of the class on the due date no late homework will be accepted Collaboration Why st dy proamig Ianuges7 o requirement 0 Increased capacity to express ideas 0 Improved background for choosing languages 0 Increased ability to learn new languages 0 Better understanding of implementations and so better debugging skill 0 Increase ability to design new languages 0 Overall advancements of Computing 0 others Applications of progmnlguages Scientific applications Business Applications Artificial Intelligence Systems Programming Scripting Web Programming Special Purpose communications compiler generation mathematics others L39 Eilr Examples of langgs Scientific applications Fortran Business Applications ABAP COBOL Artificial Intelligence Lisp Scheme Prolog Systems Programming C Scripting awk Shells perl Web Programming JavaScript PHP Special Purpose communications Erlang compiler Yacc 39 quot a others o Imperative c The order of statements defines the order of execution 0 Examples C C Pascal Lisp Fortran 0 Object Oriented 0 Methods and Data are encapsulated in Objects Examples Eiffel C Java Lisp 0 Functional c The order of statements defines the order of execution 0 Examples ML Lisp Haskell 0 Logic 0 Facts supplied by the user are processed according to rules 0 Examples Prolog Goedel What makes a langu go bad7 The key criterion is the effort required to produce and maintain a given program 0 Readability 0 Important for understanding what a given program does 0 Writability Important for writing a program 0 Reliability 0 Important for whether a program works as expected L Language features that influence the effort SimplicityOrthogonality Control structures Data types amp structures Syntax design Support for abstraction Expressivity Type checking Exception handling Restricted aliasing La 9 in Ii n Language implem ntation 0 Compilation 0 Interpretation 0 Virtual Machine


Buy Material

Are you sure you want to buy this material for

25 Karma

Buy Material

BOOM! Enjoy Your Free Notes!

We've added these Notes to your profile, click here to view them now.


You're already Subscribed!

Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'

Why people love StudySoup

Steve Martinelli UC Los Angeles

"There's no way I would have passed my Organic Chemistry class this semester without the notes and study guides I got from StudySoup."

Kyle Maynard Purdue

"When you're taking detailed notes and trying to help everyone else out in the class, it really helps you learn and understand the I made $280 on my first study guide!"

Bentley McCaw University of Florida

"I was shooting for a perfect 4.0 GPA this semester. Having StudySoup as a study aid was critical to helping me achieve my goal...and I nailed it!"


"Their 'Elite Notetakers' are making over $1,200/month in sales by creating high quality content that helps their classmates in a time of need."

Become an Elite Notetaker and start selling your notes online!

Refund Policy


All subscriptions to StudySoup are paid in full at the time of subscribing. To change your credit card information or to cancel your subscription, go to "Edit Settings". All credit card information will be available there. If you should decide to cancel your subscription, it will continue to be valid until the next payment period, as all payments for the current period were made in advance. For special circumstances, please email


StudySoup has more than 1 million course-specific study resources to help students study smarter. If you’re having trouble finding what you’re looking for, our customer support team can help you find what you need! Feel free to contact them here:

Recurring Subscriptions: If you have canceled your recurring subscription on the day of renewal and have not downloaded any documents, you may request a refund by submitting an email to

Satisfaction Guarantee: If you’re not satisfied with your subscription, you can contact us for further help. Contact must be made within 3 business days of your subscription purchase and your refund request will be subject for review.

Please Note: Refunds can never be provided more than 30 days after the initial purchase date regardless of your activity on the site.