5 ms·
That's like saying that a walker allows you to traverse a floor more "practically" than dancing.
by enduser 13y ago
That's like saying that a walker allows you to traverse a floor more "practically" than dancing.
- michaelwww 13y agoSo in your estimation all other computer languages are walkers compared to the beautiful dance of Lisp? I'm curious, maybe I really do need to learn Lisp.
- enduser 13y agoThat is my estimation. If you don't need performance or macros, Python and Ruby may give you a similar development experience. However, neither of those languages AFAIK allows you to redefine (let alone recompile to native code) functions at runtime.
- Jimmy 13y agoRuby is an extremely dynamic language, where you can redefine almost anything at runtime: def f() puts "f1" end f() if true def f() puts "true" end else def f() puts "false" end end f() This outputs: f1 true As for native code, apparently MacRuby [1] compiles to native code, although I've never used it, so I don't know the details of that claim. Can you give an example where redefining a function at runtime is a useful feature to have? I don't mean this as a challenge, I'm just curious. I like the extreme flexibility that dynamic languages provide, but it seems like the most dynamic features are mainly useful for library writers. [1] http://stackoverflow.com/questions/1972388/is-it-possible-to-compile-ruby-to-byte-code-as-with-python http://stackoverflow.com/questions/1972388/is-it-possible-to...
- Munksgaard 13y agoI don't think this is what enduser means. Lisp is the only language i know of where you can run a function such as (defun foo () (progn (format t "~a~%" (read-line)) (foo))) and then, while it is recursing, change the function to (defun foo () (progn (format t "~a and john~%" (read-line)) (foo))) recompile it, and have the behavior of your program change, while it is running. This is part of what makes lisp excellent for rapid prototyping. I'd give more examples, but I'm lazy, and it's been properly described elsewhere.
- Groxx 13y agoSeems pretty simple to me in Ruby. $ irb >> def go > puts "what" > debugger > go > end >> go "what" # stops on debugger line >> Object.module_eval "def go; puts 'wat'; end" >> continue "wat" There are of course other ways to do that, I just picked a simple one. You can break at lines / statements in files, so you don't need to include that "debugger" line. You can do something other than Object.module_eval. You can use something like Pry that would make this simpler and give you in-line source code, even after editing (IIRC). You can use something like Hijack to modify any running Ruby process - when you disconnect, your modified code will still be running. Lisp is not special in what it is capable of. Period. It's special because a) it's very old, and b) it's tuned for these features, in its own unique, minimalistic way. Yes, not all languages can do this (though you can do crazy things with GDB / debuggers in general, including using it as a REPL for compiled languages (really! it's not hard!)). But Lisp / the Lisp family are not even remotely the only ones which can.
- Munksgaard 13y agoThat is indeed very handy, but I would argue that there's a difference between running a program in a debugger and running it normally. With regards to the rest of your post: macros and data-as-code. Have you read this http://www.paulgraham.com/diff.html http://www.paulgraham.com/diff.html ?
- Groxx 13y ago"What Made Lisp Different" - all true. All intended as past tense. I never see claims that Lisp is unique because it has GC, for instance. Looking at the 'setf' macro, since you have to use 'defsetf', I don't see the difference between that and something in Ruby where you could do (errors aside): class Object def defsetf(name) $setf[self.class] = name end end def setf(class, *args) class.send($setf[class], *args) end class Whatever defsetf :set_something def set_something; end end # elsewhere... setf Whatever, instance, value Adding arbitrarily-complex ways to let you specify how to transform the arguments to a call is as easy as accepting a lambda instead of a symbol, recursive setf-ing[1] is just a lookup on the arguments and then nesting lambdas. I might be missing some deeper realization here though - defsetf seems pretty simple. Certainly the use could be complex, but I see nothing that implies that its implementation is unachievable, even with nearly-identical syntax, so what remains is library support and community. Again - specialization, not unique attribute of the language. As to "data-as-code", I think you mean the other way around? If not, eval. If yes, Ruby's reflection is I think insufficient without heavy modification like e.g. running a ruby interpreter in ruby to read its own source code and "reflect" with the AST that generates (though this is possible[2]). This is one spot where Lisp-likes certainly excel to a degree few outsiders achieve, but I'm sure I've seen outsiders, they're just not as fluent or efficient at running it. But few outsiders have real interest in optimizing it, or people label them as yet another Lisp-like, making the point sort of moot since it's part of the definition of being Lisp-like (to many). -- Macros in particular come up often, but I don't see anything really interesting about them. If you have the full AST available (a rarity, I'll admit), then it seems like a strict subset of runtime modification - it's just a self-eliminating runtime modification, done ahead of time for speed purposes. Except for maybe C-style macros, which (via a horrible syntax) can generate anything, not just valid code, which isn't always possible. [1]: (setf (sqrt something) number) => (set-sqrt something number) => (setf something (* number number)) in here: http://lists.warhead.org.uk/pipermail/iwe/2005-July/000130.html http://lists.warhead.org.uk/pipermail/iwe/2005-July/000130.h... found via here: http://stackoverflow.com/questions/267862/what-makes-lisp-macros-so-special http://stackoverflow.com/questions/267862/what-makes-lisp-ma... [2]: https://www.ruby-forum.com/topic/1108988 https://www.ruby-forum.com/topic/1108988
- michaelwww 13y agoHow is dynamically changing function definitions not a side effect or state change?
- Munksgaard 13y agoWhat do you mean? Remember, that lisp isn't inherently a pure functional programming language. On the contrary, it's a very versatile multi-paradigm language.
- michaelwww 13y agoI thought LISP was a functional language and I'm wondering how redefining a function at runtime is not a state change, but no matter, I'm reading Steve Yegge at the moment and his old take down of LISP which confirms my suspicions (don't you love it when you read something that does that ;-) http://steve-yegge.blogspot.com/2006/04/lisp-is-not-acceptable-lisp.html http://steve-yegge.blogspot.com/2006/04/lisp-is-not-acceptab...
- Munksgaard 13y agoThanks, that was a very interesting blog post. I feel like the comments add a lot of balance to the discussion (especially Pascal's, which Steve also mention in the blog itself). There's no doubt that lisp has its problems, because if not, it would be a lot more popular today than is the case. Do note however, that a lot has changed since Steve posted that blog entry, most notably is the rise of clojure, which offers solutions to a lot of the problems mentioned.
- michaelwww 13y agoRich Hickey is a very interesting language designer and maybe the "benevolent dictator" that Lisp needs. Clojure works on the JVM and .Net as well as emitting JavaScript, so I'll probably take the plunge with it. I also thought the Light Table demo was extremely interesting. Good stuff.
- jbooth 13y agoIf my goal is to get across the floor, I'd prefer a brisk walk.