https://kotlinlang.org logo
#utah
Title
# utah
m

Michael Clark

06/30/2021, 4:54 PM
I recently read this article https://www.raywenderlich.com/2780058-domain-specific-languages-in-kotlin-getting-started. I haven't made use of DSLs for any of my projects, but am going to give it a go this week for a simple use case.
r

RayeW47

07/01/2021, 8:42 AM
@Michael Clark a lot of the work i do in kotlin (i do not work for any company or anything, just personal projects for the most part) involves DSLs and they can be really nice to use! they are also good for integrating in to a scripting environment you may have set up 🙂 it makes it easy for users who do not know programming too well to get more in to the content writing of any systems you may be programming for
m

Michael Clark

07/02/2021, 3:17 PM
this is awesome, they look really useful! for my use case, I want to use them to drastically simplify some of the complex builders we have on large POJOs, and hopefully gain some good will with the Java devs.
@RayeW47 I'm curious to know how they might work in a scripting environment. By scripting environment, do you mean .kts?
r

RayeW47

07/02/2021, 7:42 PM
@Michael Clark the syntax in specific is very easy to fit in to a kotlin scripting environment, so yes a .kts file! There are script configurations you can set up either in the jetbrains IDE settings or via gradle (which is a lot more buggy at the moment), to have certain configurations (e.g. implicit imports, an implicit wrapper class around the kts file, etc) when in certain kts files (like
.script.kts
or
.whatever.kts
, etc.) and I feel like DSLs are a perfect fit for script files
m

Michael Clark

07/02/2021, 7:48 PM
interesting. thanks!
19 Views