https://kotlinlang.org logo
Channels
100daysofcode
100daysofkotlin
100daysofkotlin-2021
advent-of-code
aem
ai
alexa
algeria
algolialibraries
amsterdam
android
android-architecture
android-databinding
android-studio
androidgithubprojects
androidthings
androidx
androidx-xprocessing
anime
anko
announcements
apollo-kotlin
appintro
arabic
argentina
arkenv
arksemdevteam
armenia
arrow
arrow-contributors
arrow-meta
ass
atlanta
atm17
atrium
austin
australia
austria
awesome-kotlin
ballast
bangladesh
barcelona
bayarea
bazel
beepiz-libraries
belgium
benchmarks
berlin
big-data
books
boston
brazil
brikk
budapest
build
build-tools
bulgaria
bydgoszcz
cambodia
canada
carrat
carrat-dev
carrat-feed
chicago
chile
china
chucker
cincinnati-user-group
cli
clikt
cloudfoundry
cn
cobalt
code-coverage
codeforces
codemash-precompiler
codereview
codingame
codingconventions
coimbatore
collaborations
colombia
colorado
communities
competitive-programming
competitivecoding
compiler
compose
compose-android
compose-desktop
compose-hiring
compose-ios
compose-mp
compose-ui-showcase
compose-wear
compose-web
confetti
connect-audit-events
corda
cork
coroutines
couchbase
coursera
croatia
cryptography
cscenter-course-2016
cucumber-bdd
cyprus
czech
dagger
data2viz
databinding
datascience
dckotlin
debugging
decompose
decouple
denmark
deprecated
detekt
detekt-hint
dev-core
dfw
docs-revamped
dokka
domain-driven-design
doodle
dsl
dublin
dutch
eap
eclipse
ecuador
edinburgh
education
effective-kotlin
effectivekotlin
emacs
embedded-kotlin
estatik
event21-community-content
events
exposed
failgood
fb-internal-demo
feed
firebase
flow
fluid-libraries
forkhandles
forum
fosdem
fp-in-kotlin
framework-elide
freenode
french
fritz2
fuchsia
functional
funktionale
gamedev
ge-kotlin
general-advice
georgia
geospatial
german-lang
getting-started
github-workflows-kt
glance
godot-kotlin
google-io
gradle
graphic
graphkool
graphql
graphql-kotlin
graviton-browser
greece
grpc
gsoc
gui
hackathons
hacktoberfest
hamburg
hamkrest
helios
helsinki
hexagon
hibernate
hikari-cp
hire-me
hiring
hongkong
hoplite
http4k
hungary
hyderabad
image-processing
india
indonesia
inkremental
intellij
intellij-plugins
intellij-tricks
internships
introduce-yourself
io
ios
iran
israel
istanbulcoders
italian
jackson-kotlin
jadx
japanese
jasync-sql
java-to-kotlin-refactoring
javadevelopers
javafx
javalin
javascript
jdbi
jhipster-kotlin
jobsworldwide
jpa
jshdq
juul-libraries
jvm-ir-backend-feedback
jxadapter
k2-early-adopters
kaal
kafka
kakao
kalasim
kapt
karachi
karg
karlsruhe
kash_shell
kaskade
kbuild
kdbc
kgen-doc-tools
kgraphql
kinta
klaxon
klock
kloudformation
kmdc
kmm-español
kmongo
knbt
knote
koalaql
koans
kobalt
kobweb
kodein
kodex
kohesive
koin
koin-dev
komapper
kondor-json
kong
kontent
kontributors
korau
korean
korge
korim
korio
korlibs
korte
kotest
kotest-contributors
kotless
kotlick
kotlin-asia
kotlin-beam
kotlin-by-example
kotlin-csv
kotlin-data-storage
kotlin-foundation
kotlin-fuel
kotlin-in-action
kotlin-inject
kotlin-latam
kotlin-logging
kotlin-multiplatform-contest
kotlin-mumbai
kotlin-native
kotlin-pakistan
kotlin-plugin
kotlin-pune
kotlin-roadmap
kotlin-samples
kotlin-sap
kotlin-serbia
kotlin-spark
kotlin-szeged
kotlin-website
kotlinacademy
kotlinbot
kotlinconf
kotlindl
kotlinforbeginners
kotlingforbeginners
kotlinlondon
kotlinmad
kotlinprogrammers
kotlinsu
kotlintest
kotlintest-devs
kotlintlv
kotlinultimatechallenge
kotlinx-datetime
kotlinx-files
kotlinx-html
kotrix
kotson
kovenant
kprompt
kraph
krawler
kroto-plus
ksp
ktcc
ktfmt
ktlint
ktor
ktp
kubed
kug-leads
kug-torino
kvision
kweb
lambdaworld_cadiz
lanark
language-evolution
language-proposals
latvia
leakcanary
leedskotlinusergroup
lets-have-fun
libgdx
libkgd
library-development
lincheck
linkeddata
lithuania
london
losangeles
lottie
love
lychee
macedonia
machinelearningbawas
madrid
malaysia
mathematics
meetkotlin
memes
meta
metro-detroit
mexico
miami
micronaut
minnesota
minutest
mirror
mockk
moko
moldova
monsterpuzzle
montreal
moonbean
morocco
motionlayout
mpapt
mu
multiplatform
mumbai
munich
mvikotlin
mvrx
myndocs-oauth2-server
naming
navigation-architecture-component
nepal
new-mexico
new-zealand
newname
nigeria
nodejs
norway
npm-publish
nyc
oceania
ohio-kotlin-users
oldenburg
oolong
opensource
orbit-mvi
osgi
otpisani
package-search
pakistan
panamá
pattern-matching
pbandk
pdx
peru
philippines
phoenix
pinoy
pocketgitclient
polish
popkorn
portugal
practical-functional-programming
proguard
prozis-android-backup
pyhsikal
python
python-contributors
quasar
random
re
react
reaktive
realm
realworldkotlin
reductor
reduks
redux
redux-kotlin
refactoring-to-kotlin
reflect
refreshversions
reports
result
rethink
revolver
rhein-main
rocksdb
romania
room
rpi-pico
rsocket
russian
russian_feed
russian-kotlinasfirst
rx
rxjava
san-diego
science
scotland
scrcast
scrimage
script
scripting
seattle
serialization
server
sg-user-group
singapore
skia-wasm-interop-temp
skrape-it
slovak
snake
sofl-user-group
southafrica
spacemacs
spain
spanish
speaking
spek
spin
splitties
spotify-mobius
spring
spring-security
squarelibraries
stackoverflow
stacks
stayhungrystayfoolish
stdlib
stlouis
strife-discord-lib
strikt
students
stuttgart
sudan
swagger-gradle-codegen
swarm
sweden
swing
swiss-user-group
switzerland
talking-kotlin
tallinn
tampa
teamcity
tegal
tempe
tensorflow
terminal
test
testing
testtestest
texas
tgbotapi
thailand
tornadofx
touchlab-tools
training
tricity-kotlin-user-group
trójmiasto
truth
tunisia
turkey
turkiye
twitter-feed
uae
udacityindia
uk
ukrainian
uniflow
unkonf
uruguay
utah
uuid
vancouver
vankotlin
vertx
videos
vienna
vietnam
vim
vkug
vuejs
web-mpp
webassembly
webrtc
wimix_sentry
wwdc
zircon
Powered by
Title
d

