background image

1

Języki Programowania

Podstawowe pojęcia

R. Pełka:  Języki Programowania, 2008

2

Plan wykładu

ƒ

Właściwości języków programowania

ƒ

Czytelność kodu

ƒ

Łatwość programowania

ƒ

Niezawodność

ƒ

Ewolucja języków programowania

ƒ

Język maszynowy

ƒ

Języki proceduralne

ƒ

Języki zorientowane obiektowo

ƒ

Rodzina języków programowania

ƒ

Popularność języków, trendy, zastosowania

background image

2

R. Pełka:  Języki Programowania, 2008

3

Języki …

Jezyk maszynowy

...01100100111011...

Jezyk maszynowy

...01100100111011...

Jezyk naturalny

...niech mi Pan nie przerywa, Panie...

Jezyk naturalny

...niech mi Pan nie przerywa, Panie...

Jezyk niskiego poziomu

Jezyk niskiego poziomu

Jezyk wysokiego poziomu

Jezyk wysokiego poziomu

Jezyk niskiego poziomu

Jezyk niskiego poziomu

Jezyk wysokiego poziomu

Jezyk wysokiego poziomu

R. Pełka:  Języki Programowania, 2008

4

Programowanie komputera

Sprzet

Jezyk maszynowy

Assembler

Jezyk wysokiego poziomu

Fortran

C, C++

Pascal

Kompilacja

Egzekwowanie
programu

Narzedzia programistyczne

background image

3

R. Pełka:  Języki Programowania, 2008

5

Dlaczego istnieje tyle PLs?

ƒ

Teoretycznie, wszystkie języki programo-
wania są sobie równoważne

ƒ

Kompilowane/interpretowane na język                              
wewnętrzny procesora (asembler)

ƒ

Dlaczego istnieje tyle języków naturalnych (NLs)?

ƒ

W praktyce, języki naturalne spełniają rozmaite zapotrzebowania 
określone przez

ƒ

Różne kultury (różne obszary zastosowań)

ƒ

Różne środowiska zawodowe

ƒ

Różne sposoby postrzegania świata

R. Pełka:  Języki Programowania, 2008

6

Evolution of LPs

011111110100010101001100010001100000000100000010000000010000000000000000000000

000000000000000000000000000000000000000000000000000000000000000001000000000000

001000000000000000000000000000000001000000000000000000000000000000000000000000

000000000000000000000000000000000000000000001010000100000000000000000000000000

000000000000000000110100000000000000000000000000000000000000000000101000000000

000000100000000000000000010000000000101110011100110110100001110011011101000111

001001110100011000010110001000000000001011100111010001100101011110000111010000

000000001011100111001001101111011001000110000101110100011000010000000000101110

011100110111100101101101011101000110000101100010000000000010111001110011011101

000111001001110100011000010110001000000000001011100111001001100101011011000110

000100101110011101000110010101111000011101000000000000101110011000110110111101

101101011011010110010101101110011101000000000000000000000000000000000010011101

111000111011111110010000000100110000000000000000000000001001000000010010011000

000000000000010101000000000000000000000000100100100001001010100000000000000100

000000000000000000000000000000000001000000000000000000000000101000000001000000

000000000010001001000000010000000000000001000000010101000000000000000000000000

100100100001001010100000000000000100000000000000000000000000000000000001000000

000000000000000000101100000001000000000000000100001000000000000000000000100000

000100000000000000000000000010000001110001111110000000001000100000011110100000

000000000000000000000000000000000000000000000001001000011001010110110001101100

011011110111011101101111011100100110110001100100001000010000000000000000000000

000000000000000000000000000000000000000001000000000000000000000000000000000000

000000000000000000000000000000000100000000001111111111110001000000000000000000

000000000000010000000000000000000000000000000000000000000000000000000000000000

000001000000000011111111111100010000000000000000000000000000000000000000000000

000000000000000000000000000000000000000000000000000000001100000000000000000000

001100000000000000000000000000000000000000000000000000000000000000000000000000

000000000000000000000000000000000000000000010000000000000000000000000000000000

