Tried to use java for pulumi - it’s 3x amount of c...
# java
s
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
Copy code
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
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
Thanks I’ve already posted in this issue thread.
🙏 2
Haha, main language designer used to say that companion objects was the biggest mistake he made while designing Kotlin🤣
m
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
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
👌that sounds nice. pulumi is written in go so I can only really use structs.
s
Go is a great language except for Generics implementation🤣
m
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
cc: @steep-minister-28895
👀 1