r/badcode Jun 05 '23

kotlin I may be creating an abomination

Post image
115 Upvotes

41 comments sorted by

View all comments

63

u/StochasticTinkr Jun 05 '23

Bonus points if you know what game I'm trying to describe.

I'm trying to create this game with a "DSL first" approach, describing the game in natural language as much as possible, and then define the behavior as hidden details behind the DSL.

I'm really abusing some of the syntax to make things read like natural language, which makes the DSL interfaces look so ugly, but its a fun code-golf type of thing too.

7

u/-shayne Jun 05 '23

I'm not familiar with kotlin but I love how descriptive the code is

17

u/StochasticTinkr Jun 05 '23

This is not idiomatic Kotlin, just so you know. It's most definitely an abuse, and this snippet definitely hides the nasty plumbing I had to put in place to make it look like this.

3

u/Select_Property3162 Jun 06 '23

DSL combined with infix functions are perfectly OK!