5 ms·
I've mentioned this a few places so I should probably write a post about it, but I did experiment with Lisp and shell (using femtolisp which is used to bootstra
by chubot 10y ago
I've mentioned this a few places so I should probably write a post about it, but I did experiment with Lisp and shell (using femtolisp which is used to bootstrap Julia). There is an obvious similarity in that they both have prefix rather than infix syntax. Tcl explored this design space pretty fruitfully as well.
The short answer is that the experiment didn't work very well. If you want a shell based around Lisp, the new "oh shell" is closer to that. It has homoiconic syntax, which I don't agree with. I talked about that a bit here:
http://www.oilshell.org/blog/2016/10/28.html http://www.oilshell.org/blog/2016/10/28.html
The oh shell is influenced by the es shell, which was almost literally a Lisp. There is also EShell (ELisp) on my Github wiki, and earlier Scheme shell. So without going into too much detail, I think the idea has been tried and it has failed not by accident, but for fundamental reasons.
That's not to say that Lisp isn't hugely influential. Julia and Elixir both have very Lisp-like metaprogramming which I hope to take some inspiration from. Without having tried it in detail yet, I think the lesson is that in 2017 you don't need homoiconity to have metaprogramming. And another lesson is that people like syntax (me included!)
The shell especially needs syntax because it will often be typed in a terminal as opposed to in an editor with help.
- taeric 10y agoI fully agree that lisp is not the answer for a shell. My question was only for your data literal syntax. Specifically, maps as association lists are very natural in lisp. So are many other structures. And JSON is easily seen as a crappy sexp. XML is easily a complicated sexp. Python's pickling is a complicated eval. And I get it. Some things have a more "natural" syntax that isn't postfix. Even in common lisp, the reader macro is often used for infix things. However, when the examples used are easily translated to sexps, and back, it makes me wonder why we don't think programmers could learn to write them.
- chubot 10y agoThe literal syntax is going to look more like JSON, like Python and JavaScript have. I don't see what's better about association lists (assoc (k v) (k2 v2)) vs. {k:v, k2: v2}. I mentioned in that blog post that Clojure introduced meanings for [] and {} in a Lisp, and I generally view that as a good thing. Also if that syntax is only used for data literals, and not code, then it loses the whole Lisp paradigm and I wonder why you would want that syntax.
- lispm 10y ago> Clojure introduced meanings for [] and {} in a Lisp Lisp was using [] and {} before in a lot of software. For example this is a data structure in Connection Machine Lisp called Xapping, basically a parallel hash table: {moe->"Oh, a wise guy, eh?" larry->"Hey, what's the idea?" curly->"Nyuk, nyuk, nyuk!"} Straight from the 80s. Scheme was using [] also many years before in the standard, programs and books.
- taeric 10y agoMy thought is that the confusion is most people are taught that lisp has no syntax. And that they should avoid the reader macro at all costs. Few, then, actually dive into large programs in lisp to see how real programs actually look. In this example, though, what was the advantage of the special syntax? (I'm assuming there was one. Just a lot of these parallel hash tables written in literal form?)
- lispm 10y ago> taught that lisp has no syntax Which is wrong. It's just that Lisp syntax looks and works a bit different. Especially there is a data syntax for s-expressions and the syntax for the programming language Lisp is defined on top of s-expressions. > And that they should avoid the reader macro at all costs. Common Lisp itself uses read macros for its implementation. Applications use them in various ways. > In this example, though, what was the advantage of the special syntax? Xappings were a central data structure in Connection Machine Lisp, thus it's not unusual that it had a printed representation.
- taeric 10y agoAgreed on your points. Especially that it has syntax. But look at the linked post upthread. I said "no" syntax, but that was me being admittedly lazy. Quote there was "Lisp is a language with little syntax". Which has me wondering why it has that general view with everyone. For the representation.. So this was not simply a literal syntax, but a serialization one. Which makes sense. And I can see why the serialization syntax is easily usable as a literal one.
- taeric 10y agoActually coming back to this. Eshell is an odd example for you to pick. I use eshell daily. Is my only shell, if I can get away with it. However, it is not a "lisp" shell. It is simply a shell buffer in emacs that is heavily integrated with many emacs features. Tramp, in particular, is nicely integrated such that I am beginning to forget scp and related notations. (That is actually a bad side effect.) Yes, you can inline lisp expressions. But, I constantly paste in standard shell exports and they work exactly as you would expect them to. Again, we agree that lisp is not necessarily a good shell language. Just, EShell seems a poor example to look at when making this argument. Edit: Where is the wiki you referred to? In particular, where you discuss eshell.