https://kotlinlang.org logo
#getting-started
Title
# getting-started
r

Ray Rahke

02/25/2024, 7:42 AM
It looks like a lot of steps here are omitted. I just now created an empty kotlin project in intelliJ, added the App.kt file, and ran gradel jsRun in terminal, and it says
Task 'jsRun' not found in root project 'test'.
When I google how to setup multiplatform I just get android studio tutorials. I assume I need to add lines to my dependencies/plugins configuration file?
r

Robert Jaros

02/25/2024, 7:52 AM
Instead of creating a Kotlin/JS project from scratch you can try one of the K/JS frameworks. Check #kvision , #kobweb, #fritz2, #doodle, #compose-web. You can even find a drawing canvas demo in kvision examples repo - https://rjaros.github.io/kvision-examples/desktop/.
K/JS projects are KMP, so gradle is required, though.
e

ephemient

02/25/2024, 8:10 AM
it comes before the page you screenshotted and you should go through it first
r

Ray Rahke

02/25/2024, 10:39 AM
@Robert Jaros
I'm not sure what the Note means. Does that mean I can't develop using this while in a dev container?
I want to write all the code in GitHub codespaces
e

ephemient

02/25/2024, 10:46 AM
what makes you think that? you can configure the dev container to include the necessary tools. which you'd have to do even if you weren't using Kotlin.
r

Ray Rahke

02/25/2024, 10:47 AM
well im just not sure what else the note could mean
than "do this on your machine natively"
r

Robert Jaros

