다트 공식문서 읽기 - (1)

kim kile·2022년 8월 3일
0

Dart 공식문서 읽기

목록 보기
1/1
post-thumbnail

1. dart는 왜 type safe를 적용할까?

In computer science, type safety and type soundness are the extent to which a programming language discourages or prevents type errors.

The Dart language is type safe

Revealing type-related bugs at compile time.

More readable code. More maintainable code.

개발자들이 타입에러를 발생시키는 것을 방지할 수 있도록 도와주기 위해서.


2. type safe는 반드시 지켜야 하는걸까?

Although types are mandatory, type annotations are optional because of type inference.

it uses a combination of static type checking and runtime checks to ensure that a variable’s value always matches the variable’s static type, sometimes referred to as sound typing.

필수적으로 지켜야하는 것은 아니다. 왜냐면 다크 컴파일러 차원에서 타입을 추론할 수 있기 때문. 그래서 다트 디버거는 타입을 이중으로 체크해준다. 컴파일 할때 명시적으로 잘못된 타입선언을 체크해주고, 런타임 중에 암시적으로 잘못된 타입선언을 체크해준다.


3. dart의 type system은 soundness 할까?

Soundness is about ensuring your program can’t get into certain invalid states.

A sound type system means you can never get into a state where an expression evaluates to a value that doesn’t match the expression’s static type.

다트의 type system은 절반정도 soundness한게 아닌가 싶다. 왜냐면 암시적으로 type을 선언할 수 있기 때문에 런타임 단계에서 type 에러가 발생할 수 있기 때문. 암시적 선언을 열어둔것은 아마도 개발자의 자유도를 보장해주기 위함이 아닌가 싶지만, 자유도가 높아진 많큼 에러가능성도 동시에 높아진다는 트레이드 오프가 있다.


4. 변수와 관련된 consumer와 producer는 뭘까?

Consider the following simple assignment where Cat c is a consumer and Cat() is a producer: Cat c = Cat();

지금껏 무수히 많은 변수를 선언해왔지만, 왼쪽이 consumer고 오른쪽이 producer라는 프레임으로 본적이 없다. ㅎㅎ;; 이렇게 개념을 하나 알게되니 흥미롭다. 내가 알던 현상을 정리하는 느낌이 즐겁다.


5. 다트팀이 생각하는 효과적으로 코드를 작성하는 원칙?

Be consistent. When it comes to things like formatting, and casing, arguments about which is better are subjective and impossible to resolve. What we do know is that being consistent is objectively helpful. If two pieces of code look different it should be because they are different in some meaningful way. When a bit of code stands out and catches your eye, it should do so for a useful reason.

The Dart analyzer has a linter to help you write good, consistent code. If a linter rule exists that can help you follow a guideline, then the guideline links to that rule.

양식을 코드베이스에 일관적으로 적용하기. 마치 하나의 책에서 문체가 달라지면 안되는 것과 같음. 문체를 일관적으로 적용하기 위해 린터러는 도구를 활용할 수 있다.

If there are multiple ways to say something, you should generally pick the most concise one.

제일 간견할 문체를 사용하기.


6. 다트팀이 다트 언어를 개발한 동기?

Dart was designed to be familiar, so it inherits many of the same statements and expressions as C, Java, JavaScript and other languages. But we created Dart because there is a lot of room to improve on what those languages offer. We added a bunch of features, from string interpolation to initializing formals, to help you express your intent more simply and easily.

다른 언어들 속에서 보다 개선할 수 있는 아이디어를 발견할 수 있어서. 언어역시 서비스다. 모든 서비스가 출발점은 비슷하다. 불편에서 시작하는 것. 사실 언어는 주어진 것. 당연한 것. 으로 생각하기 쉬워서 처음 언어역시 서비스라는 생각이 들었을 때 무척이나 신선했음.


https://dart.dev/guides/language/effective-dart#the-guides

0개의 댓글