Dron Bhattacharya

02/16/2023, 10:12 AM
IMPORTANT FEEDBACK Coming from a javascript and python background, I am facing great difficulty in using Kotlin. The same for my friends too. 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.
s

Sam

02/16/2023, 10:19 AM
You might find it useful to install the command-line compiler. Once you have that, you can also look at kscript which will let you run simple .kts scripts from the command line. For larger applications, a typical workflow would involve using Gradle as a command line tool to build, run or package the application.
I can definitely understand your frustration; I find that using an IDE feels like a very walled-in experience and doesn’t provide much exposure to the actual command line tools. I’m not sure I’ve ever actually used
kotlinc
directly, despite being a Kotlin programmer for years…
r

Robert Jaros

02/16/2023, 10:22 AM
d

Dron Bhattacharya

02/16/2023, 10:22 AM
I have used C++ for some time too (not an expert though). But for Kotlin, if I have to learn things in this way by asking people ad trying hard to find out how to do what I am trying to do, I am extremely disappointed...
s

Sam

02/16/2023, 10:23 AM
It is strange that even the official docs on Kotlin scripting use IntelliJ so heavily 😕. I would have thought that the whole point of scripting was to shed a lot of that weight
d

Dron Bhattacharya

02/16/2023, 10:25 AM
Not even a single tutorial or documentation exists that does not use IntelliJ for Kotlin. Even for writing a hello world program and creating an executable from it, you need IntelliJ. This is a heartbreaking reality I cannot accept as I am really loving the language.
s

