Re:Show HN: Programming is Now Two-Dimensional
by zimbatm on Wednesday June 21, 2017 @02:32PM
(#14606625)
Take the JSON encoding example. How does it know that 802 is a number? What if I want to have "802" as a string? Is it because visitors.mozilla has a fixed schema that it's value is an int or does it try to parse the string as an int first and then bails off back to a string if it doesn't work?
[ Parent
| on HN ]
Re:Show HN: Programming is Now Two-Dimensional
by drostie on Wednesday June 21, 2017 @02:43PM
(#14606747)
It's the latter. The JSON encoding example is actually a really bad example for this language because there is a huge class of JSON which it cannot easily be seen to encode, though you can probably make some exceptions. An example of the many undefined things would be:
{"abc def": ["123 456", 789, 101112, null, false]}
A better DSL for JSON would have to include actual data types or so, obj
abc def
arr
str 123 456
num 789
num 101112
null
bool f
...or so.
Re:Show HN: Programming is Now Two-Dimensional
by breck on Wednesday June 21, 2017 @03:09PM
(#14606969)
The paper takes the example from jsonETN. The first letter is the data type.
s: StringNode
n: NumberNode
a: ArrayNode
o: ObjectNode
b: BooleanNode
j: OtherNode
I just posted the repo here if you're curious. https://github.com/breck7/jsonetnIt used to pass every test, but I haven't touched it in a while and seems like a few lines need to be updated to bring it up to date with TN 4.0 (it's on 3.8 now). Handles the tricky JSON edge cases fine.
It would be great if someone wanted to maintain a solid JsonETN! I'm on to the Turing Complete ETNs nowadays, but a JSON ETN would be great and would let you use ETN tools to work with JSON.
Package.json for NPM should eventually switch to an ETN. Would provide noticeable benefits.
Re:Show HN: Programming is Now Two-Dimensional
by breck on Wednesday June 21, 2017 @03:25PM
(#14607074)
I do like the 3 letter word better than my 1 letter word. Nice job!
Re:Show HN: Programming is Now Two-Dimensional
by breck on Wednesday June 21, 2017 @03:23PM
(#14607062)
In the jsonETN I whipped up, the first word indicates the node type. n is number, s is string. Seemed good enough. Probably could be a better ETN for JSON if someone wants to give it a whirl. (For reference; https://github.com/breck7/jsonetn)