Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Elm <3

Elm <3

Avatar for Sehyun Chung

Sehyun Chung

October 25, 2019

Other Decks in Programming

Transcript

  1. ‘반환함’ add : number -> number -> number add x

    y = x + y 함수이름 ‘타입 어노테이션임’ 인자 인자 ‘반환함’ expression ‘받고’ ‘받아서’ 타입 타입 타입
  2. |> 재대입이 불가능 |> statement가 없고 expression만 있음 |> 코드

    실행 블록({})이 없음 |> 값을 만드는 것 외에 다른 실행을 할 수 없음 |> 그래서 모든 함수가 순수 함수일 수 밖에 없음 |> undefined 와 null이 존재하지 않음
  3. Tony Hoare(1934~) I call it my billion-dollar mistake. It was

    the invention of the null reference in 1965. At that time, I was designing the first comprehensive type system for references in an object oriented language (ALGOL W). My goal was to ensure that all use of references should be absolutely safe, with checking performed automatically by the compiler. But I couldn't resist the temptation to put in a null reference, simply because it was so easy to implement. This has led to innumerable errors, vulnerabilities, and system crashes, which have probably caused a billion dollars of pain and damage in the last forty years. 나의 10억 달러(약 1조 천2백58억원) 짜리 실수다!
  4. 그 동안 짠 Elm 코드가 20만줄인데 2년 만에 처음 런타임

    에러가 났다. 그동안 레거시 자바스크립트 코드는 대충 6만번 정도 터짐. (Debug.crash라는 코드였고 말 그대로 crash를 일으키는 코드였음(땀))
  5. 어디가 문제인지 ‘보여’줌 자기를 ‘I’라고 지칭함(귀엽) 그래도 모르겠으면 어딜 찾아보라고

    알려줌 일단 뭐가 문제인 지 알려줌 어떻게 하면 좋을지 ‘제안’함
  6. 모든 에러 메시지는 저기서 배워야 함. Elm 고마워 내가 본

    중 가장 유용한 에러메시지임 존 카맥 (퀘이크, 둠, CTO of Oculus VR)
  7. import Browser import Html exposing (Html, button, div, text) import

    Html.Events exposing (onClick) main = Browser.sandbox { init = 0, update = update, view = view } type Msg = Increment | Decrement update msg model = case msg of Increment -> model + 1 Decrement -> model - 1 view model = div [] [ button [ onClick Decrement ] [ text "-" ] , div [] [ text (String.fromInt model) ] , button [ onClick Increment ] [ text "+" ] ]
  8. |> 순수한 재미를 추구할 수 있는 기회 |> Haskell 등

    함수형 머시기에 관심이 있다면 |> 컴파일러님과 싸우다보면 프로그램이 돌아간다 |> 재미있다