000000000000000000000000000000000000000000000000000000000000000000000110000000

000000000000000100000000000000000000000000001101000000000000000000000000000000

000000000000000000000000000000000000001000000000000000000000000000000000000000

000000000000000100010000000000000000000000000000000000000000000000000000000000

000000000010000000000000000000000000000000000000000000000000000010001100000000

000000000000000000000000000000000000000000000000000000000000100000000000000000

000000000000000000000000000000000000101100000000000000000000000000000000000000

000000000000000000000000000000001000000000000000000000000000000000000000000000

000000001101001000000000000000000000000000000000000000000000000000000000100100

000010010000000000000000000000010000000000000000000000000011011100000000000000

000000000000000000000000000000000000000000000000000000100000000000000000000000

000000000000001101000011001010110110001101100011011110010111001100011011100000

first computers

(e.g., ENIAC) were not

programmable

ƒ

had to be 

rewired/reconfigured 

for different 

computations

late 40’s / early 50’s: 

coded directly in machine 

language

ƒ

extremely tedious 

and error prone

ƒ

machine specific

ƒ

used numeric codes, 

absolute

background image

4

R. Pełka:  Języki Programowania, 2008

7

Evolution of LPs

(cont.)

.file   "hello.cpp"

gcc2_compiled.:

.global _Q_qtod

.section ".rodata"

.align 8

.LLC0:  .asciz

"Hello world!"

.section ".text"

.align 4

.global main

.type   main,#function

.proc   04

main:   !#PROLOGUE# 0

save %sp,-112,%sp

!#PROLOGUE# 1

sethi %hi(cout),%o1

or %o1,%lo(cout),%o0

sethi %hi(.LLC0),%o2

or %o2,%lo(.LLC0),%o1

call __ls__7ostreamPCc,0

nop

mov %o0,%l0

mov %l0,%o0

sethi %hi(endl__FR7ostream),%o2

or %o2,%lo(endl__FR7ostream),%o1

call __ls__7ostreamPFR7ostream_R7ostream,0

nop

mid 1950’s: assembly languages 
developed

ƒ

mnemonic names replaced 
numeric codes

ƒ

relative addressing via names 
and labels

a separate program (assembler)
translated from assembly code to 
machine code

• still machine specific, low-level

R. Pełka:  Języki Programowania, 2008

8

Evolution of programming

(cont.)

late 1950’s: high-level languages developed

ƒ

allowed user to program at higher level 
of abstraction

however, bridging the gap to low-level 
hardware was more difficult

• a 

compiler

translates code all at once 

into machine code (e.g., FORTRAN, 
C++)

• an 

interpreter

simulates execution of the 

code line-by-line (e.g., BASIC, Scheme)

Java utilizes a hybrid scheme

• source code is compiled into byte code
• the byte code is then interpreted by the 

Java Virtual Machine (JVM) that is built 
into the JDK or a Web browser

// File: hello.cpp

// Author: Dave Reed

//

// This program prints "Hello world!"

////////////////////////////////////////

#include <iostream>

using namespace std;

int main()

{

cout << "Hello world!" << endl;

return 0;

}

background image

5

R. Pełka:  Języki Programowania, 2008

9

FORTRAN (Formula Translator)

FORTRAN 

was the first high-level 

language

ƒ

developed by 

John Backus

at IBM

ƒ

designed for the IBM 704 computer, 
all control structures corresponded 
to 704 machine instructions

ƒ

704 compiler completed in 1957

ƒ

despite some early problems, 
FORTRAN was immensely popular –
adopted universally in 50's & 60's

ƒ

FORTRAN evolved based on 
experience and new programming 
features

• FORTRAN II (1958)
• FORTRAN IV (1962)
• FORTRAN 77 (1977)
• FORTRAN 90 (1990)

C

C  FORTRAN program

C  Prints "Hello world" 10 times

C

PROGRAM HELLO 

DO 10, I=1,10 

PRINT *,'Hello world' 

10 CONTINUE 

STOP 

END 

John Backus

R. Pełka:  Języki Programowania, 2008

10

