It looks like a lot of steps here are omitted. I j...
# getting-started
r
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
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
it comes before the page you screenshotted and you should go through it first
r
@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
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
well im just not sure what else the note could mean
than "do this on your machine natively"
r
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
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
Unfortunately I don't use vscode so I can't help.
e
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
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
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
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
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
well that vscode extension just doesn't work with multiplatform (which js is), https://github.com/fwcd/kotlin-language-server/issues/11
r
OK well then is there a way for me to turn off / ignore only these io imports?
no they are required
r
the imports are required but I mean getting the language server to not show errors on
like in ts you have // @ts-ignore
e
by turning off the language server sure…
r
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
if they're not going to look at it, why do you care if it's red?
r
im pretty sure the left side bar explorer will be red
e
but honestly it sounds like you'd be better served by running your own compile server
like the Kotlin playground
r
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
r
thats the codespaces thing?
e
Two separate things
compile server and frontend are free yes
IDE license is free for educational use
r
bit confused. what is the frontend?
e
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
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
that's just frontend work :)
r
not sure what you mean. are you saying to code my own editor
e
I mean, yeah? there's freely available CRDT-capable editors out there
r
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
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
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
the community ide and Kotlin plugin are open source
r
but if you can't realistically use it then it doesn't really matter
in these use cases
r
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
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
it is the same compiler that the Kotlin Gradle Plugin uses
r
I suppose you can, gradle plugin do exactly this.
e
if you want to use it directly, you're effectively becoming KGP - you need to manage dependencies yourself
r
will that also involve me writing import statements that vscode will error about
r
But that definitely won't give you intellisense stuff ...
e
you will not have an easy time using any external libraries
r
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
possibly the command line isn't set up for the new ir backend, dunno
r
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
You should have main() function at the end of the App.kt file.
e
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