“It is critical for the community to set standards”: Marsin Moskala about Kotlin





A couple of years ago, there were a lot of “See what an interesting Kotlin language” blog posts that explained the basics. In 2019, you no longer need to chew the basics, but now a publication appears in a completely different format. Marsin Moskala, who has been teaching people this language for many years, is now publishing the book “Effective Kotlin” - that is, not just “how to write Kotlin”, but “how to write Kotlin in the best way”.



And soon Marsin will come to us on Mobius with a report . Therefore, we asked him about the new book, the report, the training of Kotlin people, and what is happening in the industry around this language. And about the difference between the words "effective" and "efficient".



- First, please tell us a little about yourself. What did you do before you started educating people and creating Kt. Academy ?



- I have been programming since childhood. I started with Visual Basic when I was 10 because I wanted to make games. Later, during the training, I discovered Android for myself and devoted myself to Android development. In the following years I worked for companies like Samsung, Warta and mBank (as an employee of Apreel), Docplanner and Gamekit. And also discovered Kotlin and fell in love. I began to make presentations about him, write articles and books. Soon, companies began to turn to me for training, and so Kt appeared. Academy.



- Do you have JetBrains partner status, and what does it mean? What requirements do you need to meet? Do you often chat with JetBrains?



- The main requirement is to know Kotlin well and spread knowledge about it. It is also necessary that a person be reliable, and it will not be superfluous if he is known.



I keep in touch with some members of the Kotlin team, as well as with the evangelists, but I myself am not sure how much this is connected with the partner status. Mostly, this status is a way for JetBrains to report that someone knows a specific JetBrains technology, and certificates from that person are valuable.



- You teach Kotlin people, so you get a lot of feedback and questions about it from different people. What do they say and what do they ask most often?



- People really like him. They especially note its brevity and the fact that they do it very easily. And their top-level functions and implicit recipients in lambda expressions (implicit receivers) are disturbing. In my opinion, there is no problem with the first option, but what about the second ... I think people are overdoing it and we are just starting to realize the scale of the problem.



- Is there any common mistake or antipattern in the Kotlin code of different people?



- I think this is just an unnecessary desire to hide the recipient. Well, you know, all sorts of DSL inside DSL, apply inside apply ... more and more often the recipient is using it covertly. It's great when you write code, but not when you read it.



- Initially, everyone came to Kotlin only from Java. Now do you have to teach people who don’t know Java at all, but want to learn Kotlin?



- Yes, I trained a lot of developers in JavaScript and Swift, a team of rockers and even a team of developers in C, for whom Kotlin was a huge leap. Kotlin also thinks a lot about pythonists - I hope they join too.



- Will you recommend learning Kotlin as the first language in 2019? Or do beginners still have to deal with Java, so it will be difficult?



- If a person wants to engage in Android development, I definitely recommend it. If I had more time, I would write a book about modern Android development, which did not touch the origins at all, but immediately suggested new approaches: Kotlin, AndroidX, Room, WorkManager, ConstraintLayout and MVVM with ViewBinding (and soon Jetpack Compose ) ... We can live well without Java, Support Library, DatabaseHelper, AlarmManager.



The backend is more complicated, but it’s also fun with modern Kotlin frameworks like Ktor. So for students this can also be an interesting option.



- Different languages ​​are evaluated differently in the context of learning: Python is often praised in this regard, Java is sometimes criticized. What is it like teaching Kotlin compared to Java?



- On the one hand, in Kotlin it is much easier to do something. When you teach Kotlin, the ability to put many classes and functions in one file helps a lot.



Kotlin, on the other hand, has more features than Java, so learning them takes time. Although, to some extent, these idioms still embody repeating patterns from Java: for example, data classes, which for a beginner in Java will be difficult, and in Kotlin trivial, it is enough to add the data modifier. I would say that overall learning Kotlin is more fun.



