Hi friends! We have a Kotlin JVM project which cur...
# multiplatform
p
Hi friends! We have a Kotlin JVM project which currently uses MVEL as expression language. One of our long term goals is to provide native executables. Therefore we are migrating to Kotlin multiplatform, but the MVEL dependency seems to be still a blocker for us. Does anybody know of any expression language in which we could use? Any feedback is welcome. Thanks! 😉
e
what kinds of expressions? simple arithmetic, there's a few libraries out there. more complex expressions that operate on outside types, doesn't sound doable without reflection, which would limit you to JVM
consider writing the expressions in the Kotlin code itself, perhaps using a DSL, to be compiled together with the rest of your code?
p
We use conditionals, method calls and variable assignments at runtime, so it's quite tricky. 🙂 We might consider moving this specific part to a JVM-only component and then implement the remaining ones in multiplatform. Thanks for the feedback!
b
On my project I use ANTLR to generate a parser for each target language (JS/Java/Swift), and have all the platforms simply delegate to the same visitor class written in Kotlin. In this way, all the logic and grammar are shared.
p
Thanks for the insight, Brian! It's a good idea. However, for our specific scenario, it would be hard to formalize a grammar. And we would need to include the types and their members into the grammar as well.
b
I still recommend ANTLR. Since we last spoke, my company is officially shipping the ANTLR expression parser in our Android, iOS (native) and Javascript apps, all in Kotlin. Works very well for us.
p
Thanks, Brian! We are still discussing some blockers at the moment, but we will consider it. In the meantime,
luak
might be an interesting approach to follow. Thanks again! 😉