ALGOL (Algorithmic Language)

comment ALGOL 60 PROGRAM

displays "Hello world" 10 times;

begin

integer counter;

for counter := 1 step 1 until 10 do

begin

printstring(Hello world");

end

end

ALGOL 

was an international effort to 

design a universal language

ƒ

developed by joint committee of ACM 
and GAMM (German equivalent)

ƒ

influenced by FORTRAN, but more 
flexible & powerful, not machine specific

ƒ

ALGOL introduced and formalized many 
common language features of today

• data type
• compound statements
• natural control structures
• parameter passing modes
• recursive routines
• BNF for syntax (Backus & Naur)

ƒ

ALGOL evolved (58, 60, 68), but not 
widely adopted as a programming 
language

• instead, accepted as a reference language

background image

6

R. Pełka:  Języki Programowania, 2008

11

C Æ C++ Æ Java Æ JavaScript

ƒ

C (1971, Dennis Ritchie at Bell Labs)

• designed for system programming (used 

to implement UNIX)

• provided high-level constructs and low-

level machine access

ƒ

C++ (1985, Bjarne Stroustrup at Bell Labs)

• extended C to include objects
• allowed for object-oriented 

programming, with most of the efficiency 

of C

ƒ

Java (1993, Sun Microsystems)

• based on C++, but simpler & more 

reliable 

• purely object-oriented, with better 

support for abstraction and networking

ƒ

JavaScript (1995, Netscape)

• Web scripting language

#include <stdio.h> 

main() { 

for(int i = 0; i < 10; i++) { 

printf ("Hello World!\n"); 

}

#include <iostream>

using namespace std; 

int main() { 

for(int i = 0; i < 10; i++) { 

cout << "Hello World!" << endl;

return 0;

}

public class HelloWorld { 

public static void main (String args[]) { 

for(int i = 0; i < 10; i++) { 

System.out.println("Hello World "); 

}

<html>

<body>

<script type="text/javascript"> 

for(i = 0; i < 10; i++) { 

document.write("Hello World<br

/>"); 

</script> 

</body>

</html>

C

C++

Java

JavaScript

R. Pełka:  Języki Programowania, 2008

12

Other influential languages

ƒ COBOL

(1960, Dept of Defense/Grace Hopper)

ƒ

designed for business applications, features for structuring data & managing files

ƒ BASIC

(1964, Kemeny & Kurtz – Dartmouth)

ƒ

designed for beginners, unstructured but popular on microcomputers in 70's

ƒ Simula 67

(1967, Nygaard & Dahl – Norwegian Computing Center)

ƒ

designed for simulations, extended ALGOL to support classes/objects

ƒ Pascal

(1971, Wirth – Stanford)

ƒ

designed as a teaching language but used extensively, emphasized structured 
programming

ƒ Prolog

(1972, Colmerauer, Roussel – Aix-Marseille, Kowalski – Edinburgh)

ƒ

logic programming language, programs stated as collection of facts & rules

ƒ Ada

(1983, Dept of Defense)

ƒ

large & complex (but powerful) language, designed to be official govt. contract 
language

background image

7

R. Pełka:  Języki Programowania, 2008

13

Nie ma idealnego rozwiązania …

ƒ

remember

: there is no best programming language

ƒ

each language has its own strengths and weaknesses

ƒ

languages for a specific application

business applications  

Æ

COBOL

artificial intelligence 

Æ

LISP/Scheme or Prolog

systems programming

Æ

C

software engineering

Æ

C++ or Java or Smalltalk

Web development 

Æ

Java or JavaScript or VBScript or perl

R. Pełka:  Języki Programowania, 2008

14

The family of PL

background image

8

R. Pełka:  Języki Programowania, 2008

15

PL in common use

SourceForge

R. Pełka:  Języki Programowania, 2008

16

PL in coomon use

(cont.) - books

background image

9

R. Pełka:  Języki Programowania, 2008

17

Popularność cd.

R. Pełka:  Języki Programowania, 2008

18

Language speeds

www.bagley.org/~doug/shoutout

Completely Random and Arbitrary 
Point System