본문 바로가기
[Kotlin] Kotlin 의 숨겨진 비용 #1 [Kotlin] Kotlin 의 숨겨진 비용 #1 https://medium.com/@BladeCoder/exploring-kotlins-hidden-costs-part-1-fbb9935d9b62 -“With great power comes great responsibility” 를 기억해야 한다.( 간단한 코드를 짜는 대신 대가가 있다는 얘기다 ) -Kotlin bytecode inspector 를 사용하면 Kotlin 코드가 어떻게 bytecode 로 변환되는지 볼 수 있다.Android studio plugin 으로 접할 수 있다.이를 보면 primitive type 의 boxing, code 에서 보이지 않는 기타 object 들의 instantiation, 그리고 각종 추가 method 들의 추.. 2018. 1. 16.
[Kotlin] 장점, 단점, 그리고 아쉬운 점 이야기 [Kotlin] 장점, 단점, 그리고 아쉬운 점 이야기 https://medium.com/keepsafe-engineering/lessons-from-converting-an-app-to-100-kotlin-68984a05dcb6https://medium.com/keepsafe-engineering/kotlin-the-good-the-bad-and-the-ugly-bf5f09b87e6f -위 링크의 글을 쓴 필자는 마켓에 출시된 Java 로 되어 있는 앱을 Kotlin 으로 전환했다.많은 사람들이 Kotlin lib 때문에 dex method limit 이 걸릴 것을 걱정하지만,실제 converting 후 proguard 적용시 method count 는 10% 줄어들고, code line 은 30% 줄.. 2018. 1. 15.
[Objective-C] 선언 프로퍼티 [Objective-C] 선언 프로퍼티 출처 : OS X 구조를 이해하면서 배우는 Objective-C Chap 7. Notice : 정리자(돼지왕 왕돼지)가 remind 하고 싶은 내용이나 모르는 내용 기반으로 정리하는 것이기 때문에 구체적인 내용은 책을 사서 보시기를 권장드립니다. 7.1. 프로퍼티란 * 7.1.1. 프로퍼티를 사용한 프로그래밍 -선언 프로퍼티 관련 기능은.. 접근자 메서드 생성 인스턴스 변수를 지정해서 전형적인 접근자 메서드를 생성할 수 있다. 게터와 세터 모두 생성할지 게터만 생성할지 지정할 수 있다. 대응하는 접근자를 스스로 정의할 수도 있다. 인스턴스 변수 생성 프로퍼티를 인스턴스 변수에 없는 이름으로 선언하면 접근자 메서드와 동시에 자동으로 인스턴스 변수도 생성된다. 접근자 .. 2017. 12. 28.
[Effective Objective-C] #41 동기화에는 락보다는 디스패치 큐를 사용하라 [Effective Objective-C] #41 동기화에는 락보다는 디스패치 큐를 사용하라 출처 : Effective Objective-C -다수 스레드에서 동시에 접근하기 때문에 문제를 겪는 코드를 오브젝티브-C에서 가끔 발견할 수 있다.이 문제를 해결하기 위해서는 앱이 락을 사용해 동기화해야 한다.GCD 이전에는 동기화를 위한 두 가지 방법이 있었는데 첫 번째 방법은 built-in 동기화 블록이다.- (void) synchronizedMethod{ @synchronized(self){ // 코드 }} 이 구조는 주어진 객체를 기반으로 락을 자동으로 생성하고 블록에 포함된 코드가 완료될 때까지 락을 잡고 기다린다.락은 코드 블록의 끝에서 풀린다. -또 다른 방법은 NSLock 객체를 직접 사용하는 .. 2017. 10. 6.
[Kotlin Tutorial] Annotation 과 Reflection #2 [Kotlin Tutorial] Annotation 과 Reflection #2 참조 : Kotlin in action 10.2. Reflection: introspecting Kotlin objects at runtime -Kotlin 에서의 reflection 은 java.lang.reflect package 의 API 들과 kotlin.reflect package 의 API 들을 사용한다.Kotlin 의 reflection 은 Java 에 없는 nullable type 이나 properties 들의 접근을 가능하게 한다. -runtime lib 의 size 를 줄이기 위해, kotlin 의 reflection API 는 kotlin-reflect.jar 라는 별개의 jar 로 pakcage 되어 있.. 2017. 9. 12.
[Kotlin Tutorial] Annotation 과 Reflection #1 - Chap 10. Annotations and reflection [Kotlin Tutorial] Annotation 과 Reflection #1 - Chap 10. Annotations and reflection 참조 : Kotlin in action 10.1. Declaring and applying annotations. 10.1.1. Applying annotations -Annotation 사용법은 Java 와 동일하다. @ 를 prefix 로 하고 annotation name 을 써주면 된다. -@Deprecated 의 경우 Kotlin 은 Java 의 것에서 향상되었다.replaceWith parameter 가 추가되어, 새로운 version 의 API 에 연결될 수 있다.@Deprecated(“Use removeAt(index) instead.”, Rep.. 2017. 9. 7.
[Kotlin Tutorial] Generics - Chap9. Generics 참조 : Kotlin in action 9.1. Generic type parameters -Java 와 기본적으로 generic 사용법은 동일하다. -Type Inference 는 가능하지만 명시적으로 써야 하는 케이스도 있다.val authors = listOf(“Dmitry”, “Svetlana”) // type inference 가능 val readers : MutableList = mutableListOf() // type inference 불가능, 명시적 선언val readers = mutableListOf() -Kotlin 에서는 raw type generic 을 사용할 수 없다. ( Java 로 치자면 그냥 List ) 9.1.1. Generic functions and properties.. 2017. 9. 5.
[Kotlin Tutorial] 함수 정의하고 호출하기 #1 - Chap 3. Defining and calling functions [Kotlin Tutorial] 함수 정의하고 호출하기 #1 - Chap 3. Defining and calling functions 참조 : Kotlin in Action 3.1. Creating collections in Kotlin -아래와 같이 쉽게 collection 을 만들 수 있다."type”Of 의 form 이다.val hashSet = hashSetOf(1, 7, 53) // mutableval set = setOf(“Gamza”, “Goguma”) // immutable val list = arrayListOf(1, 7, 53) // mutable val map = hashMapOf(1 to “one”, 7 to “seven”, 53 to “fifty-three”) // mutable/.. 2017. 8. 3.
[Kotlin Tutorial] Kotlin 기초 #1 - Chap2. Kotlin basics [Kotlin Tutorial] Kotlin 기초 #1 - Chap2. Kotlin basics 참조 : Kotlin in Action 2.1. Basic elements : Functions and variables 2.1.1. Hello, world! -fun main(args: Array){ println(“Hello, world!”)} fun 는 function 을 정의하는 keywordtype 은 variable 이름 다음에 옴function이 class 정의 안에 있지 않아도 된다Array 가 class 이다 ( Java 는 아니징 ) -> Kotlin 에서는 모든 것이 Object 이다System.out.println 대신 println; (semicolon) 넣을 필요 없다 ( option.. 2017. 7. 25.
반응형