Re:Why most of us won't be inventing little languages
by ohgodplsno on Monday April 17, 2023 @07:19AM
(#35599195)
Funny seeing that relatively old article, when you consider that JetBrains made good on that promise: Kotlin made writing DSLs actually pleasant.
This includes many things that Kotlin makes use of, like String.invoke(block: () -> Unit) which is both an extension on String instances and makes uses of Kotlin's "ability" to move lambdas out of parentheses if they are the last argument (so something like log(lazyString: () -> String), can be used as log({ "message" }), or log { "message" }, @DslMarker (to allow a String.invoke(() -> Unit) block in the form of "it should behave well", only inside the context of a StringSpec.), infix funs (+ is infix operator fun plus(), with some slightly specific language handling because it's extremely common, infix fun shouldBe). This is using Kotest (https://kotest.io/docs/framework/writing-tests.html), but other tools like Ktor, Skrape.it (https://github.com/skrapeit/skrape.it), and more: https://kotlinlang.org/docs/type-safe-builders.html
[ Parent
| on HN ]
There are no comments on this comment yet.