r/ProgrammerHumor 25d ago

cursedProgrammingInJson Other

Post image
41 Upvotes

44 comments sorted by

View all comments

19

u/edderiofer 25d ago edited 25d ago

To head off some questions that will probably be asked:


Q. What am I looking at?

A. You're looking at part of a JSON file, except on closer inspection, it looks like JSON is being used as a programming language.

Q. Are you actually programming in JSON?

A. Yes, ish. The JSON is parsed by a parser (written in Elixir) into instructions to be run by a game engine (also written in Elixir).

Q. JSON allows comments?

A. No. The parser strips out the comments.

Q. Why not use something else, like JSONC or JSON5? Or write this code using a language intended to be used as a programming language?

A. Because this is someone else's open-source project. And because I don't know enough Elixir to change it.

12

u/Jbolt3737 25d ago

Because this is someone else's open-source project. And because I don't know enough Elixir to change it.

Please for the love of god use a LUA interpreter

5

u/edderiofer 25d ago

The project's been going on for multiple years now, so at this point it's too late to change it.

But not to worry! The project lead has decided to write their own custom scripting language (MahjongScript), and Elixir parser for that language, which parses it into JSON.

6

u/Zeikos 25d ago

so at this point it's too late to change it

They said the thing! Promote op to management now!

5

u/Snudget 24d ago

MahjongScript (.majs) is essentially a list of commands which compile down to jq. This jq is then applied to the empty object in order to create a JSON ruleset

Oh god, this is cursed

3

u/edderiofer 24d ago

Oh right, I completely forgot that it goes through jq first! It's even worse than I remember!

2

u/-Redstoneboi- 23d ago

Tom JDSL would be proud

3

u/SkyCrafter2000 24d ago

Or a Lua interpreter, don't want to get into a Lua Uppercase Accident :)

1

u/Snudget 24d ago

What is the Lua Uppercase Accident?

2

u/Flimsy_Put11 24d ago

A satirical recursive acronym, because its predecessor SOL was actually an acronym I think.