- Sometimes Kotlin is perceived only as the “language for Android”, but it has ambitions in other areas. What do you see in your trainings: all the demand for them from mobile developers, or do backenders also apply?



- A year ago, almost everyone was for Android developers. And now, I think, about 50 to 50. There is also growing interest in the Kotlin Corotuines and Effective Kotlin trainings.



- To the question of Effective Kotlin: your new book is called the same, and your report on Mobius is Efficient Kotlin. Do such similar names mean that the new report is a brief retelling of the theses of the whole book?



- The words “effective” and “efficient” in programming have very different meanings, like “safe” and “secure”. "Effective" is more general, about the most different best practices. And “Efficient Kotlin” is only about performance and memory optimizations, the third part is devoted to this in the book. For Mobius, this is better, because the conference is known for advanced reports for experienced developers. And the time of the report is limited; the whole book cannot be covered there.











- And the principles from "Effective Kotlin" and "Efficient Kotlin" are suitable for all developers, no matter what they write on Kotlin, or is there any specificity there?



- Everyone: not only Android and the backend, but even those who use Kotlin / JS and Kotlin / Native.



- The name “Effective Kotlin” immediately brings to mind Joshua Bloch's “Effective Java”. How does your book look like her?



- There are many books in the "Effective X" format, and all of them are built on the same principle: show with concrete examples how to write code. I was inspired by Effective Java, and others - Effective C #, Effective Python, Effective C, Effective JavaScript. But there is no strict binding to any of these books - all these are different languages, and different advice is required with them. Although, if you read them all and then read Effective Kotlin, you can link any of my advice with the advice from other “effective” books. And also with tips from other influential books like Code Complete, Clean Code, Clean Archutecture, Structure and implementation of computer programs, and so on. My goal was to take the best tips that fit Kotlin and present them in the most understandable way.



- A lot of books have already been published about Kotlin, but usually they were in the format “how to do something on Kotlin” and not “how to do it in the most efficient way”. Do you think that at first the community needed the basics of Kotlin, but now it has mastered and wants to improve quality?



- Yes, I think the community has grown so much that now it needs best practices. According to the official website, there are already more than two million Kotlin developers in the world. This is a lot. There are already many “How to ...” format articles and answers to Stack Overflow, but there are more and more people who had to use Kotlin because of CTO's solution, or for whom it became the first language. Now setting standards is critical because Kotlin allows a lot, and if we don’t stop people from doing crazy things, they may end up loving it and start to consider it confusing and unreadable.



- Best practices are always a debatable topic, people's opinions about “what’s best” differ. Are there discussions in your trainings or reports?



- Yes, and these discussions inspired me to write Effective Kotlin. As I said, people often care about some features. I usually listen and let them speak. As a result, it is always possible to come to conclusions about the advantages and disadvantages of the feature, and then the teams decide what they should do with it.



“You are publishing the second book.” What does the process of working on them look like? For example, how do you decide who will publish it?



- The first I published in Pact. I was not quite happy with the collaboration, so I decided to publish Effective Kotlin on my own using LeanPub. So far, the experience is excellent. I have excellent volunteer reviewers, a good designer, and a nice typography. Problems arose only with the account in Amazon, but I hope I have time to deal with it before the publication of the final version of the book.



- Do you advise developers to write books? How useful is this for the developer?



“When you start the book, you need to know that it will almost certainly take longer than you expect.” Estimate 1-2 hours per page. And if you are a developer, it is unlikely that the book will bring you more money than if you had spent this time programming. On the other hand, you will learn a lot. To write confidently, you need to carefully study the topic and truly understand each argument. And this is a unique experience.



- And the last question: if you could change one thing in Kotlin, what would it be?



- I think I would get rid of Unit. He's a little annoying. Especially when interacting with some other languages.



Finally, recall the links to the text mentioned. The book “Effective Kotlin” is published on Leanpub , and the description of Marsin ’s new report, with which he will arrive at Mobius in December, is published on the conference website (and you can see its full program there ).




All Articles