JPL: The JSON Programming Language (github.com)
from Kissaki@programming.dev to programming_languages@programming.dev on 10 Jul 19:16
https://programming.dev/post/33693028

Examples from the README

example 1

json [ { “let”: { “name”: “JSON”, “times”: 3 } }, { “for”: { “var”: “i”, “from”: 1, “to”: “times”, “do”: [ { “print”: { “add”: [“Hello “, “name”] } } ] } } ]

example 2

json [ { “import”: “system.jpl” }, { “print”: { “call”: { “now”: [] } } }, { “print”: { “call”: { “osName”: [] } } }, { “print”: { “call”: { “cpuCount”: [] } } }, { “let”: { “a”: 9, “b”: 4, “name”: “JPL” } }, { “print”: { “add”: [”\“a + b = \””, { “add”: [“a”, “b”] }] } }, { “print”: { “mul”: [“a”, “b”] } }, { “print”: { “div”: [“a”, “b”] } }, { “print”: { “mod”: [“a”, “b”] } }, { “print”: { “&”: [6, 3] } }, { “print”: { “||”: [false, true] } }, { “print”: { “gt”: [“a”, “b”] } }, { “def”: { “sq”: { “params”: [“x”], “body”: [{ “return”: { “mul”: [“x”, “x”] } }] } } }, { “print”: { “call”: { “sq”: [5] } } }, { “def”: { “greet”: { “params”: [“who”], “body”: [{ “return”: { “add”: [“\“Hi, \””, “who”] } }] } } }, { “print”: { “call”: { “greet”: [“\“JSON Fan\””] } } }, { “if”: { “cond”: { “<”: [“b”, “a”] }, “then”: { “print”: “\“b < a 👍\”” }, “else”: { “print”: “\“b >= a 🤔\”” } } }, { “for”: { “var”: “i”, “from”: 1, “to”: 3, “step”: 1, “do”: [ { “print”: { “call”: { “sq”: [“i”] } } } ] } }, { “print”: “\“All features in one! 🎉\”” } ]

example 3

json [ // 🚀 Welcome to JPL — JSON Programming Language! // Import system utilities for fun stuff { “import”: “system.jpl” }, // Print system info { “print”: { “call”: { “now”: [] } } }, { “print”: { “call”: { “osName”: [] } } }, { “print”: { “call”: { “cpuCount”: [] } } }, // Define a math function to square a number { “def”: { “square”: { “params”: [“x”], “body”: [ { “return”: { “mul”: [“x”, “x”] } } ] } } }, // Greet a user { “def”: { “greet”: { “params”: [“name”], “body”: [ { “return”: { “add”: ["Hello, ", “name”] } } ] } } }, // Declare variables { “let”: { “a”: 7, “user”: “Kapil” } }, // Use greet function and print { “print”: { “call”: { “greet”: [“user”] } } }, // Conditional message { “if”: { “cond”: { “>”: [“a”, 5] }, “then”: { “print”: “a is greater than 5” }, “else”: { “print”: “a is 5 or less” } } }, // Loop with break and continue { “for”: { “var”: “i”, “from”: 1, “to”: 10, “step”: 1, “do”: [ { “if”: { “cond”: { “eq”: [“i”, 3] }, “then”: { “continue”: true } } }, { “if”: { “cond”: { “gt”: [“i”, 7] }, “then”: { “break”: true } } }, { “print”: { “call”: { “square”: [“i”] } } } ] } }, // Fun ending message { “print”: “🎉 Done with curly braces and JSON fun!” } ]

#programming_languages

threaded - newest

EnsignWashout@startrek.website on 10 Jul 19:21 next collapse

The Who is this for? is amazing.

unmagical@lemmy.ml on 10 Jul 20:06 collapse

I can kinda see it for a DSL or a transit medium for carrying permitted commands from a client to be heavily assessed prior to executing on a server.

There are other ways to accomplish the same, but it’s certainly not the worst way to handle it.

MrPoopyButthole@lemmy.dbzer0.com on 10 Jul 20:12 next collapse

This is cursed 🫠

Semi_Hemi_Demigod@lemmy.world on 10 Jul 20:21 next collapse

Thanks I hate it

nieminen@lemmy.world on 10 Jul 22:23 next collapse

I don’t hate it… Would take this over python for sure.

PolarKraken@programming.dev on 10 Jul 23:54 collapse

As a (primarily) Python dev, I hope you use this and have a miserable time lol

nieminen@lemmy.world on 11 Jul 01:10 collapse

I accept this. Good day sir, sorry about your career 😉

PolarKraken@programming.dev on 11 Jul 01:39 collapse

Ouch! My dignity! Help!

bitcrafter@programming.dev on 11 Jul 01:07 next collapse

This is definitely not jank.

orhtej2@eviltoast.org on 11 Jul 09:54 collapse

{ “print”: { “add”: ["Hello ", “name”] } } ] } } ]

no (spot the variable)