Expected `kotlin` to have a format command to form...
# kotlin-toolchain
e
Expected
kotlin
to have a format command to format Kotlin source code. Non-configurable
format
command to avoid bikeshedding. Similar to
gleam format
which exists
So to avoid thinking of picking ktlint/ktfmt
j
Say no more, this is planned 😊 JetBrains is taking over the development of ktfmt from Meta, and making some changes. When this work settles, we'll include this as a
kotlin format
command
💡 1
❤️ 6
j
Nice! I suppose it will also be integrated with Idea? I wonder how different this is from ktlint from Pinterest.
e
My 2 cents, an anti-bikeshedding formatter needs to be either exceptionally good and much prefer readable structure/semantics over an 80-character limit, or should be applied to a language that is so inelegant that handing formatting over to a tool is almost always better than doing it by hand. The latter certainly doesn't apply to Kotlin Last I tried it (some time ago),
ktfmt
still produced obviously less readable/elegant formatting than doing it by hand. An illustrative (not real) example:
Copy code
// By hand
val handlers = mapOf(
    "create" to CreateHandler(repository, validator),
    "delete" to DeleteHandler(repository),
)
vs.
Copy code
// kfmt
val handlers =
    mapOf(
        "create" to
            CreateHandler(repository, validator),
        "delete" to DeleteHandler(repository),
    )
It can be quite frustrating when you've designed an easy to read API / DSL and have the formatter ruin the structure. Bikeshedding is of course very frustrating. Though if this formatter doesn't produce excellent results, I can also see that becoming a frustrating discussion between team members that get joy from creating readable code, and team members that get joy from delivering the next feature quickly. Ideally this formatter satisfies both.
j
I totally feel you. Part of the work currently being done is exactly about improving this type of things. cc @vsevolod.tolstopyatov
💜 1
v
yep, one of our decisions is not to follow the rectangle rule here!
e
That's really good to hear, very curious now to see what it'll be like 🙂