2013-01-09 - Introduction to Programming Languages (CS4400/CS5400) ======================================================================== >>> Introduction to Programming Languages (CS4400/CS5400) * General plan for how the course will go. * Administrative stuff. (Most of the stuff from the web page.) >>> http://pl.barzilay.org/ <<< * Why should we care about programming languages? (Any examples of big projects *without* a little language?) ======================================================================== [[[ PLAI Chapter 1 ]]] * What defines a language? - syntax - semantics - libraries - idioms * How important is each of these? - libraries give you the run-time support, not an important part of the language itself. (BTW, the line between "a library" and "part of the language" is less obvious than it seems.) - idioms originate from both language design and culture. They are often misleading. For example, JavaScript programmers will often write: if (isExplorer) document.onmousemove = explorer_move; else document.onmousemove = mozilla_move; or if (isExplorer) document.onmousemove = function () { ... }; else document.onmousemove = function () { ... }; or document.onmousemove = isExplorer ? function () { ... } : function () { ... }; How many JavaScript programmers will know what this does: function foo(n) { return function(m) { return m+n; }; } - Compare: a[25]+5 (Java: exception) (+ (vector-ref a 25) 5) (Racket: exception) a[25]+5 (JavaScript: NaN or undefined) a[25]+5 (Python: exception) $a[25]+5 (Perl: 5) a[25]+5 (C: <<>>) a[25]+5 (ML: not an array ref at all) -> syntax is mostly in the cosmetics department. -> semantics is the real thing. * How should we talk about semantics? - A few well-known formalisms for semantics. - We will use programs to explain semantics: the best explanation *is* a program. - Ignore possible philosophical issues with circularity (but be aware of them). (Actually, they are solved: Scheme has a formal explanation that can be taken as a translation from Scheme to logic, which means that things that we write can be translated to logic.) - We will use Racket for many reasons (syntax, functional, practical, simple, formal, statically typed, environment). ========================================================================