Sam

02/16/2023, 10:26 AM
makes mental note to write a blog on how to use Kotlin without IntelliJ
g

Goetz Markgraf

02/16/2023, 10:28 AM
You don’t need IntelliJ: Just install gradle and you can create a project with
gradle init
. Then grab your favorite editor and start coding. Personally, I side with @Sam and think that an IDE is a great help even for a small mini-program. About the “executable”: In a JVM-Environment, you don’t create Executables in the sense of a binary that can be called from the shell directly. The nearest to that is a fatJar, meaning a JAR-File that contains every depedency and library. You can then call this with
java -jar <name of jar-file>.jar
.
a

Adam S

02/16/2023, 10:29 AM
d

Dron Bhattacharya

02/16/2023, 10:30 AM
@Adam S I have done this.
a

Adam S

02/16/2023, 10:31 AM
JetBrains is researching how to improve newcomer’s experiences https://kotlinlang.slack.com/archives/C0922A726/p1675353698143759
d

Dron Bhattacharya

02/16/2023, 10:33 AM
@Goetz Markgraf If I want to create a platform-specific binary. For example, I have created a command program that I want to use for myself in the
.exe
format of Windows. Is it possible with Kotlin?
g

Goetz Markgraf

02/16/2023, 10:34 AM
There is kotlin/native that can compile kotlin code to a binary. Or you can use GraalVM to create a binary from a fatJar-File.
s

Sam

02/16/2023, 10:34 AM
By default the Gradle application plugin will make you a package that can be started with a Windows
.bat
script. You might need an extra plugin to package that up into an
.exe
but it’s definitely possible
a

Adam S

02/16/2023, 10:37 AM
I think it’s important to keep in mind that Kotlin has multiple targets (JVM, JS, Native, WASM). So some of your questions will depends what the Kotlin target is. Kotlin/Native can produce `.exe`s (although the suffix is
.kexe
on Mac/Linux for some reason). For Kotlin/Native most of the docs don’t use Gradle or IntelliJ, just the command line. https://kotlinlang.org/docs/native-command-line-compiler.html. On Kotlin/JVM, there’s not really a thing as an
.exe
. Java programs just aren’t like that, instead they’re packaged into
.jar
files, and you have to run them using
java -jar test.jar
(There is GraalVM, but that’s quite advanced.)
g

Goetz Markgraf

02/16/2023, 10:40 AM
@Adam S the
,kexe
ending is only added on linux and macos. On windows its a
.exe
.
For Kotlin/native you have to keep in mind that you can use the Kotlin standard library but not the java library. For example, there is no
File
class in Kotlin/native.
d

Dron Bhattacharya

02/16/2023, 11:08 AM
Just as an example... Problem: Most of the time, we tend to create/store new random files like images,
.txt
files,
pdf
files on the desktop and soon the desktop becomes a mess. (Windows OS) Goal: I want to write some code to keep my Desktop clean and uncluttered. The program basically detects the files and puts them in the right places and deletes unnecessary files according to the configuration I made in the code. The program runs periodically in the background to do these jobs. So, I need to create a
.exe
and then schedule it as done in Windows. Is, Kotlin the right choice for these things? I love programming and in my spare time, I am always coding something and sharing it with friends. So can Kotlin be used for this kind of general-purpose programming???
g

Goetz Markgraf

02/16/2023, 11:10 AM
You can certainly do this with Kotlin. I am not sure if you really have to have an
.exe
-File because the Windows Scheduling can surely also run
.bat
-Files. I recommend using “normal” Kotlin (meaning Kotlin/jvm), what most of documentation is using. You can package your program however you want and create a
.bat
-File to run it.
d

