개발자가 내팔자

NodeJS의 특징, 강점, 약점 본문

Programming Language/JavaScript

NodeJS의 특징, 강점, 약점

야생의 개발자 2022. 6. 13. 21:12

IO needs to be done differently

비동기방식의 IO

  • 고전적인 처리 방식 : 절차지향적 -> 너무 많은 클럭 수를 낭비함

    let databaseResult = queryDatabase() // how long?
    // Do things with databasesResult...
    let apiResult = getSomethingFromAPI() // how long?
    // Do things with apiResult
  • JavaScript식 비동기 처리 방식

    queeryDatabase(result => {
    // Do things with databasesResult...
    })
    getSomethingFromAPI(result => {
    // Do things with apiResult
    })

    No more blocking!
    자바스크립트는 언어 수준에서 이미 비동기 문제를 잘 해결해 두었다.

Node가 빠른 속도와 매우 높은 확장성을 갖는 근본적인 이유

저수준의 오래 걸리는 일은 Node에게, 고수준의 로직은 메인 스레드에서.

저수준 처리의 개선

  • 저수준 처리는 Node가 빠르게 처리하기 매우 어려운 부분이 있다.
  • Node.js는 C와 WebAssembly module을 바인딩해 사용하는 방법을 제공한다.
  • C는 node-gyp를 통해, WebAssembly는 Node 12버전부터 제공하고 있다.

방대한 오픈 소스 생태계

'Programming Language > JavaScript' 카테고리의 다른 글

[TypeScript] Abstract Class와 Interface  (0) 2022.07.06
[TypeScript] Type과 Interface  (0) 2022.07.06
Comments