CS/프로그래밍 언어론

[프로그래밍 언어론] 개요

윤곰이 2024. 4. 26. 00:39

프로그래밍 언어 배우는 이유

  • different construct 이용하는 capacity 늘리기
  • 언어 선택을 더욱 intelligently 하게
  • 새로운 언어 배우는 것이 쉽게

Programming Domains(분야)

  • 과학 기술 응용: scientific applications(floating point) → Fortran
  • Business applications: 휴대폰 요금 고지서 → COBOL
  • AI: 기호 이용 계산, linked list → LISP
  • System programming: 효율성 중요(속도⬆️, 메모리⬇️) → C
  • Web Software: markup(HTML), scripting(PHP), general-purpose(Java)

Language Evaluation Criteria(평가기준)

  1. Readability
    • simplicity
    • orthogonality(직교성): 서로 다른 요소가 서로에게 영향 X
    • 적절한 data type
    • syntax consideration-이상한 키워드X, 기존과 유사
  2. Writability
    • simplicity
    • orthogonality
    • support for abstraction(추상화) : 세부사항X, 간단하게 설명 가능(프로그래밍 언어가 알아듣게)
    • expressivity: 충분한 표현력
  3. Reliability(신뢰성)
    • type checking: 미리 걸러줌
    • exception handling: 에러 등 특이사항 시→ 무시 but 계속 해
    • aliasing(별명): 하나의 대상에 여러 이름
    • readability&writability⬆️ → reliability⬆️
  4. Cost(비용): 시간비용, 실행시간, 전기, 유지 보수
  5. Portability(이식성): 환경마다 실행? 프로그램 이식이 쉬운지 어려운지
  6. Generality
  7. Well-definedness: 완벽, 정확

Influences on Language Design

  1. Computer Architecture
    • 현재 대부분: 폰노이만 architecture
      • Data, Program은 메모리에
      • 메모리는 CPU 와 떨어져서
      • iteration이 효율적
    • Imperative languages(명령형 언어)
    • Fetch-execute cycle
  2. Program Design Methodologies
    1. 1950-60초: machine efficiency 고려
    2. 1960후: 구조화 프로그래밍(structed programming)-함수로 자르기 
    3. 1970후: process-oriented→ data-oriented
    4. 1980중: object-oriented

Language Categories

  1. Imperative(명령형)
    • C, Java, Perl, Javascript, C++
  2. Functional(함수형)
    • 값→함수→값 결합
    • LISP, Scheme,,
  3. Logic(논리형)
    • prolog
  4. Markup/Programming hybrid
    • JSTL,XSLT

Implementation Methods

  1. compilation
    • high-level program → machine code로 번역
    • 번역은 느리지만, 해석 후 실행은 빠름
      • lexical analysis: character를 lexical unit으로
      • syntax analysis: lexical unit을 parse tree로
      • semantic analysis: intermediate code 생성
      • code generation: machine code 생성과정
      • 따로따로 compile → 연결: linker → load: loader
  2. pure interpretation → 그 때 그 때 한줄 씩 번역(실행시간, 메모리 ⬆️) 예: python
  3. hybrid implementation system: 둘의 결합
    • compiler: 실행시간 ⬇️, interpreter: 유연성, 디버깅 빠름 → 이 둘을 합친것
    • portability ⬆️: 기계어에 딸라 virtual machine만 바꾸면 ok
    Just-In-Time Implementation (JIT)
    • 미리 intermediate language로 번역해두었다가 → 호출 시 → machine code 번역
    • Java에서 널리 사용
    • 단점: compile 시간 ⬆️ (lazy compilation임)
      • eager compilation: 전체를 미리 compile 해놓는 것
      • lazy compilation: 실행 중 실제로 필요한 부분만을 compile

Layered View of Computer

Preprocessors

  • 다른 파일의 코드가 포함되어야 함을 알림
  • C 코드의 #include, #define 등