cs2403 programming languages course outline chung-ta king department of computer science national...
TRANSCRIPT
CS2403 Programming Languages
Course Outline
Chung-Ta KingDepartment of Computer ScienceNational Tsing Hua University(Slides are adopted from Concepts of Programming Languages, R.W. Sebesta; Modern Programming Languages: A Practical Introduction, A.B. Webber)
2
On Valentine’s Day
You want to impress your girl friend by baking a chocolate cake specifically for her.
4
巧克力蛋糕食譜 材料:
1/2 杯牛油 約 120 克黑巧克力 兩個雞蛋 兩個蛋黃 1/4 杯砂糖 2 茶匙中筋麵粉
步驟: 預熱烤箱到 230 度。 將巧克力和牛油隔水融化。 攪拌雞蛋、蛋黃和糖至到顏色變淺。 混合巧克力和牛油,倒入蛋液中,加入麵粉,攪拌至完全融合。 把攪拌物倒入模具,放入烤箱烤 6~7 分鐘。 把模具翻轉到盤中,靜置 15 秒後脫模。可配上鮮奶油。
5
Chocolate Cake Receipt Materials:
1/2 cup butter 4 ounce bittersweet chocolate 2 eggs 2 egg yolks 1/4 cup white sugar 2 teaspoons all purpose flour
Step: Preheat oven to 450°F. Heat butter and chocolate until chocolate is almost
melted. Beat eggs, yolks and sugar until light colored and thick. Mix chocolate and butter, and slowly pour into egg
mixture, stirring constantly. Stir in flour until just combined.
Pour batter into molds and bake for 6 to 7 minutes. Invert molds on plates, let sit 15 seconds, and unmold. Serve with whipped cream.
6
A Receipt Is Like a Program
Receipt: 阿基師 tells you how to
make a chocolate cake Has inputs (butter,
eggs, chocolate, flour, sugar) & output (chocolate cake)
Define a procedure Instruct how
processors (oven, mixer) process inputs to generate output
Can be expressed in different languages
Program: You tell a computer
how to do a computation
Has inputs and outputs
Define a procedure (algorithm)
Instruct how processors process inputs to generate outputs
Can be expressed in different languages
7
Questions
Given two languages, how do they differ in expressing the same receipt/algorithm?
Which language is better? How to evaluate “goodness” of languages?
Why are there so many different languages? What is “programming language” anyway? Why does a programming language have so
many different features? How are these features implemented? … Topics of
this course
8
A Programming Language Is …
An artificial language designed to express computations or algorithms that can be performed by a computer -- WikipediaA language is a means of expressing your
thoughts to othersIn the case of PL, it is a means of expressing
your thoughts (algorithms) to a computerNatural languages such as Chinese and English
are not used because they cannot be easily translated into machine language executable by the computer
Keywords: expressiveness, implementation
9
Why PL Important?
A language is a framework for problem-solvingIt may facilitate or hinder your thoughts and,
thus, the abilities to solve problemsIt may help you make fewer mistakes
Example: tense and gender, e.g.“He was doing great!” in English
Example: a C language that supports only static and global variables no malloc()How to implement hash table? linked list?
(Ref.: John Mitchell, http://www.stanford.edu/class/cs242)
How to choose
PL?
12
Important to Know PL by Trend
Increasing use of type-safe languages: Java, C#, …
Scripting languages for web applications with increasing client-side functionality
More on expressing algorithms than syntax
Runtime environment and virtualization with continuous compilation, analysis, and checking
More program analysis abilities: automated error detection and recovery
(Ref.: John Mitchell, http://www.stanford.edu/class/cs242)
13
Important to Know PL by Tradeoffs
Factors influencing programming language Expressiveness:
Application domainsProgramming methods: multiprogramming,
interactive systems,… Implementation: efficiency
Computer architecture, OS, toolchain, libraryEvery convenience has its cost; must
recognize cost of presenting an abstract view of machineUnderstand trade-offs in programming language
design(Ref.: M. Sirjani, http://ut.ac.ir/classpages/ProgrammingLanguages)
14
PL as a Course
What is notDo not teach you a programming languageDo not teach you how to program
What isIntroduce fundamental concepts of
programming languagesDiscuss design issues of various language
constructsExamine design/implementation choices for
these constructsCompare design alternatives
Need to be familiar in at least one PL
15
Why Study PL?
To improve your ability to develop effective algorithms and to use your languageO-O features, recursionCall by value, call by reference
To allow a better choice of PL Increased ability to learn new languages To make it easier to design a new language To understand significance of
implementationE.g. the efficiency of a recursive function
16
Course Information
教授 : 金仲達辦公室 : 資電館 443 分機 : 42804email: [email protected]
助教 :陳志中、劉正芝
上課時間 :週一 13:10–15:00週四 13:10–14:00
上課地點 : CSEE131 http://www.cs.nthu.edu.tw/~king/courses/
cs2403.html
17
Textbook
Concepts of Programming Languages, Robert W. Sebesta, 9th Edition, Addison Wesley, 2009Describing Syntax and SemanticsNames, Bindings, and ScopesData TypesExpressions and AssignmentControl StructuresSubprogramsAbstract Data Types, EncapsulationConcurrencyException Handling and Event HandlingFunctional and Logic Programming Languages
18
Expected Workload
Assignments:Expect one assignment every two weeks,
including programming assignments
Grade breakdownAssignments 50%Examinations 45%Class participation 5%