I'm a college student who usually writes only Python. Currently, I am making a messaging app as a training because I was accepted by an intern who applied for it with half interest.
For this intern, the recommended language was Kotlin on both the server side and the client side. I was a little worried if I could implement it in Kotlin because I had never touched Java, but when I tried it while investigating, I was able to remember it ** easily **.
I think that many articles on the net are Kotlin articles for the purpose of comparison with Java. For someone like me who isn't migrating from Java, it's also hard to get along with.
So, this time, I would like to introduce in order what Java inexperienced people did to study Kotlin.
https://www.amazon.co.jp/Kotlinスタートブック-新しいAndroidプログラミング-長澤-太郎/dp/4865940391/
--The first book I bought to learn Kotlin's grammar ――The layout is beautiful and the design is easy to stick to.
You can find it by searching for "Kotlin" on Google, but it's hard to find a site that is systematically organized from the basic grammar. I rarely study with books, but I bought it this time.
The content is divided into three parts, the first two parts are about Kotlin's grammar, and the last third part is about the implementation on Android. The amount is also about this ratio.
It covers ** basic grammars ** required for programming such as classes and inheritance from simple conditional branches and functions. Anyone who has even a little bit of a bit of another programming language will understand it right away, and even those who have no programming experience will (probably) understand it.
Android This is written on the assumption that you have some knowledge of the Android implementation. ** ** I was also a complete beginner with the Android implementation, so I had a little trouble understanding it. However, when I read it back now, what was stuck was not Kotlin, but the description of the xml file, the concept of the adapter, and so on. It's written using a lot of Kotlin-specific techniques, so I think there are many parts that make me think "I see." For client engineers who are considering migrating from Java.
https://www.amazon.co.jp/Kotlinスタートブック-新しいAndroidプログラミング-長澤-太郎/dp/4865940391/
--Introduction to Kotlin written by the same person as before --Half is written about ** implementation of server-side API **
In Java, a sample implementation using Spark and Spring Boot, which are famous as web frameworks, is introduced. However, techniques using Kotlin-specific grammar were also written, and some of them were "certainly useful."
If you don't implement Android, this book may be better.
Once you've learned the basics, you'll have to look at what you don't understand individually. Here, I would like to introduce an article that focuses on the part where I am stuck.
--Many ** scope functions ** are provided by default in Kotlin. ――Frequently used scope functions are organized in a table in an easy-to-understand manner, and I was able to understand them easily. ――There are definitions and examples for each scope function, so I often look at it as if I were looking at the reference.
--Kotlin has an example of a ** higher-order function **. ――When I wanted to write a callback-like process on my own, I searched for it. ――When I first saw the definition of a higher-order function, I thought, "What is this?", But I understood it by reading it carefully.
--This article I found because I wanted to do ** asynchronous processing ** in Kotlin. ――Honestly, I couldn't understand it at first when I read it, but I could understand it after reading ** n times. ** ** ――Look at the practical examples using Coroutines described later, and if you want to investigate in detail, you should take a look.
--This is an implementation example of asynchronous API client using Retrofit + Coroutines. ――It seems that RxJava is the mainstream for asynchronous processing on Android, but I learned by reading that the number of implementations using Coroutines will increase as the transition to Kotlin progresses. -** I was surprised that asynchronous processing can be written synchronously without using callbacks. ** **
Reference - Kotlin Programming Launguage --The official Kotlin reference. ――Somehow ** † Strongest † ** ――I think that the British and strong people can learn everything with this alone (I can't do it)
What did you think? It's easy to think that Kotlin has to be learned from Java, but it's surprisingly easy to learn. There is also a part that makes you feel a modern language in writing.
"Buy a book for the time being, and if you have any questions, look it up online." This may be the fastest way to learn Kotlin.
Why don't you study Kotlin with this in mind?
~~ It's a secret that I sometimes think "This processing Python is quick". ~~
Recommended Posts