360 likes | 381 Views
CSE-321 Programming Languages Overview. 박성우. POSTECH March 6, 2006. Welcome!. What this course is about: fundamental theory behind programming languages and all other exciting topics What this course is not about: history of programming languages
E N D
CSE-321 Programming LanguagesOverview 박성우 POSTECH March 6, 2006
Welcome! • What this course is about: • fundamental theory behind programming languages • and all other exciting topics • What this course is not about: • history of programming languages • comparison of different programming paradigms • and all other boring topics (that you can study by yourself)
PLs you have ever used? • BASIC • Pascal • Assembly languages • C • C++ • Java • C# • Prolog • Lisp • Perl • Python • ... • any other?
BASIC • 1984 • Disappointing ;-( • It does not compile to machine code. • It is slow. • “So I cannot make a computer game!” • Had to learn anyway: • to run computer games stored in cassette tapes
C • 1991 • Exciting ;-) • It compiles to machine code. • “So maybe I can make a computer game!” • “Return of the Jedi” (1983) and DOOM (1993)
I did not realize how inefficient my structural programming was until ...
C++ • 1993 • Cool! • object-orientation (whatever that means) • Even a novice programmer like me instantly appreciated the power of object-orientation. • Remark by the instructor: “C++ will become the most dominant programming language in a decade from now.” • Is it?
I did not realize how inefficient my object-oriented programming was until ...
Java • 1995 • Incredible! • Not only object-orientation but also garbage collection! • no more hassle of memory allocation and deallocation • Virtual Machine lets you run the code “everywhere.” • The syntax and semantics seemed flawless.
I did not realize how ugly,inelegant, and messymy Java programming was until ... (to be continued)
Outline • Introduction V • Why do we need to study programming language theory? • What do we study in programming language theory? • How do we study programming language theory? • Summary
Mars Climate Orbiter Failure • Mars Climate Orbiter launched in 1998 • Destroyed due to a navigation error • Cause? • One module used English units (feet). • The other module expected metric units (meter). • Lessons • Both modules were fine in isolation. • Programmers did not even know the existence of the bug until the spacecraft was destroyed. • Stupidity: • NASA scientists? No! • programming languages they used? Yes!
Communication map unit map unit centimeter/radian mapper navigator meter/degree meter/degree localizer sensor processor actuator Robot Programming • Dimension conversion
Robot Programming • Probabilistic computation
Programming Language CES • C++ for Embedded Systems • Story: • Robot programming in C++ is too painful. • It is quite prone to errors. • It is very hard to locate errors even if we know their existence. • E.g., no segmentation fault, but the robot takes a wrong path. • So why not design a new programming language? • Lesson • It is not programming language theorists who wanted to develop CES. • It is a robotics expert who wanted such a language (who won the DARPA Grand Challenge!)
Gears of War • Highly anticipated XBox 360 Killer title by Epic Games
Gears of War at POPL 2006 • POPL (Principles of Programming Languages) • the premier conference for programming language research • Tim Sweeney • CEO and founder of Epic Games • Epic Games? • Unreal Tournament series • Gears of War • Unreal Engine (used in Lineage II) • Tim Sweeney gave an invited talk entitled: “The next mainstream programming language: a game developer's perspective”
Gist of the Talk • Code: • gameplay code: ~250,000 lines C++ code • Unreal Engine 3: ~250,000 lines C++ code • “Will gladly sacrifice 10% of our performance for 10% higher productivity.” • Our code is littered with runtime failure cases, yet the compiler remains silent! • By 2009, game developers will face… • CPU’s with: • 20+ cores • 80+ hardware threads • >1 TFLOP of computing power • If we are to program these devices productively, you are our only hope!
VAULT at Microsoft • Microsoft believes: • 90% of Windows OS bugs originate from “device drivers.” • Device drivers account for 70% of Windows OS source code. • Microsoft cannot verify: • these 90% of Windows OS bugs indeed originate from “device drivers.” • So they are designing a new language called VAULT: • type system that enforces rules between device drivers and the OS kernel.
Outline • Introduction V • Why do we need to study programming language theory? V • What do we study in programming language theory? • How do we study programming language theory? • Summary
What to Study? • 1st topic: • type theory • 2nd topic: • operational semantics • 3rd topic: • logic • What the heck is type theory anyway?
Long Documentation • Long documentation is always better? /* Takes two arguments and returns their sum. * Both arguments must be integers. * If not, the result is unpredictable. * If their sum is too large, an overflow may occur. * ... */ fun add(x, y) { return x + y; } • The documentation cannot be formally verified by the compiler. • We have to trust whoever wrote it.
Short Documentation • Short documentation can be formally verified by the compiler. • Great! argnum 2 fun add(x, y) { return x + y; } • Utterly useless, however ;-(
Types • Good compromise between: • simplicity: types can be formally verified. • expressiveness: types are useful. int add(int x, int y) { return x + y; } • I will spend the whole semester to convince you that type theory is: • useful, • beautiful with a strong logical foundation, • and fun to learn.
Outline • Introduction V • Why do we need to study programming language theory? V • What do we study in programming language theory? V • How do we study programming language theory? • Summary
I did not realize how ugly,inelegant, and messymy Java programming was until ... (from an earlier slide)
ML • 1995 • Eye-opener! • functional language • strong type system • profound logical foundation • ML = “Meta-Language” • Lessons that I learned: • Programming is not about coding. • Programming is about design and specification.
Outline • Introduction V • Why do we need to study programming language theory? V • What do we study in programming language theory? V • How do we study programming language theory? V • Summary
Summary • Why do we need to study programming language theory? • Because there is an ever growing need for new programming languages! • What do we study in programming language theory? • Type theory and operational semantics! • How do we study programming language theory? • By learning a functional language ML and its foundation!
RoboCup 2050 Still in C++, Python? http://www.robocup.org
Homework by Wednesday • Visit the course webpage. • http://www.postech.ac.kr/~gla/cs321 • Install SML/NJ 110.57 on your machine. • Install the AFS client software on your machine. • make sure you have read/write permission on your submission directory. • Read Chapter 1 of the course notes. • Any comments will be greatly appreciated. • Start assignment 1!