https://pulumi.com logo
Title
s

steep-apple-98525

07/27/2022, 7:50 PM
Tried to use java for pulumi - it’s 3x amount of code comparing to other langs like Python|TS Kotlin could be so much better, but java code is generated in a way that can’t effectively utilize Kotlin features. eg example here https://www.pulumi.com/docs/get-started/aws/modify-program/ could look like
import com.pulumi.asset.FileAsset;
import com.pulumi.aws.s3.BucketObject;
import com.pulumi.aws.s3.BucketObjectArgs;

fun main() = Pulumi.run { ctx -> 
    // var bucket = ...

    // Create an S3 Bucket object
    BucketObject("index.html", BucketObjectArgs(
         bucket = bucket.getId(),
         source = new FileAsset("index.html"),
    ))
}
m

mammoth-salesclerk-61945

07/27/2022, 8:32 PM
personally I think kotlin is the best designed programming language I've ever seen just because of the concept of companion objects. We have an issue here and would love any thoughts that come to mind. https://github.com/pulumi/pulumi-java/issues/544
lol just saw your comment
s

steep-apple-98525

07/27/2022, 8:33 PM
Thanks I’ve already posted in this issue thread.
:thank-you: 2
Haha, main language designer used to say that companion objects was the biggest mistake he made while designing Kotlin🤣
m

mammoth-salesclerk-61945

07/27/2022, 8:35 PM
really??? static fields/methods is so hard to read. just group all of the state and methods together. gonna look it up
Your not supposed to use companion objects as a replacement for statics. You use package-level functions and extension functions. The only time you should ever use a companion object is for creating factory methods.
the reasoning is the best thing I've ever read. yeah static is bad.
s

steep-apple-98525

07/27/2022, 8:37 PM
yep:) You actually don’t need companion object to group static methods, just put it in separate file. If you want to scope them - extension functions 🙂
I think static is great:) I used to use functional programming with Kotlin(not in crazy Arrow way) and best way to do it is to have a bunch of static functions
m

mammoth-salesclerk-61945

07/27/2022, 8:40 PM
👌that sounds nice. pulumi is written in go so I can only really use structs.
s

steep-apple-98525

07/27/2022, 8:40 PM
Go is a great language except for Generics implementation🤣
m

mammoth-salesclerk-61945

07/27/2022, 8:50 PM
I'm still getting used to Go's approach. I've just discovered tags while typing out this message to complain about default values.
b

brave-dawn-64711

08/09/2022, 8:39 AM
cc: @steep-minister-28895
👀 1