Dron Bhattacharya

02/16/2023, 11:16 AM
one more thing... if I am creating this kind of program in Kotlin, do they use a large portion of system/hardware resources slowing the OS...
l

Laertes Moustakas

02/16/2023, 11:35 AM
I don't think it will in your case. It depends on the application, but a periodic job accessing the file system shouldn't need a lot of resources. That being said, a native application typically consumes less resources than a JVM application.
g

Goetz Markgraf

02/16/2023, 12:02 PM
… but in the native version, @Dron Bhattacharya has to write the file IO functions for himself. Of course, there are examples on the internet for that.
r

Robert Jaros

02/16/2023, 12:20 PM
Building a Kotlin/JS app with node api and compiling it to an executable with pkg is probably also an interesting option.
k

Kirill Grouchnikov

02/16/2023, 1:33 PM
“This is a heartbreaking reality I cannot accept as I am really loving the language” If you’re going to fight your way against a tide, you’re certainly not going to enjoy swimming in there. Kotlin has been created and evolved by the same company who is very much in the business of writing world-class IDEs. I find it quite straightforward that they would lean on the IDE aspect of it for the tutorials and really the whole experience, no matter how big or small your project is. It’s going to be quite frustrating if you are planning to swim against this tidal current, or if you’re going to be expecting to have the exact same things that you know from other programming environments.
c

Casey Brooks

02/16/2023, 2:23 PM
I’ll also add that different programming languages/environments have different goals, which very much shape the developer experience using that language. Python and JS were both created to be scripting languages, which is why that workflow works very well. But Java (and thereby Kotlin) was created first and foremost for large-scale production applications. The JVM simply was not intended to be a great platform for scripting, so any scripting experience with Java or Kotlin is not going to be as optimized as with other scripting languages. As Kirill said, you’re only going to cause pain for yourself trying to use a tool in a way it’s not optimized for. Yes, Kotlin supports scripting and theoretically can do all the same stuff as Python/JS, but it’s just not optimized for that, and the workflow for creating small utilities like this is not going to be as easy as you might expect given your background. And even outside the Gradle/IntelliJ workflow itself, the language is statically typed, which inherently makes it tricky to use without IDE help, especially if you’re not deeply familiar with the language. But the same thing is true in the other direction. Python/JS are difficult to scale up to huge, enterprise-scale applications because they were optimized for smaller tasks. Again, not that it can’t be done, there great are enterprise-grade frameworks for both those languages like Django or Express, but there’s a reason that Spring and .NET dominate the server-side tech stack. That’s what those languages were optimized for.
So my suggestion is this: start with the basic, most widely-used application of a language/framework first before trying to use it for more non-standard ways. For Kotlin, that means sticking with IntelliJ and Gradle targeting the JVM, and only once you’re very familiar with that workflow does it really make sense to start using it for scripting. I understand the frustration of needing to use an IDE for small tasks, especially if you’re on a lower-powered computer, but the frustration of trying to work without it will be even greater.
d

Dron Bhattacharya

02/17/2023, 6:28 PM
When I go through any Kotlin tutorials, I have never come across the concept of
building
I don't know why. But it seems pretty important though. I have done the Kotlin sample project from Gradle Docs.
c

Casey Brooks

02/17/2023, 6:36 PM
“building” is more-or-less synonymous with “compiling”, and it’s not just a Kotlin term. To “create a build” is to compile the source code, link it with dependencies, and produce an artifact that could be shipped to production and run by the end-users. Kotlin typically uses Gradle as the tool “to build” (verb), which produces “a build” (noun). JS/TS uses WebPack, and uses the same terminology. Same with iOS and XCode (which is both an IDE and the “build tool”). C++ uses Make, etc.
j
d

Dron Bhattacharya

02/17/2023, 6:40 PM
Currently, I am seeing the Kotlin-docs tools section.
k

Klitos Kyriacou

02/20/2023, 9:39 AM
Another use of the term "build" is when "building" a String (or a List or other immutable collection), and that's something completely different.