화물 컬트 프로그래밍

Cargo cult software engineering은 Steve McConnell이 만든 용어입니다.

McConnell describes software development organizations that attempt to emulate more successful development houses, either by slavishly following a software development process without understanding the reasoning behind it...

-- Wikipedia



Feynman이 사이비 과학을 설명하기 위해 이 용어를 사용했기 때문에 "화물 컬트"라고 불립니다.

In the South Seas there is a Cargo Cult of people. During the war they saw airplanes land with lots of good materials, and they want the same thing to happen now. So they’ve arranged to make things like runways, to put fires along the sides of the runways, to make a wooden hut for a man to sit in, with two wooden pieces on his head like headphones and bars of bamboo sticking out like antennas—he’s the controller—and they wait for the airplanes to land. They’re doing everything right. The form is perfect. It looks exactly the way it looked before. But it doesn’t work. No airplanes land. So I call these things Cargo Cult Science, because they follow all the apparent precepts and forms of scientific investigation, but they’re missing something essential, because the planes don’t land.

-- Richard P. Feynman



소개



프로그래밍에서 물러나서 큰 그림을 봅시다. 사람들은 항상 사물을 설명하고, 이해하고, 추론하고, 예측하고, 원하는 방식으로 작동하도록 만들려고 노력했습니다.

천둥 신이 화가 나서 번개를 던진 결과로 번개를 설명하는 원시 종교를 상상해보십시오. 이것은 자연 현상을 설명하려는 시도입니다.

또는 예를 들어 일부 부족이 비를 내리기 위해 춤을 추는 것과 같은 오컬트나 주술적 관습을 상상해 보십시오. 이것은 사물에 영향을 미치려는 시도입니다(그러나 그것의 본질을 이해하지 못한 채).

그런 일을 하는 것은 일종의 인류의 오랜 전통입니다. 그러한 시도 중 일부는 다른 것보다 더 성공적이었습니다. 그렇게 과학이 나타났습니다. 과학은 사물을 설명하고 결과적으로 사물을 예측하거나 유용한 방식으로 작동하게 만드는 성공적인 방법입니다.

it (science) works... bitches!

--



예를 들어 실패한 시도는 사이비 과학, 신비주의, 연금술 등입니다. 참고: 인간 지식의 모든 분야를 과학으로 다룰 수 있는 것은 아닙니다. 예를 들어 철학과 예술이 있습니다.

프로그래밍으로 돌아가기



프로그래머도 사람입니다. 그들은 계산과 컴퓨터의 본질을 이해하려고 노력하고 컴퓨터와 소프트웨어에 대해 추론하려고 노력하며 컴퓨터가 원하는 대로 작동하도록 하려고 합니다. 그리고 우리는 이전에 사람들이 했던 것과 똑같은 일을 합니다. 우리는 그 주제에 대한 일련의 믿음을 가지고 있습니다. 어떤 믿음은 합리적인 설명이 있고 어떤 믿음은 그렇지 않습니다.

프로그래밍이 컬트처럼 느껴질 때의 예를 보여주는 일련의 게시물을 작성하겠습니다.

cult - a system of religious beliefs and ritual

-- merriam-webster



정의되지 않음 및 null



JavaScript에는 undefinednull 의 두 가지 비값이 있습니다. 값이 아닌 것은 값이 없음을 나타내는 것으로 가정합니다. 두 개의 별개의 비값이 있으므로 존재 이유가 있다고 가정합니다. 맞습니까?

So people try to explain it :



tc39 says :

4.4.13 undefined value -
primitive value used when a variable has not been assigned a value

4.4.15 null value -
primitive value that represents the intentional absence of any object value



따라서 null 값은 개체 값 🤔의 의도적인 부재를 나타내는 것으로 가정합니다.

객체 비트에 대해 이야기해 봅시다.

typeof null === "object";


이것은 typeofnull가 객체를 위한 이유라고 생각하도록 속일 수 있습니다. 그러나 JavaScript의 초기 구현에는 그 당시까지 지속된 버그가 있음이 밝혀졌습니다. The history of “typeof null”을 참조하십시오.

의도적 인 비트에 대해 이야기합시다. 의도적으로 사용할 수 있습니다undefined:

let a = undefined; // 🤷‍♀️
({ a: undefined }.hasOwnProperty("a")); // true


JS 자체가 사용하는 위치undefined를 살펴보겠습니다.

var a; // not initialized
let a; // not initialized
({}["test"]); // no value
[][0]; // out of bounds
((x) => x)(); // no argument provided
(() => {})(); // no return value
(() => {
  return;
})(); // no return value
void 0; // evaluate expression and return undefined


null - 내가 찾은 유일한 장소는 null를 반환합니다.

(Deprecated) The function.caller property returns the function that invoked the specified function. It returns null for strict, async function and generator function callers.

-- mdn

The Object.setPrototypeOf() method sets the prototype (i.e., the internal [[Prototype]] property) of a specified object to another object or null.

-- mdn



일부 DOM 기능도 있지만 DOM은 JS 사양의 일부가 아니라 라이브러리와 비슷합니다.

JS 자체는 그렇게 많이 사용하지 않습니다null. 더 이상 사용되지 않는 기능이나 거의 사용되지 않는 기능에 사용됩니다.
nullJSON에서 사용되지만 라이브러리로 도입되었고 나중에 언어에 포함되었습니다. 그리고 JSON의 저자(Douglas Crockford)believes that null should be deprecated .

많은 언어에는 하나의 비값이 있습니다.
  • 파이썬NONE
  • 루비 - nil
  • CNULL 매크로
  • null - C.A.R. Hoare는 null이 The Billion Dollar Mistake이라고 말합니다. 예를 들어 Haskell에서는 null 대신 Maybe를 사용합니다(비연속 합집합 방식).

    data Maybe a = Just a | Nothing
    


    두 개의 값이 아닌 값을 가질 실제 이유가 없습니다. 프로그래밍 언어 설계 오류였습니다(오류를 만들어도 괜찮습니다). 하지만 그것들이 존재하기 때문에 사람들은 레거시 코드 이상의 것으로 그 존재를 설명하려고 합니다.

    좋은 웹페이지 즐겨찾기