16-typesBindings

16-typesBindings - Topics Covered Thus Far CMSC 330:...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
1 CMSC 330: Organization of Programming Languages Type Systems, CMSC 330 2 Topics Covered Thus Far Programming languages • Ruby • OCaml Syntax specification • Regular expressions • Context free grammars Implementation • Finite automata (scanners) • Recursive descent parsers CMSC 330 3 Language Features Covered Thus Far Ruby • Implicit declarations { x = 1 } • Dynamic typing { x = 1 ; x = “foo” } OCaml • Functional programming add 1 (add 2 3) • Type inference let x = x+1 ( x : int ) • Higher-order functions let rec x = fun y -> x y • Static (lexical) scoping let x = let x = … • Parametric polymorphism let x y = y ( ‘a -> ‘a ) • Modules module foo struct … end CMSC 330 4 Programming Languages Revisited Characteristics • Artificial language for precisely describing algorithms • Used to control behavior of machine / computer Syntax • Combination of meaningful text symbols Semantics • Meaning associated with syntactic construct Examples: x = 1 vs. x == 1 CMSC 330 5 Comparing Programming Languages Syntax • Differences usually superficial C / Java if (x == 1) { … } else { … } Ruby if x == 1 … else … end OCaml if (x = 1) then … else … • Can cope with differences easily with experience Though may be annoying initially • You should be able to learn new syntax quickly Just keep language manual / examples handy CMSC 330 6 Comparing Prog. Languages (cont.) Semantics • Differences may be major / minor / subtle • Explaining these differences a major goal for 330 • Will be covering different features in upcoming lectures a = b a == b OCaml a == b a.equal?(b) Ruby *a == *b a == b C a.equals(b) a == b Java Structural Equality Physical Equality
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 CMSC 330 7 Programming Language Features Paradigm • Functional • Imperative • Object oriented • Multi-paradigm Higher-order functions • Closures Declarations • Explicit • Implicit Type system • Typed vs. untyped • Static vs. dynamic • Weak vs. strong (type safe) CMSC 330 8 Programming Language Features (cont.) • Namespaces • Static (lexical) scopes • Dynamic scopes Parameter passing • Call by value • Call by reference • Call by name Eager vs. lazy evaluation Polymorphism • Ad-hoc Subtype Overloading • Parametric Generics Parallelism • Multithreading • Message passing CMSC 330 9 Explicit vs. Implicit Declarations Explicit declarations • Variables must be declared before used • Examples C, C++, Java, OCaml Implicit declarations • Variables do not need to be declared • Examples Ruby CMSC 330 10 Type System Overview Typed vs. untyped Static vs. dynamic Type safety • Weak (not type safe) vs. strong (type safe) CMSC 330 11 Type vs. Untyped Languages Typed language • Operations are only valid for specified types 2 * 3 = 6 “foo” * “bar” = undefined
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/13/2012 for the course CMSC 330 taught by Professor Staff during the Fall '08 term at Maryland.

Page1 / 7

16-typesBindings - Topics Covered Thus Far CMSC 330:...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online