0.2 Introduction to programming languages

주홍영·2022년 3월 9일
0

Learncpp.com

목록 보기
2/199

https://www.learncpp.com/cpp-tutorial/introduction-to-programming-languages/

Machine Language

First, each instruction is composed of a sequence of 1s and 0s. Each individual 0 or 1 is called a binary digit, or bit for short.
기계어는 0과1로 구성된 instruction

어떤 CPU는 instruction이 항상 32bit 지만, 반면에 x86 family와 같이 길이가 서로다른 instruction set을 가진 CPU 아키텍쳐도 있다.

differtent CPUs have different instruction sets

This meant programs generally weren’t portable (usable without major rework) to different types of system, and had to be written all over again.
위에서 portable은 휴대용의 느낌보다 범용성에 가까운 느낌으로 쓰인듯 하다

Assembly Language

기계어가 너무 보기 어려워서 만들어진 어셈블리어
각 instruction이 abbreviation (축약어)로 (기계어와 같이 비트가 아닌)

ex) Here is the same instruction as above in assembly language: mov al, 061h

사람이 보기에 이해하기 더 쉬워졌으나 CPU가 바로 해석할 수 없기에 translated 되어야 한다

앞서말한 translate의 과정을 Assembler 가 관장한다.

오늘날에도 속도가 중요한 경우 사용되곤 한다

하지만 어셈블리어도 각 instruction set을 이해하기에는 쉽지만 전체적으로 어떠한
functionality를 구현하는지 확인하기 힘들며, 여전히 Portable하지 못하다는 특성이 있다 (instruction set의 구현이 서로 다른 경우 호환이 불가능하다)

High-level Languages

To address the readability and portability concerns
해석 : 가독성 및 이식성 문제를 해결하기 위해

하이레벨언어는 마찬가지로 해석을 거쳐서 기계어로 번역이 되어야 됨
A compiler is a program that reads source code and produces a stand-alone executable program that can then be run.
컴파일러가 이를 관장해서 처리하는듯

An interpreter is a program that directly executes the instructions in the source code without requiring them to be compiled into an executable first. Interpreters tend to be more flexible than compilers, but are less efficient when running programs because the interpreting process needs to be done every time the program is run. This means the interpreter is needed every time the program is run.

인터프리터의 경우 바로 하드웨어로 돌릴 수 있도록 번역해주는? 느낌
하지만 프로그램을 running하는 경우 매번 번역작업이 진행되어야 하므로 (running 도중에도)
효율적이지 않다.

컴파일러는 먼저 번역을 다해서 exectuable file을 만들고 실행하고
인터프리터는 매순간 순간 라인을 번역해서 hardaware에 전송해 실행하는 느낌?

Most languages can be compiled or interpreted, however, traditionally languages like C, C++, and Pascal are compiled, whereas “scripting” languages like Perl and Javascript tend to be interpreted. Some languages, like Java, use a mix of the two.

c, c++, pascal은 컴파일
scripitng language인 Perl, javascript는 interpret
Java는 위 둘을 섞어서

장점: 알기 쉽다, 직관적이다, 스크립트 짜는데 더 효율적이다
앞서 기계어와 어셈블리어와 달리 Portable하다
(각 하드웨어에 맞는 컴파일러가 구비되어 있다면)

단 OS 의존적인 (ex)windows) code를 사용할 경우 portable 하지 않을 수도 있음
또한 특정 컴파일러 extensions를 사용할 경우 다른 컴파일러에서 portable하지 않다

단어장

compose : 구성하다
whereas : 반면에
abbreviation : 축약형
to address : 다루다, 처리하다
concern : 염려, 관심사, 걱정, 본문에서는 문제에 가까운 의미로

profile
청룡동거주민

0개의 댓글