3 ms·
So, what about Lisp makes it great? I learned some Lisp in a CS course a while ago, and while it certainly seemed interesting, I didn't feel anything special (p
by personjerry 11y ago
So, what about Lisp makes it great? I learned some Lisp in a CS course a while ago, and while it certainly seemed interesting, I didn't feel anything special (perhaps I ought to spend more time with it?). Could a pro give me a short list of the biggest advantages, compared to C or Python?
- Synaesthesia 11y agoThe major advantages are extreme modularity and conciseness - you can write much shorter expressions than competing languages, like C, Python, Java etc. Macros are another big feature, which allow you to generate code easily and lastly the ease with which you can write self-modifying code (Homoiconic code) is often praised. Here are some more good answers to that question in a Stackexchange thread http://programmers.stackexchange.com/questions/9320/why-is-lisp-useful http://programmers.stackexchange.com/questions/9320/why-is-l.... edit: another one - http://stackoverflow.com/questions/2036244/whats-so-great-about-lisp http://stackoverflow.com/questions/2036244/whats-so-great-ab...
- progman 11y ago> you can write much shorter expressions than competing languages, like C, Python, Java etc. Exactly. For instance, consider Clojure, PicoLisp, Racket and Wolfram in http://rosettacode.org/wiki/24_game/Solve http://rosettacode.org/wiki/24_game/Solve.
- erik14th 11y agoI don't think you should choose the tool before you know the problem. Computer programming is a pretty vast domain. Lisp was probably a good tool for pg's startup. It was an ecommerce builder, most lisps are great at metaprogramming and creating DSL's. But his startup also used C and some other languages for different problems. What I think is great about Lisp is its idealistic simplicity. (function parameter1 parameter2) Everything is a list, pretty much everything that doesn't look like a list is just syntax sugar. My opinion is: unless you have a hard requirement, just use the language you already know and like. If you need to squeeze every tiny bit of performance, you might just need to use C++ or C. If your client wants a complete website in a ridiculous short amount of time, going for python,ruby or even php would be a sane choice. If your problem involves DSL's, metaprogramming or impressing people with how alien your code looks, check out some lisps, maybe Haskell.
- mbrock 11y agoLike Smalltalk, and to some extent Erlang, Lisp is an integrated programming platform that loads and reloads code while the system runs. Learning Lisp is not just learning a language grammar—it's learning a habit of development that is incremental and live in a way that's miles away from C coding and quite far from most typical styles of Python coding. You open your editor and connect to Lisp. Then you spend your time interactively defining functions, changing them, defining variables and inspecting them, and so on. This has consequences that you need to experience or see to understand how it plays out in practice. You tend to start coding in a different way. Paul Graham calls it bottom up programming. There are also synergistic effects with features like macros which enable radical kinds of convenient code generation / DSL-building, and conditional restarts which are like exceptions but fundamentally more powerful in a way that helps greatly when doing interactive coding, the multiple dispatch object system, the online documentation system, and so on and so on. Lisp is shock full of good ideas that are still absent from most other languages. But mere bullet lists aren't convincing, like in so many other situations. I wrote a web service in Lisp and just for convenience I wanted to have it incrementally recompile and reload its own source code on every request if the commit hash of the working tree had changed. This was a three line hack. I also generate a memory image every time I make a deploy, which means that the server starts in a finger snap including the whole runtime for all this dynamic stuff. Another advantage for me is the HyperSpec, an excellent hyperlinked reference of the whole standard language. It's an industrial quality manual written by literate professionals and so it's exhaustive, correct, and mostly unambiguous. I also simply enjoy how Emacs with Lisp is a world-class IDE. Right now I'm mostly offline with just slow pricey 3G but I made sure to install a bunch of Lisp packages and the HyperSpec and it's a joy to code using just Emacs and SBCL in the background. I can look up any documentation, semantic tab completion and argument list popups work perfectly since the editor is aware of all the code and the namespace rules and so on. I just don't know any other language that's so pleasant and fun to develop with. (After learning it, of course.) People call Lispers smug because they love the language more than any other, but I don't feel smug because I didn't come up with the thing, I just learned it and like it. I'm humbled by the engineering and quality of the tools and everything. It's not some weird academic obsession. It just makes me happy on a daily basis.
- ufo 11y agoThe obvious "killer feature" of LISP is macros. One concrete example where I saw the power of macros in a problem I was working with was when I saw how clean the parser generator library in Racket was. Instead of being like yacc, which uses an external DSL to define the parser, with its own syntactic conventions, the Racket parset generator is built with macros. The reason yacc has to be a metaprogram instead of just a library is because of how the semantic actions are "chunks of code" which you can't really represent in C but in LISP its easy to represent "chunks of unevaluated code" in your program, which lets you define the parser generator as an embedded dsl implemented via macros. Anyway, the reason I found this nice is that in Racket you can define your own macros to abstract over the repetitive parts of the grammar description. For example, in yacc you need to write multiple rules to describe a comma-separated list /* Use left recursion for efficient stack use and reverse at the end so the list is in left-to-right order */ arglist: arglistrevdeclsx { $$ = reverse($1); } ; arglistrev: /*empty*/ { $$ = NULL; } | arglistrev ',' arg { $$ = cons($2, $1); } ; and this pattern repeats for every other list you might have in the grammar. In yacc there is no alternative but to copy and paste this boilerplate but in Racket you could define a helper macro that would let you write grammars that look a bit like this: ;; create a non-terminal called arglist ;; that is a list of "arg"s, separated by commas ,@(makelist arglist ',' arg) ;; and this code can be reused: ,@(makelist decllist ',' identifier)