Language Paradigm
다른 종류 : – Applicative, concurrent, constraint, declarative, definitional, procedural, scripting, single-assignment, …
Imperative : 명령형
Assignment, Iteration, Order of execution is critical
프로그래밍의 상태와 이를 변경시키는 구문의 관점에서 연산을 설명
전역적인 상태가 없음. 그저 어떻게 계산되는지를 쭉 적어둠
C언어
int fact ( int n ) {
int sofar = 1;
while ( n > 0 ) sofar *= n-- ?
return &ofar;
}
# Forth Factorial : stack-oriented language
: FACTORIAL
1 SWAP BEGIN ?DUP WHILE TUCK * SWAP 1- REPEAT ;
Functional : 함수형
Single-valued variables (대입X), Heavy use of recursion(반복X)
자료 처리를 수학적 함수의 계산으로 취급하고, 상태와 가변 데이터, 반복 데이터를 멀리한다.
고로 함수의 응용을 강조함으로써, 람다 대수에 근간을 두고 있다.
장점은 상태를 신경쓰지 않고 병렬 처리 가능함
ML
fun fact x =
if x <= 0 then 1 else x * fact(x-1) ;
Object-Oriented
Usually imperative + Constructs to help programmers use "objects" (bundle)
클래스로 데이터를 객체에 의존하여 관리하고 메소드를 통해서만 접근할 수 있도록 함
파이썬은 완전히 객체 지향을 지원하지 않음. 다만 캡슐화와 상속, 다형성은 지원
Java
public class MyTnt {
private int value;
public Mylnt {int value) {
this.value = value;
}
public int getValue() {
return value;
}
public Mylnt getFact() {
return new MyInt(fact (value));
}
private int fact(int n) {
int sofar = l;
while (n > 1) sofar * = n-- ?
return sofar;
}
}
Logical
Program expressed as rules, in formal logic
fact(X,1) :=
X =:= 1,
!.
fact(X,Fact) :-
X>1,
NewXx is X-1,
fact(NewX, NF),
Fact is X * NF
The Odd Controversies
Partisan arguments
각 언어마다 장점이 좋제하기에 어느 것이 더 좋다고 말하기 어렵다.
Language standards
언어의 규범을 정의한 문서는 국제적으로 함께 작성한다
Fortran의 경우 여러 번 릴리즈 했다. (dialects)
Fundamental definitions
fuzzy concept: 이 언어가 어떤 패러다임인지 얘기하기 어렵다다
Evolution
발전하고 새로운 언어도 만들어진다
잘 적응한 언어는 살아남고(JAVA), 아니면 도태된다(Algol)
Programming Style
OOP: 객체를 많이 써서 만들어야
함수형: side effect를 최소화한 작은 함수를 많이 사용
논리형: 논리적으로 정의된 문제를 탐색하는 방식을 사용
+)
computer architecture: stack, parallel, internet
theory of formal language : regular or context-free grammar (automata)
turing equivalence
'CS > Programming Language' 카테고리의 다른 글
ML: Higher-order Functions (0) | 2022.11.11 |
---|---|
ML: Semantics - "Types", Polymorphism, Scope (0) | 2022.11.10 |
Language Systems (0) | 2022.11.03 |
모호성 (0) | 2022.10.31 |
Programming Syntax 2 (0) | 2022.10.30 |