0% found this document useful (0 votes)
13 views28 pages

(IT ) Week7 Programming Language

Uploaded by

sec552345
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views28 pages

(IT ) Week7 Programming Language

Uploaded by

sec552345
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 28

IT 개론 07

Programming
Language
손 우형
[email protected]
Where we are
• Part 1. Hardware • Part 3. Communications
• Computer 구조 • Internet
• Bit, Byte • WWW
• CPU • Security & Privacy

• Part 4. Other Issues


• Part 2. Software
• AI
• Algorithm
• Software Engineering & Agile
• OS
• Digital Transformation
• Programming Language
• Application & Cloud
Algorithm and Program
Algorithm
- abstract or idealized process descriptions that ignore details and practicalities.
- precise and unambiguous recipe
- a blueprint

Program
- a concrete statement of every step that a real computer must perform to accomplish a task
- a building

A program has to worry about practical problems like insufficient memory, limited
processor speed, invalid or even malicious input data, faulty hardware, broken network
connections, and human frailty.

GIGO(Garbage In Garbage Out)


Evolution of programming languages
1940’s: Machine level
- Use binary or equivalent notations for actual numeric values

1950's: "Assembly language“


- Names for instructions: ADD instead of 0110101, etc.
- Names for locations: assembler keeps track of where things are in memory; translates this more
humane language into machine language
- This is the level used in the "toy" machine
- Needs total rewrite if moved to a different kind of CPU
Evolution of programming languages,
1960's
"High level" languages: Fortran, Cobol, Basic
- Write in a more natural notation, e.g., mathematical formulas
- A program (called "compiler") converts into assembly language programs
- Potential disadvantage: lower efficiency in use of machine
- Enormous advantages:
Accessible to much wider population of users
Same program can be translated for different machines (portable)
More efficient in programmer time

Fortran
- “Formula Translation” developed by IBM
- Alive and well today
Cobol
- “Common Business Oriented Language” aimed for business data processing
Basic
- “Beginner’s All-purpose Symbolic Instruction Code” available on the first Personal Computer
How Compiler works
Evolution of programming languages,
1970's
"System programming" languages: C
- Efficient and expressive enough to take on any programming task
- Writing assemblers, compilers, operating systems such as UNIX
- C compiler converts into assembly language programs
- Enormous advantages:
Accessible to much wider population of programmers
Same program can be translated for different machines (portable)
Faster, cheaper hardware helps make this happen
Evolution of programming languages,
1980's
"Object-oriented" languages: C++
- Better control of structure of really large programs
- Better internal checks, organization, safety
- C++ compiler converts into assembly language or C programs
- Enormous advantages
Same program can be translated for different machines (portable)
Faster, cheaper hardware helps make this happen

Most of the major programs are written in C and C++


- Unix and Linux Operating System
- Word, Firefox and Crome
Evolution of programming languages,
1990's
"Scripting", Web, component-based, ...:
- Java, Perl, Python, Ruby, Visual Basic, JavaScript, ...
- programming speed and convenience became more important than machine efficiency
- Write big programs by combining components already written
- Often based on "virtual machine": simulated, like fancier toy computer
- Enormous advantages:
Same program can be translated for different machines (portable)
Faster, cheaper hardware helps make this happen
Programming languages in the 21st century?
New general-purpose languages
- Go, Rust, Swift, Scala, ...

Ongoing refinements / evolution of existing languages


- C, C++, Fortran, Cobol all have new standards in last few years

Specialized languages for specific application areas


- e.g., R for statistics

Old languages rarely die


- It costs too much to rewrite programs in a new language
Evolution of Programming languages
Compiler vs. Interpreter
Compiler vs. Interpreter
KEY DIFFERENCE
• Compiler transforms code written in a high-level programming language into the machine
code, at once, before program runs, whereas an Interpreter coverts each high-level
program statement, one by one, into the machine code, during program run.
• Compiled code runs faster while interpreted code runs slower.
• Compiler displays all errors after compilation, on the other hand, the Interpreter
displays errors of each line one by one.
• Compiler is based on translation linking-loading model, whereas Interpreter is based on
Interpretation Method.
• Compiler takes an entire program whereas the Interpreter takes a single line of code.
Classification of programming languages
(1) 절차적 언어(Procedural Programming Language)
또는 명령형 언어(Imperative Language), 기본적으로 알고리즘을 표현하기 위한 명령어들의 집합
구조적 프로그래밍 개념
COBOL, FORTRAN, ALGOL, BASIC, PASCAL, C, Ada 등

(2) 객체지향 언어(Object-Oriented Programming Language)


객체(Object)라는 엔티티에 데이터와 메소드(Method)가 포함
객체 내의 데이터를 접근하기 위하여 필히 객체의 메소드를 통해 가능

(3) 선언적 언어(Declarative Programming Language)


절차적 언어는 “문제를 어떻게 풀지(“How to solve the problem”) 를 기술
선언적 언어는 “문제가 무엇인지(“What the problem is)” 를 정의
시뮬레이션 언어 GPSS, 논리적 언어 Prolog, 데이터베이스 질의어 SQL 등

(4) 함수형 언어(Functional Programming Language)


