Add Kotlin and Scala examples. #2
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
java-gi/examples!2
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "main"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I've created both a HelloWorld example for Scala and a Calculator example for Kotlin. Due to the nature of Scala, it is impossible to write java-gi programs that follow proper Scala practices, as such I struggled to rewrite any examples except for HelloWorld. I may be able to write a wrapper library similar to the one for Swing in the future which would greatly improve Scala support.
Thanks for the PR! Can you please change the calculator example so that it will replace the current Java version? I don't think it's really useful to have two calculator examples.
I'd really like a Scala example app that is a bit larger. Why is it impossible to write java-gi programs that follow Scala best practices? Is the Gtk API not suitable or is it something specific in java-gi?
I'll change the PR once I have access to my laptop. As for the second question, it is just due to the nature of GTK. Ideally, Scala programs should be immutable, non-nullable, and functional, however GTK was intended for mutable, nullable, and object-oriented programming languages. This conflict of interest makes it necessary to use Scala like it was Java or Vala which isn't how the language was intended to be used.
Thanks! I like the image viewer example a lot. It's small, and easy to understand.
I have a few review comments, nothing spectacular.
One question remains: Do you mind if I change the references to "org.poach3r" into "io.jwharm.javagi.examples" for consistency with the other examples, and credit you in the examples' README file instead?
@ -0,0 +1,28 @@plugins {Missing a closing
"@ -0,0 +1,28 @@plugins {kotlin("jvm") version "2.0.21"}Please add the
applicationplugin & set the main class, sogradle runwill work, and suppress the warning about unsafe access:@ -0,0 +1,185 @@package io.jwharm.javagi.examplesChange this to
Gtk.styleContextAddProviderForDisplayto prevent a deprecation warning about theStyleContextclass.@ -0,0 +5,4 @@lazy val root = (project in file(".")).settings(name := "HelloWorldScala")Please suppress the "unsafe native access" warning:
@ -0,0 +7,4 @@name := "HelloWorldScala")libraryDependencies += "io.github.jwharm.javagi" % "gtk" % "0.11.0"0.11.1
@ -0,0 +1,14 @@ThisBuild / version := "0.1.0-SNAPSHOT"Please suppress the "unsafe native access" warning:
@ -0,0 +1,44 @@import io.github.jwharm.javagi.base.GErrorExceptionI think it's okay. Can you remove the comment?
I'm unsure if Github notified you of this, however I updated my branch with your requests.
Thanks!