Kotlin

752 readers
1 users here now

Kotlin is a statically typed programming language for the JVM, Android, JavaScript, and native.

Subreddit rules:

Resources:

founded 2 years ago
MODERATORS
26
5
Kotlin 2.0.0-RC1 (github.com)
submitted 1 year ago* (last edited 1 year ago) by testeronious@lemmy.world to c/kotlin@programming.dev
27
28
 
 

I came across this post (and more like it) claiming extensions to be a good, or at least different, solution for mapping DTO's.

Are they though? Aren't DTO's supposed to be pure data objects? I've always been taught to seperate my mappings in special mapping services or mapping libraries like MapStruct and ModelMapper for implementing the good practice of "seperation of concerns".

So what about extensions?

29
 
 

I have a screen where I want a lazy-loading card of various items below some necessary information, all of which will scroll down. My initial approach was to nest the lazycolumn under the card which is nested under a Column with a calculated nested height based on the size of the calls list. However, I can't do that, and neither can I do the following.

@Composable
@Preview
fun mockup() {
    val calls = mutableStateListOf(Pair(1..418, 418 downTo 1))
    MaterialTheme {
        LazyColumn(Modifier.verticalScroll(rememberScrollState())) {
            item {
                Text("Text and some necessary UI elements")
                Slider(value = .418f, onValueChange = {})
            }
            Card(Modifier.fillMaxWidth()) {
                items(calls.asReversed()) {
                    Row {
                        Text(it.first.toString(), Modifier.fillMaxWidth(0.5f), fontWeight = FontWeight.Black)
                        Text(it.second.toString(), Modifier.fillMaxWidth(0.5f))
                    }
                }
            }
        }
    }
}

I found https://stackoverflow.com/questions/68182413/compose-lazylist-section-background, for which the only viable solution found was to hack a special composable widget so that when combined, it looks like a continuous card. Still, I want to see if there's a "proper way" of doing this...

30
31
 
 

I've had a long time fascination with Conway's Game of Life, and with the Sigbla APIs starting to stabilize I thought it would be fun to play around a bit and implement it as an example.

You can find the Conway example code here, and it should hopefully, even if you're unfamiliar with Sigbla, be fairly straight forward to understand.

It's using various core features, such as views, batching, transformers and cloning, with about 100 lines of code to get it all working. It's not really what I would envision Sigbla being used for, but it's a fun little example..

Conway's Game of Life in Sigbla

32
33
 
 

Looks like we have some extra support for Kotlin projects.

  1. http4k
  2. mockk

Each given $2,500 (which is chump change for a company like Target, but it's better than 0) from https://opencollective.com/target-tech

34
 
 

If you've played around with version catalogs enough, you will inevitably come to a point when you when you want to also use a BOM in your version catalog. Doing that just feels so...clunky? You need to declare the BOM in the libraries section, and then you have to declare each individual dependency from the BOM as a library (without a version). Alternatively, you can just skip using the BOM entirely and declare each dependency without the BOM. In either case it's not a great experience and definitely could use some improvement.

I wrote a Gradle plugin (in Kotlin) to automatically generate a version catalog from a BOM so you only have to specify it once, let me know what you guys think!

35
36
37
 
 

Hello developers!

I need some programming advice and I hope that I am not off-topic. I couldn't find a more relevant group in Lemmy.

I have a Gradle convention plugin (written in Kotlin) that needs a buildscript classpath. But I can't get it to resolve correctly in the project.

  1. If I add the buildscript classpath to the convention plugin and then apply the plugin to the project, it throws an error saying that buildscript is not allowed and the plugins section should be used instead.
  2. If I add the buildscript classpath to the project itself (although this doesn't feel right because the convention plugin should be already compiled), then it throws an error saying that the dependencies are not met (classpath not applied).

Any advice?

38
39
40
41
 
 

I've for a good while been using an excellent port of Scala's persistent data structures in my Kotlin code known as Dexx. This also works well from Java code.

However, while the project is what I would call feature complete, it's no longer maintained, resulting in outdated dependencies. It would also become problematic should any bugs or issues pop up.

Hence I decided to fork it as Sigbla PDS and tidy it up a bit, with v1.0 now released and ready for use.

42
43
 
 

I was using freecodecamp's tutorial on Kotlin but I was told that a video isn't a good way to learn a language. So I did the hyperskill course but it marks all of my answers as wrong even when the code works, and the subscription for more than ten questions a day is crazy expensive. I will be getting atomic kotlin soon but I still want to learn before it comes

44
45
46
 
 

At least they took the grant from the Kotlin Foundation... Let's wait for version 3 to be ready!

47
48
 
 
49
50
 
 

Seen this post by Donn Felker (!) on some other discussion platform and though I'd like to see the opinion of Lemmings about it.

view more: ‹ prev next ›