4 ms·
Embedded in this response is a consideration for how programming languages handle data. In Java, if you have a config file, does that file use Java syntax? No.
by evdubs 3y ago
Embedded in this response is a consideration for how programming languages handle data. In Java, if you have a config file, does that file use Java syntax? No. What is that Java file written in? Likely XML. Can you write XML literals in Java? No. Wouldn't it be nice to:
XMLElement el = <html><body>Hello World!</body></html>;
In JavaScript, we have probably the closest to Lisp in this regard with JSON. You can define JSON literals in your JavaScript code; config files like package.json are written using this object notation. If you want to work with, say XML, there are libraries to convert your XML to JSON and you can take it from there.
But, JSON is limited. How do you define dates for your datatypes? Probably use a string. In Lisp, you can use a string or have some (date year month day) form. How do you represent rational numbers? Maybe you'll risk using floating point or you'll just go with a string. Lisps have rationals built in or you could roll your own with (rational numerator denominator). So your JSON
{
'name': 'John Doe',
'birth-date': '1970-01-01',
'account-balance': '1000.01'
}
can become
(user #:name "John Doe" #:birth-date (date 1970 1 1) #:account-balance 100001/100)
When Lispers need to interact with JSON, they convert it to S-expressions. When Lispers need to interact with XML, they convert it to S-expressions. Wouldn't it be nice if the other languages had syntaxes that made you want to define data using that language's syntax and not JSON or XML?
- jen20 3y agoVisual Basic .NET actually does have XML literals [1] - one of the few reasons to use it! [1]: https://learn.microsoft.com/en-us/dotnet/visual-basic/programming-guide/language-features/xml/xml-literals-overview#simple-literals https://learn.microsoft.com/en-us/dotnet/visual-basic/progra...
- brabel 3y agoScala also had it, but seems they replaced it in Scala 3 with a more general concept[1] as everyone thought it was a bad idea to special case XML (why XML, not JSON or something else?). [1] https://docs.scala-lang.org/scala3/reference/dropped-features/xml.html https://docs.scala-lang.org/scala3/reference/dropped-feature...
- Firadeoclus 3y agoThis makes sense but to be honest, how I'd really like to represent data to go along with code is as a table or a tree (i.e. presentation/interaction more like a spreadsheet).
- evdubs 3y agoA Lisp response to this might be: tables and trees are just special forms of lists. You can work with tables, trees, maps, vectors, etc. and if they can support list operations (filter, map, reduce, first, last, etc.) then they can be treated like a list and you can do those operations. You can still build IDEs that will show you tables of variables at runtime and graphs of your tree structures.
- draegtun 3y agoIt's worth looking at Rebol [1], a language that is also homoiconic which was influenced by Lisp, Forth, Self & Logo and had a big influence on JSON too! user: [name: "John Doe" birth-date: 1970-01-01 account-balance: $1000.01] [1] https://en.wikipedia.org/wiki/Rebol https://en.wikipedia.org/wiki/Rebol
- kazinator 3y ago> had a big influence on JSON too! It might have influenced Javascript, but the entire idea in JSON is to have a data exchange syntax that can be plonked into Javascript as a literal. That requirement leaves room for no other influence, pretty much.
- draegtun 3y agoHere's a video where Crockford mentions Rebol (and others) being an influence on JSON - https://www.youtube.com/watch?v=-C-JoyNuQJs&t=1233s https://www.youtube.com/watch?v=-C-JoyNuQJs&t=1233s I've seen it mentioned on Rebol chatter that Crockford approached Carl Sassenrath (creator of Rebol) to open-source & use Rebol prior to creating JSON. So having a Javascript literal wasn't on Crockford's mind at that point. NB. Rebol was closed sourced until 2012.