5 ms·
Correct me if I'm wrong but it seems you roughly get "lisp-ness" by taking any textual data format and defining a programming language syntax in terms of that d
by shrimpx 3y ago
Correct me if I'm wrong but it seems you roughly get "lisp-ness" by taking any textual data format and defining a programming language syntax in terms of that data format. I could make a JSON-based language that looks like:
[
// define some_fun(x) => let y=2;let z=y*3;return x+z
{"some_fun": [["x"], [
{"y": 2,
"z": ["*", "y", 3]},
["+", "x", "z"]
]},
// call it
["some_fun", 100]
]
Here I'm using JSON dictionaries to bind variables, and lists for everything else (instruction sequences, argument lists, etc.). Now I can quote stuff to define JSON data, or otherwise define programs.
I'm not a lisper but it seems what's special about lisp is it defines its programs in a generic data format.
- zdragnar 3y agoYou're essentially describing homoiconicity: https://en.wikipedia.org/wiki/Homoiconicity https://en.wikipedia.org/wiki/Homoiconicity
- shrimpx 3y agoThanks!
- Jtsummers 3y ago> I'm not a lisper but it seems what's special about lisp is it defines its programs in a generic data format. One of the things that still makes Lisp special. It makes metaprogramming "easy" in contrast to metaprogramming in almost every other language out there. The other big thing is its high degree of interactivity and dynamic capabilities.
- matthewn 3y agoSimilar argument from this lengthy but enjoyable essay: https://stopa.io/post/265 https://stopa.io/post/265
- kazinator 3y agoBut JSON is somewhat impoverished in that only has floating-point numbers, strings and a handful of symbols (true, false, null, ... ?). The most obvious thing lacking from the point of view of interpreting in a Lisp-like way is an ergonomic syntax for symbols. People have experimented with computation in JSON, pretty much like how you have it; but it's lame to work with. Nobody wants to write quotes around basic identifiers like "+". And it is inefficient, to boot. Interning of symbols is a key advantage of Lisp, and it was there in 1958 already; so by using JSON this way, you're regressing before that. Lisp converts symbols into small values, which are atoms. Two or more occurrences of the same symbol are the same atom. An atom is a small word-sized quantity. Often a pointer, but not necessarily so; it could be a numeric index into a table of objects. Anyway, it is very efficient to test whether two atoms are the same object.