블록 단위의 프로그램이 마치 수학의 함수와 같이 작용
인공지능 언어 LISP, Scheme 등
programming language ranking

https://www.y
outube.com/w
atch?v=YqxeLo
dyyqA
Why so many programming languages?

each language represents a set of tradeoffs among concerns like efficiency,


expressiveness, safety, and complexity
- Reaction to perceived failings of others; personal taste

Notation is important
- "Language shapes the way we think and determines what we can think about." (Benjamin Whorf)
- The more natural and close to the problem domain, the easier it is to get the machine to do what
you want

Higher-level languages hide differences between machines and between operating systems.
We can define idealized "machines" or capabilities and have a program simulate them --
"virtual machines".
Programming Language Components
Syntax: Grammar rules for defining legal statements
- What's grammatically legal? how are things built up from smaller things?
Semantics: What things mean
- What do they compute?

Statements: Instructions that say what to do


- Compute values, make decisions, repeat sequences of operations
Variables: Places to hold data in memory while program is running
- Numbers, text, ...

Most languages are higher-level and more expressive than the


assembly language for the Toy machine
- Statements are much richer, more varied, more expressive
- Variables are much richer, more varied
- Grammar rules are more complicated
- Semantics are more complicated
but it's basically the same idea
The Process of Programming
Figure out what to do
- Start with a broad specification
- Break into smaller pieces that will work together
- Spell out precise computational steps in a programming language

Build on a foundation (rarely start from scratch)


- A programming language that's suitable for expressing the steps
- Components that others have written for you:
Functions from libraries, major components, ...
- Which in turn rest on others, often for several layers
- Runs on software (the operating system) that manages the machine

It rarely works the first time


- Test to be sure it works, debug if it doesn't
- Evolve as get a better idea of what to do, or as requirements change
Real-world Programming
The same thing, but on a grand scale
- Programs may be millions of lines of code.
Typical productivity: 1-10K lines/year/programmer
- Thousands of people working on them
- Lifetimes measured in years or even decades
Big programs need:
- Teams, management, coordination, meetings, …
Schedules and Deadlines
Constraints and Criteria
- How fast the program must run, how much memory it can use
- Reliability, safety, security, interoperability with other systems, …

Maintenance of old ("legacy") programs is hard


- Programs must evolve to meet changing environments and requirements
- Machines and tools and languages become obsolete
- Expertise disappears
Real programs
(Warning: Some of these numbers are flaky)
Unix 6th Edition: 9,000 lines
Linux: 14.8 M lines, 33,000 source files in C (v 3.6.5, 11/12)
- Includes many device drivers, etc., not all needed, not all simultaneous

First C compiler: about 2,700 lines


GCC C/C++/… compiler: 4.9 M lines, 43,500 files (v 4.7.2, 11/12)
Firefox: 2.4 M lines, 11,000 files C++ (v 3.6.23, 11/11)
Windows 98: 18 M lines (but what's included?)
Windows XP: 38 M lines
Windows Vista: 100 M lines?
Windows 7+: ???
What’s Hard about Big Programs?
Lots of components with hidden or implicit connections
- A change in one place has unexpected effects elsewhere:
Software as spaghetti
- Most errors occur at interfaces between components
- Language features, software design, etc., devoted to reducing and controlling interconnections

Changes in requirements or environment or underpinnings


- Each change requires rethinking, adapting, changing -- a fresh chance to get something wrong

Constraints on performance, memory, schedule, …


- Force people to create more complicated code or cut corners

Coordination and cooperation among groups of people


- Management complexity grows rapidly with size of organization
- Brooks's Law: Adding manpower to a late software project makes it later
Libraries and API
Programming is similar with building the house.
- Use prefabricated pieces : doors, windows ….

Library is collection of functions


While (scanf(“%d”, &num) != EOF && num != 0)
sum = sum + num;
printf(“%d\n”, sum)

API(Application Programming Interface)


- lists the functions, what they do, how to use them in a program, what input data they require, and
what values they produce
Why Software instead of Hardware?
General-purpose software instead of special-purpose hardware:
Software is
- More flexible
- Easier to change in the field
- Cheaper to manufacture (though often costly to create originally)
Hardware is
- Faster, more efficient
- More reliable, more robust
- More secure against intrusion, theft, reverse engineering

Dividing line is not always clear


- Flash memory, etc.
- Plug-in cards, game cartridges
Wrap-up: Key Software Ideas
Algorithm: Sequence of precise, unambiguous steps
- Performs some task and terminates
- Based-on defined basic / primitive operations
- Describes a computation independent of implementation details
Programming language:
- Grammar, syntax, and semantics for expressing computation
- notation is important: there are many, many languages
Program: Algorithms implemented in a programming language
Compilers, interpreters: Programs that convert from the high-level
language used by people to a lower level
- A compiler is a program that writes a program
- An interpreter also acts as a computer so the program can be run
Libraries and components: Programs written by others
- Packaged in a form that can be used in a new program
Programming Tool Example: Visual Studio Code
Programming Tool Example: Eclipse
Programming Tool Example: Jupyter
The End of Lecture

You might also like