CoolHut

1. Introduction to Swift 본문

리뷰

1. Introduction to Swift

HappyDslo 2020. 4. 13. 00:06

1. Introduction to Swift

요새 뭔가 새로운 걸 배워보고 싶은 생각이 들어서, 순위가 급(?) 상승하고 있는 Swift 언어를 배워보려고 합니다. 일단 swift.org부터 시작해봅시다. Swift에 관한 모든 것이 있는 곳입니다.

swift.org
swift.org

첫 페이지를 보면 easy, fast, safe 세단어가 눈에 띄는데, 이게 Swift 언어의 주요 특징으로 보이고 특히 아래 문장이 Swift 언어의 목표라고 하네요.

we want to make programming simple things easy, and difficult things possible

그리고 modern programming concepts과 best practices를 배울 수 있다고 하는데, 구체적으로 그게 뭔지는 차차 알 수 있을 듯. 모바일 디바이스부터 데스크탑, 클라우드까지 다양한 플랫폼에 적용될 수 있다는 것도 매력적이네요. 소위 말하는 풀스택 개발자가 될 수 있는건가요?

Swift 언어의 특징

swift.org에서 언급된 주요 특징들은 아래와 같습니다.

  • inferred types. to make code cleaner and less prone to mistakes. type을 생략할 수 있고, Swift에서 type을 유추한다.
  • 헤더파일이 없고 namespace를 제공한다.
  • 메모리 관리가 자동으로 되다.
  • 세미콜론을 사용할 필요가 없다.
  • Closures unified with function pointers
  • Tuples and multiple return values
  • Generics
  • Fast and concise iteration over a range or collection
  • Structs that support methods, extensions, and protocols
  • Functional programming patterns, e.g., map and filter
  • Powerful error handling built-in
  • Advanced control flow with do, guard, defer, repeat keywords
  • 변수는 사용하기 전에 반드시 초기화 되어야 한다.
  • array와 integer는 overflow check이 된다.
  • Swift object는 nil 값을 가질 수 없다. 꼭 필요한 경우는 optional을 이용해서 nil 값을 사용할 수 있다.

Safety 관점에서 많이 언급됐는데, 앞으로 하나 하나 알아가 봅시다.