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

Info icon This 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 square4 Lecture outline square4 Static vs. dynamic languages square4 Program execution and run-time systems square4 Compiler structure square4 Some history 6/8/2009 1
Image of page 1

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

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

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

View Full Document Right Arrow Icon
Language types square4 Static, a.k.a. “compiled,” a.k.a. “conventional” square4 Examples: C, C++, Fortran square4 Static type-checking square4 “Manual” memory management square4 Run-time values not “tagged” – i.e. , cannot determine type of value at run time square4 Dynamic, a.k.a. “interpreted” square4 Examples: Java, OCaml, Python, Lisp square4 Often lack static type-checking (Python, Lisp), but sometimes have it (Java, OCaml) square4 Automatic memory management, a.k.a. garbage collection square4 Run-time values are “tagged” – i.e. , can determine properties of values at run time 6/8/2009 4
Image of page 4
Type checking – static vs. dynamic square4 When is type-checking done? square4 Statically, i.e. , at compile time square4 Dynamically, i.e. , at run time. (Values must be tagged in some way.) square4 How strong? square4 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 . square4 Weak: programmer may bypass type system square4 These are properties of the language, i.e. , specified in the language’s definition. 6/8/2009 5
Image of page 5

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

View Full Document Right Arrow Icon
Type checking (cont.) square4 Java: int f (int x) { return x+1; } … f(new C()) … square4 Ocaml: let f x = x+1;; … f true … square4 C or C++: int f (int x) { return x+1; } … f((int)new C()) … square4 Python: Def f (x): return x+1 … f([]) … square4 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.
Image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern