1 programming language concepts ethics why study concepts of programming languages (pls)? pl...

20
1 Programming Language Concepts • Ethics Why study concepts of programming languages (PLs)? PL categories Influences on PL design Problem areas & needs that drive PL development Programming Environments Ref: Chapter 1 of Sebesta

Upload: lizbeth-kelley

Post on 25-Dec-2015

212 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 1 Programming Language Concepts Ethics Why study concepts of programming languages (PLs)? PL categories Influences on PL design Problem areas & needs that

1Programming Language Concepts• Ethics• Why study concepts of programming languages (PLs)?• PL categories• Influences on PL design• Problem areas & needs that drive PL development• Programming Environments

Ref: Chapter 1 of Sebesta

Page 2: 1 Programming Language Concepts Ethics Why study concepts of programming languages (PLs)? PL categories Influences on PL design Problem areas & needs that

2EthicsThe 10 Commandments for Computer Ethics1. Thou shalt not use a computer to harm other people.2. Thou shalt not interfere with other people's computer work.3. Thou shalt not snoop around in other people's files.4. Thou shalt not use a computer to steal.5. Thou shalt not use a computer to bear false witness.6. Thou shalt not use or copy software that you did not pay for.7. Thou shalt not use other people's resources without authorization.8. Thou shalt not appropriate other people's intellectual output.9. Thou shalt think about the social consequences of your programs.10. Thou shalt use a computer in considerate and respectful ways.

Computer Professionals for Social Responsibility: www.cspr.org

Page 3: 1 Programming Language Concepts Ethics Why study concepts of programming languages (PLs)? PL categories Influences on PL design Problem areas & needs that

3Why Different PLs?• To better express ideas• To choose the best PLs for a project• To learn a new PL faster• To understand effects of implementation on

the quality of your software• To choose the best programming environment• To understand and apply advances in

computing

Page 4: 1 Programming Language Concepts Ethics Why study concepts of programming languages (PLs)? PL categories Influences on PL design Problem areas & needs that

4Expressing Ideas• Learning new PL paradigms, new language

features, new data structures, new algorithms allows you to – create better programs – solve more difficult problems

• E.g.: after learning object-oriented programming in Java, you could simulate objects as structures and functions in plain C

• (and you will learn C++ more easily)

Page 5: 1 Programming Language Concepts Ethics Why study concepts of programming languages (PLs)? PL categories Influences on PL design Problem areas & needs that

5Choosing a PL• Programmers tend to stick with the first

language they learned

• E.g.: A programmer who learned C in the school may implement a binary tree with arrays in Java, instead of using linked objects

Page 6: 1 Programming Language Concepts Ethics Why study concepts of programming languages (PLs)? PL categories Influences on PL design Problem areas & needs that

6Learning New PLs• Knowing the basic concepts of one language

will enable you to learn a new PL faster– E.g.: If you understand object-oriented concepts

from Java, you will learn Ada more easily than if you never used these concepts

• Will you learn one language and use only that one for the rest of your career?

• How long will this PL be around?

Page 7: 1 Programming Language Concepts Ethics Why study concepts of programming languages (PLs)? PL categories Influences on PL design Problem areas & needs that

7The Half-Life of Information• In 1400, a person could learn – all what there was to know

• In 1900, a child could learn – all what she needed for the rest of her life

• Today, 50% of the facts you know –will be untrue or obsolete in 3-4 years!• Country boundaries, presidents• OS versions, PLs, IDEs …• • ?????

Page 8: 1 Programming Language Concepts Ethics Why study concepts of programming languages (PLs)? PL categories Influences on PL design Problem areas & needs that

8PL Implementation Effects• Knowledge of PLs enables you to– Construct more efficient software– Have fewer bugs in your program – Find and correct the bugs faster

• If you practice recursion in Lisp, you will write compact and concise code that will be as efficient as an iterative version in another PL

Page 9: 1 Programming Language Concepts Ethics Why study concepts of programming languages (PLs)? PL categories Influences on PL design Problem areas & needs that

9Advances in Computing• Knowing the pros and cons of different PLs will

help you as a manager choose the best PL for a project

• New PLs have new and better combinations of features

• E.g.: In the early 1960s, Fortran was used much more than ALGOL 60, even though ALGOL 60’s control statements were much better

Page 10: 1 Programming Language Concepts Ethics Why study concepts of programming languages (PLs)? PL categories Influences on PL design Problem areas & needs that

10Language Categories• Imperative– Central features: variables, assignments, iteration– c.g. C, Pascal, Fortran

• Object-oriented• Classes and objects (data and operations)• Data encapsulation• Inheritance • Polymorphism, dynamic type binding

– Grew out of imperative languages– e.g. Smalltalk, C++, Java, Common Lisp’s CLOS

Page 11: 1 Programming Language Concepts Ethics Why study concepts of programming languages (PLs)? PL categories Influences on PL design Problem areas & needs that

11Language Categories (cont.)• Functional– Computation: applying functions to parameters yields a

result– E.g. LISP, Scheme, ML, Haskel

• Logic– Rule-based– Order of rules not important– Proving a statement by inference (part of the language)– E.g. Prolog

• Scripting– regular expressions and pattern matching– E.g. Perl, JavaScript, Unix shells, Scheme

Page 12: 1 Programming Language Concepts Ethics Why study concepts of programming languages (PLs)? PL categories Influences on PL design Problem areas & needs that

12Influences on PL Design• Computer Hardware and Architecture– Credited to von Neumann (“von Noyman”),– Data & programs are stored in memory– CPU executes instructions– Instructions & data piped between memory & CPU

• Imperative languages designed around this– Variables model memory cells– Assignment statements model piping– Iterative form is most efficient

Page 13: 1 Programming Language Concepts Ethics Why study concepts of programming languages (PLs)? PL categories Influences on PL design Problem areas & needs that

13Von Neumann Bottleneck• Fetch-execute cycle

1. Fetch the instruction at program counter2. Increment program counter3. Decode the instruction4. Execute the instruction

• Speed: CPU > bus > RAM > …. > disk

• Instructions are executed much faster than they can be moved to the CPU for execution

Page 14: 1 Programming Language Concepts Ethics Why study concepts of programming languages (PLs)? PL categories Influences on PL design Problem areas & needs that

14Influences on PL Design (cont.)• Programming needs drive PL design– Early 1970s: Type checking & flow control• Higher-level languages• Procedure-oriented/imperative programming

– Late 1970s: Abstract data types – Early 1980s: Object-oriented programming– Late 1980s: First standardized OO language: • CLOS (Common Lisp Object System) • !

Page 15: 1 Programming Language Concepts Ethics Why study concepts of programming languages (PLs)? PL categories Influences on PL design Problem areas & needs that

151st Application: Scientific = Fortran• First computers used for scientific applications– 1940s

• Needed mostly arrays, matrices, counting loops, and selections

• Most efficient PL: Fortran– (Formula Translation) – 1950s

Page 16: 1 Programming Language Concepts Ethics Why study concepts of programming languages (PLs)? PL categories Influences on PL design Problem areas & needs that

16Business Applications = COBOL• Computers used for business starting in 1950s• 1st PL for this was COBOL– (COmmon Business-Oriented Language)– New features• Store character data• Create reports, text output• Store decimal numbers directly• Perform calculations using decimal numbers (without

translating to binary)

• Nowadays, spreadsheets and databases are available as applications on PC

Page 17: 1 Programming Language Concepts Ethics Why study concepts of programming languages (PLs)? PL categories Influences on PL design Problem areas & needs that

17Artificial Intelligence = Lisp, Prolog• Computations on symbolic data rather than

numeric computations

• Lists are a built-in data structure

• 1959: Functional PL LISP– developed for AI

• 1970: logic PL Prolog

Page 18: 1 Programming Language Concepts Ethics Why study concepts of programming languages (PLs)? PL categories Influences on PL design Problem areas & needs that

18Systems PL = Assembly, ALGOL, C• Systems software – = Operating System + supporting tools– Must be efficient – Must interface with external drivers

• 1960s & 1970s: PL/S, BLISS, Extended ALGOL were first used for this

• Currently, UNIX is written mostly in C

Page 19: 1 Programming Language Concepts Ethics Why study concepts of programming languages (PLs)? PL categories Influences on PL design Problem areas & needs that

19Scripting PLs = Perl, JavaScript, PHP• Early scripting:– a list of commands in a file (a script) to be executed – e.g. csh on unix, batch file on DOS

• -> Scripting languages:– variables, control flow statements, functions, etc.

• Perl: popular scripting language– e.g. for Common Gateway Interface (CGI) programming for

the World Wide Web

• JavaScript & PHP– embedded in HTML web pages

Page 20: 1 Programming Language Concepts Ethics Why study concepts of programming languages (PLs)? PL categories Influences on PL design Problem areas & needs that

20Development Environments• IDE Integrated Development Environment

– Set of tools used in software development

• UNIX– An older operating system with tool collection– Nowadays often used through a GUI (e.g., CDE, KDE, or GNOME) that

runs on top of UNIX

• Borland JBuilder– IDE for Java

• Microsoft Visual Studio.NET– A large, complex visual environment– Supports C#, Visual BASIC.NET, Jscript, J#, and C++

• Eclipse– Open Source IDE primarily for Java