04-Language-Impl - CS 421 Lecture 4: Overview of language...

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

View Full Document Right Arrow Icon
CS 421 Lecture 4: Overview of language implementation s Lecture outline s Static vs. dynamic languages s Program execution and run-time systems s Compiler structure s Some history 6/8/2009 1
Background image of page 1

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

View Full DocumentRight Arrow Icon
6/8/2009 2 Change of pace s No more OCaml! (* for now… *) s Different ways to design and implement programming languages s Brief history of PLs
Background image of page 2
Language implementation overview s Language types s Static, vs. s Dynamic s Implementation approaches s Compile to machine code, vs. s Compile to virtual machine code, vs. s Directly execute (“interpret”) s Run-time support s “Raw” machine, vs. s Extensive run-time support ( e.g. , garbage collection) 6/8/2009 3
Background image of page 3

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

View Full DocumentRight Arrow Icon
Language types s Static, a.k.a. “compiled,” a.k.a. “conventional” s Examples: C, C++, Fortran s Static type-checking s “Manual” memory management s Run-time values not “tagged” – i.e. , cannot determine type of value at run time s Dynamic, a.k.a. “interpreted” s Examples: Java, OCaml, Python, Lisp s Often lack static type-checking (Python, Lisp), but sometimes have it (Java, OCaml) s Automatic memory management, a.k.a. garbage collection s Run-time values are “tagged” – , can determine properties of values at run time 6/8/2009 4
Background image of page 4
Type checking – static vs. dynamic s When is type-checking done? s Statically, i.e. , at compile time s Dynamically, , at run time. (Values must be tagged in some way.) s How strong? s Strong: no type errors possible, e.g. , if program has expression x.a ”, then x is definitely an object of a class that has a field named a . s Weak: programmer may bypass type system s These are properties of the language, , specified in the language’s definition. 6/8/2009 5
Background image of page 5

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

View Full DocumentRight Arrow Icon
s Java: int f (int x) { return x+1; } … f(new C()) … s Ocaml: let f x = x+1;; … f true … s C or C++: int f (int x) { return x+1; } … f((int)new C()) … s Python: Def f (x): return x+1 … f([]) … s Note: Not all errors are type errors – e.g. , hd [], or 5/0. Call those value errors . In Java and Ocaml, no type errors can occur at run time; in Python, both value and type errors can occur; in C or C++, type errors cannot normally occur, but you can cause them by injudicious casting. 6/8/2009
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 07/01/2009 for the course CS CS421 taught by Professor Kirillmechitov during the Summer '09 term at University of Illinois, Urbana Champaign.

Page1 / 29

04-Language-Impl - CS 421 Lecture 4: Overview of language...

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

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