For getting good at Kotlin, the environment is kind of like “You must know java or c++ like language if you want to learn Kotlin”.
Also, I love using the terminal for most of my work. But Kotlin tries to force you to use IntelliJ.
I want to mention that I love the language really and I don’t want to leave this language behind. But it has been more than a month or two, and I still cannot figure out how to create an executable using Kotlin.
And also, I and sick of using IntelliJ. No offense, but using the IDE for a simple program is not worth it. For this, I don’t even feel like writing some coding with Kotlin in my daily life. But I am still not leaving it, as I love the language at its core.
So, can anyone help me with this? I can be thinking in the wrong way; in which case guide me in the right direction.
It is really hard to compare interpreted, dynamically-typed, script-like languages to compiled and statically typed languages. They are apples and oranges in the terms of tooling and the developer experience.
I wouldn’t say you need to know other compiled languages to start using Kotlin, although it could be sometimes hard without being familiar with Java specifically. Java VM is the main target of Kotlin, so there are many similarities between both languages and unfortunately, the documentation for Kotlin sometimes assume familiarity with Java.
Speaking about IntelliJ (or any other IDE) my comment is: don’t even try to not use them. Programming is not really meant to be done using notepads, etc. Such approach could work with scripting languages, but not really with anything more “heavy”. You will get an headache of manually adding imports, etc.
Using the terminal for anything else than coding itself is fine. Use gradle/maven, then you can run, test and do a lot of other tasks straight from the terminal.
What you’re experiencing is the pains of a new domain. There’s a different set of perspectives and approaches, even different problems at play.
It’s very natural, expected even, to have this kind of growing pain with different workflows. You’re on the right track. The main thing I’d say is to lean into the new perspectives that may not feel natural and you’ll come out the other side better for it.
For example, I come from a heavy Java/JVM classical structure background. For me, compilers or tools that made things clean, effective, and fast to debug (Intellij being the gold standard) were the bare minimum.
Eventually, I started doing work in Python, a lot of Groovy work (basically Python kind of values), frontend, Lua, Dart, etc. These languages and toolchains felt challenging to work in:
- It felt tedious to be slowed down so heavily by having to use consoles (groovy/python terminals, REPLs) and always be running snippets to get tiny amounts of feedback when prior toolchains gave me feedback at every keystroke without having to execute anything at all.
- It felt difficult for discovery to always have an open separate page of documentation in order to find what method to call or what functions were available which had always been free and immediate documentation in my prior toolchains.
- It felt annoying to have to worry about my entire host machine as the execution environment for both developing and running code when in prior toolchains I had a single 10 line Gradle file that guaranteed that my code is isolated for execution and equal with all other collaborators’ development environments.
I could go on and on.
But after some time I found the solution is to lean into the new context. Instead of trying to get an easy-breezy IDE workflow to serve this new scripting context, use Vi and the REPL. Instead of expecting APIs to be clear and well-defined input/output types, go with the flow of making everything a collection. Instead of expecting contracts to be free and in code, create my own defensive validation checks.
There’s definitely a mental shift that happens after you get some practice. Kind of like the mental shift when learning OOP from the imperative focused “what do I do” to more OOP thinking of “what do I have”. Once you make that shift you’ll always have it available to you.
My advice would be to expect some discomfort for now but keep at it!
It’s funny because when I started to learn python the first thing I searched was “the best IDE for python”. I’ve eventually settled down on… Idea (PyCharm variant). It has a bare minimum of autocompletion and quick doc but still you need to configure local environment which is annoying coming from gradle/maven.
In my experience, it is quite easy for people with Python experience to adopt Kotlin as a language. Setting up a project could be tiresome at first (is saves much more time later though). If you want to play with language itself, I recommend using Kotlin notebook on a local computer or in https://datalore.jetbrains.com/. It allows you to play with the language without setting up a project.
To be honest, I think this is not a good advice. These all kernels, jupyters and notebooks are pretty confusing and complicated for anyone who is not a data analyst on a daily basis. I used different kinds of REPLs for 15+ years already, for the last year I use Spark, Zeppelin, Jupyter and similar tools extensively and it is still pretty confusing to me how to even run the above project
https://datalore.jetbrains.com/ could be much easier to start if you don’t mind creating an account, accepting licenses, etc. Still, creating a project in IntelliJ takes 2 minutes and we can play with the code straight away.
Adding a kotlin to desktop jupyter takes exactly one line using conda. In my Kotlin course I am starting with jupyter kernel/datalore for the first month and return to gradle-based project when people finally have some feeling of the language.
That’s assuming they won’t see this:
conda: command not found or this:
jupyter: command not found. But this is not really about installing things. Even if installation instructions are pretty simple (still, more complicated than a single line of code), this is discouraging if we have to follow instructions that mean nothing to us. The description of the above project is gibberish for a person who don’t use this kind of tools. What is kernel, what is a notebook, jupyter, conda, datalore, what does it mean to “Running cells” and do we really need to know all of this in order to simply run a hello world in Kotlin? I think this may discourage people to even try.
Is your course about first steps in a general purpose language or is the audience of the course profiled around data science?
conda install -c jetbrains kotlin-jupyter-kernel is exactly one line. Conda could be installed without command line at all.
As for the rest, people coming from Python and JS are expecting solutions like that. I personally also prefer to know what I am doing and not to rely on magic to do it for me. But for people coming to “try new things”, spending few days on setting up first gradle project is too much (even if experts tell them that it will save months of work later).
My course is a general (with some inclination towards scientific computing, but not “traditional” data science). It is designed so students without experience could attend. And my previous attempts show that starting with gradle on the first lecture is discouraging for them.
UPDATE: An analogy. When you teach children to speak, you do not teach them grammar right away. Yo start teaching grammar when they already can communicate.
I think we are talking about the same thing, but we consider different things to be “the grammar” No matter what’s the background of people, they most probably know what is IDE and what is a build system. They don’t need to know the whole gradle beast, but at least they know it is an alternative to makefiles, ant, yarn, setuptools or whatever people used so far. But if we say: “Install Jupyter kernel to use in notebooks”, then 50% of words in this sentence mean nothing to listeners. So they can only blindly follow instructions, without understanding what they’re actually doing.
Also, by using IDE they can simply click “create new project” and they don’t even need to understand how does it work internally. With notebooks they have to explicitly install conda, then use it to install the kernel, install jupyter, use jupyter… they are exposed to a lot of new stuff and new names to even start.
But well, you have an experience with teaching Kotlin, I don’t. So if you tested both approaches and notebooks were easier to follow for the audience, then apparently you are right
they most probably know what is IDE
Nope. Most of Python/JS beginners do not have experience with proper IDE. And definitely don’t know about build tools. I am getting some consulting money from moving Python prototypes to a production stage.
So they can only blindly follow instructions, without understanding what they’re actually doing.
Sadly, gradle setup (even from a template) is much more complicated than jupyter notebook setup. Also Python people usually are already familiar with Conda or at least Pip.
Also, by using IDE they can simply click “create new project” and they don’t even need to understand how does it work internally.
It does not work. You need to set up JDK, you need to check that gradle uses the same jdk as the project. You need to add an entry point to the program. The templates configures an application plugin, but there are a lot of things that could go wrong and it confuses people.
Notebooks are not panacea. They do not allow you to create a complicated program. But for beginners they are great. At some point there was an idea to create a simplified kotlin starter gradle plugin, which hides unnecessary clutter for “my first project”. It is a very good idea, but I do not have time for it right now. Please write to me in kotlin slack education channel if you want to participate.
I think you are facing the same difficulty you would if it was any other non interpreted strictly typed language…
IDEA is great, especially since you will want to debug things rather than logging everything just to find out simple thing. From my experience i dont know a single productive developer who uses terminal for java/kotlin… like its not vimable language, it can be done but you will never be productive.
What i would recommend not to try force your way and explore the new tools. You are not always going to write some simple programs, yes for simple hello world temrinal is totally fine.
Try using this video but do every single thing he does with him.
He generally makes good content for trying out new stuff or learning from scratch.
If you actually try the video and repeat everything he does and still feel the same way let me know i have few more optiosn in mind that could help but i think this is the best for someone who knows how to code and is not a complete beginner.