02/25/2024, 11:03 AM
Users reported some issues when developing kotlin/js apps on a network filesystem (e.g. nfs, samba), so I've added this note to the guide. Still it was years ago, so probably it's not as important anymore (edit: it was about dropbox folder: https://github.com/rjaros/kvision-examples/issues/5#issuecomment-498856329)
r

Ray Rahke

02/25/2024, 1:18 PM
Ah I didn't realize you were the creator. Thanks for building this, it looks nice
@Robert Jaros I download your kvision examples/template and run it in, seeing it work in my localhost. However when I open the project in vscode, I am getting import errors (the program still runs though). I don't see these errors when I open it in intellij. Is there some gradle configuration I need to do?
image.png
nvm, apparently an extension is causing it. fixed
Well, if I remove that extension (the kotlin extension by fwcd), i lose all intellisense highlighting...
r

Robert Jaros

02/25/2024, 4:03 PM
Unfortunately I don't use vscode so I can't help.
e

ephemient

02/25/2024, 4:04 PM
I believe you'll have better luck using Intellij. there are set up instructions for dev containers if that's what you want to use.
r

Ray Rahke

02/25/2024, 4:04 PM
Yeah fair points, but I am using this for youth education. I need it to run in a codespace, I can't realistically get kids to install intellij on their machines
r

Robert Jaros

02/25/2024, 4:04 PM
I would not be surprised to see that only typical jvm dependencies are supported in vscode. And Kotlin/JS is multiplatform. The dependencies are not simple jar's.
e

ephemient

02/25/2024, 4:05 PM
it's not the full intellij
in that mode, it's just a shell just hosting the gui, with the ide itself running in the container
r

Ray Rahke

02/25/2024, 4:06 PM
im not sure if the ide would show up then. codespaces is just a remote container
so you can't open winows or anything like that
but you can see web browsers running on localhost
thats why im opting to do web stuff
so kids can see their code effects easily while in a codespace
e

ephemient

02/25/2024, 4:07 PM
well that vscode extension just doesn't work with multiplatform (which js is), https://github.com/fwcd/kotlin-language-server/issues/11
r

Ray Rahke

02/25/2024, 4:08 PM
OK well then is there a way for me to turn off / ignore only these io imports?
no they are required
r

Ray Rahke

02/25/2024, 4:08 PM
the imports are required but I mean getting the language server to not show errors on
like in ts you have // @ts-ignore
e

ephemient

02/25/2024, 4:09 PM
by turning off the language server sure…
r

Ray Rahke

02/25/2024, 4:09 PM
but just on this file. My students are never going to look at this entry point anyway, it will exist just to boot up an html canvas
all the code they write will be in different files with native kotlin
e

ephemient

02/25/2024, 4:09 PM
if they're not going to look at it, why do you care if it's red?
r

Ray Rahke

02/25/2024, 4:10 PM
im pretty sure the left side bar explorer will be red
e

ephemient

02/25/2024, 4:10 PM
but honestly it sounds like you'd be better served by running your own compile server
like the Kotlin playground
r

Ray Rahke

02/25/2024, 4:11 PM
To work in a codespace in a JetBrains IDE you need: • A valid JetBrains license
I assuming this means a paid product
which is not going to work out on a per student basis. My teaching business is not an officialized school yet so I won't qualify for any free licenses.
r

Robert Jaros

02/25/2024, 4:11 PM
r

Ray Rahke

02/25/2024, 4:12 PM
thats the codespaces thing?
e

ephemient

02/25/2024, 4:12 PM
Two separate things
compile server and frontend are free yes
IDE license is free for educational use
r

Ray Rahke

02/25/2024, 4:12 PM
bit confused. what is the frontend?
e

ephemient

02/25/2024, 4:13 PM
that goes with the compile server
that has basically nothing in common with the ide
but it's much simpler if you just want your students to have access to Kotlin on the web
you can host your own with your own libraries etc.
r

Ray Rahke

02/25/2024, 4:14 PM
the playground website won't be sufficient. we'll be coding 2d games and stuff and having a live share feature is integral for coding togheter
e

ephemient

02/25/2024, 4:15 PM
that's just frontend work :)
r

Ray Rahke

02/25/2024, 4:15 PM
not sure what you mean. are you saying to code my own editor
e

ephemient

02/25/2024, 4:18 PM
I mean, yeah? there's freely available CRDT-capable editors out there
r

Ray Rahke

02/25/2024, 4:18 PM
ive worked in coding schools that have their own inhouse code editors before and it is just terrible
intellisense is just a must for kids
and i definitely can't take on a project like replicating vscode
with live share features and so on
e

ephemient

02/25/2024, 4:19 PM
but imo you either choose a real project setup, with intellij, or build your own frontend. I don't think there is a viable path for vscode unless somebody actually pays several more people to maintain that extension
r

Ray Rahke

02/25/2024, 4:19 PM
i don't think this language is ever going to become a contender
way too coupled to proprietary jetbrains stuff
extremely sad that the two prettiest languages currently are like this
(swift is the other)
e

ephemient

02/25/2024, 4:20 PM
the community ide and Kotlin plugin are open source
r

Ray Rahke

02/25/2024, 4:21 PM
but if you can't realistically use it then it doesn't really matter
in these use cases
r

Robert Jaros

02/25/2024, 4:25 PM
This is really a simple thing - if you want something to be good and free of proprietary stuff at the same time, you just need to find someone who will create it for free or someone else who will pay for it with his own money. There is no other way - everybody (companies incl.) just have to earn for living.
r

Ray Rahke

02/25/2024, 4:26 PM
I agree. That is what makes the situation sad to me
I don't think enough people care to do that, so it is unlikely to become general purpose to this extent anytime soon
The old kotlinc-js compiler did not require any dependencies / kmm stuff i think. Can't I Just use that to compile native kotlin code to js?
e

ephemient

02/25/2024, 4:30 PM
it is the same compiler that the Kotlin Gradle Plugin uses
r

Robert Jaros

02/25/2024, 4:30 PM
I suppose you can, gradle plugin do exactly this.
e

ephemient

02/25/2024, 4:30 PM
if you want to use it directly, you're effectively becoming KGP - you need to manage dependencies yourself
r

Ray Rahke

02/25/2024, 4:30 PM
will that also involve me writing import statements that vscode will error about
r

Robert Jaros

02/25/2024, 4:31 PM
But that definitely won't give you intellisense stuff ...
e

ephemient

02/25/2024, 4:31 PM
you will not have an easy time using any external libraries
r

Ray Rahke

02/25/2024, 4:31 PM
all I need is an html canvas and methods to draw shapes/images to it
all of the other code for students will be their own abstractions in native kotlin
when i try to use kotlinc-js compiler, it says deprecated. is there a setting i need to turn on to allow this?
Students need to be enrolled in an accredited educational program that takes one or more years of full-time study to complete.
yeah so the gateway approach couldn't be an option even if I could prove that I am an educator
e

ephemient

02/25/2024, 4:34 PM
possibly the command line isn't set up for the new ir backend, dunno
r

Ray Rahke

02/25/2024, 4:38 PM
Are we certain that there is no way to turn off / hush these errors on a per file / per line basis?
@Robert Jaros Where is the part that specifies to gradel that the application entry is in jsMain/kotlin/com/example/App.kt? I want to delete most of those folders and just have a src/App.kt, but I imagine that will break all of my gradle commands
i have not found anything specifying that path yet
does gradel just recursively look in sub directories until it finds a file with a fun main
r

Robert Jaros

02/25/2024, 5:46 PM
You should have main() function at the end of the App.kt file.
e

ephemient

02/25/2024, 5:56 PM
nothing to do with Gradle. main works differently on different platforms. on JVM, they all get compiled separately. Java chooses at runtime which main function to run on native, Kotlin needs to be told which main function to run on JS, Kotlin output contains calls to every main function in the module
but if you change the source set structure, then Gradle simply won't see and compile your code
3 Views