[JAVASCRIPT][https://javascript.info/][PART1-The JavaScript language][An introduction][1.1 An Introduction to JavaScript]

·6 min read

[[An Introduction to JavaScript]]

  • Let’s see what’s so special about JavaScript, what we can achieve with it, and what other technologies play well with it.

-- JavaScript의 특별한 점, JavaScript로 무엇을 얻을 수 있는지, JavaScript와 잘 어울리는 다른 기술은 무엇인지 살펴보겠습니다.

 

[What is JavaScript?]

  • JavaScript was initially created to “make web pages alive”.

-- JavaScript는 처음에 "웹 페이지를 생생하게 만들기" 위해 만들어졌습니다.

 

  • The programs in this language are called scripts. They can be written right in a web page’s HTML and run automatically as the page loads.

-- 이 언어로 된 프로그램을 스크립트라고 합니다. 웹페이지의 HTML파일 내에 바로 작성할 수 있으며 페이지가 로드될 때 자동으로 실행될 수 있습니다.

 

  • Scripts are provided and executed as plain text. 

-- 스크립트는 일반 텍스트로 제공되고 실행됩니다.

  • They don’t need special preparation or compilation to run.

-- 실행을 위해 특별한 준비나 컴파일이 필요하지 않습니다.

 

  • In this aspect, JavaScript is very different from another language called Java.

-- 이러한 측면에서 JavaScript는 Java 언어와 매우 다릅니다.

 

[! Why is it called JavaScript?]

  • When JavaScript was created, it initially had another name: “LiveScript”. -- JavaScript가 생성되었을 때, 처음에는 "LiveScript"라는 다른 이름을 사용했습니다.

  • But Java was very popular at that time, so it was decided that positioning a new language as a “younger brother” of Java would help. -- 하지만 당시 Java는 매우 인기가 있었기 때문에, 새로운 언어를 Java의 "동생"으로 포지셔닝하는 것이 도움이 될 것이라고 결정했습니다.

  • But as it evolved, JavaScript became a fully independent language with its own specification called ECMAScript, and now it has no relation to Java at all. -- 그러나 JavaScript가 발전하면서, JavaScript는 ECMAScript라는 자체 사양을 갖춘 완전히 독립적인 언어가 되었으며, 이제는 Java와 전혀 관련이 없습니다.  

  • Today, JavaScript can execute not only in the browser, but also on the server, or actually on any device that has a special program called the JavaScript engine.

-- 오늘날 JavaScript는 브라우저뿐만 아니라 서버나 실제로 JavaScript 엔진이라는 특수 프로그램이 있는 모든 장치에서 실행될 수 있습니다.

 

  • Different engines have different “codenames”. For example:

-- 엔진마다 "코드명"이 다릅니다. 예를 들어:

    • V8 – in Chrome, Opera and Edge.
  • SpiderMonkey – in Firefox.

  • …There are other codenames like “Chakra” for IE, “JavaScriptCore”, “Nitro” and “SquirrelFish” for Safari, etc.

  • The terms above are good to remember because they are used in developer articles on the internet.

-- 위의 용어는 인터넷의 개발자 기사에 사용되므로 기억해 두는 것이 좋습니다.

  • We’ll use them too. For instance, if “a feature X is supported by V8”, then it probably works in Chrome, Opera and Edge.

-- 우리도 그것들을 사용할 것입니다. 예를 들어, "V8에서 기능 X를 지원합니다"라면 아마도 Chrome, Opera 및 Edge에서 작동할 것입니다.

 

[! How do engines work?]

  • Engines are complicated. But the basics are easy. -- 엔진은 복잡합니다. 하지만 기본은 쉽습니다.
    • The engine (embedded if it’s a browser) reads (“parses”) the script. -- 엔진(브라우저인 경우 내장)은 스크립트를 읽습니다("구문 분석").
    • Then it converts (“compiles”) the script to machine code. -- 그런 다음 스크립트를 기계어 코드로 변환(“컴파일”)합니다.
    • And then the machine code runs, pretty fast. -- 그런 다음 기계어 코드가 매우 빠르게 실행됩니다.
  • The engine applies optimizations at each step of the process. -- 엔진은 프로세스의 각 단계에서 최적화를 적용합니다.
  • It even watches the compiled script as it runs, analyzes the data that flows through it, and further optimizes the machine code based on that knowledge. -- 심지어 실행되는 컴파일된 스크립트를 관찰하고, 이를 통해 흐르는 데이터를 분석하며, 해당 지식을 기반으로 기계어 코드를 더욱 최적화합니다.  

[What can in-browser JavaScript do?]

Modern JavaScript is a “safe” programming language. It does not provide low-level access to memory or the CPU, because it was initially created for browsers which do not require it.