4 ms·
For a person who loves Scala, Haskell and Python and have heard a lot about LISP (and even uses a DIY LISP notation to serialize some stuff in some projects) ye
by qwerty456127 9y ago
For a person who loves Scala, Haskell and Python and have heard a lot about LISP (and even uses a DIY LISP notation to serialize some stuff in some projects) yet didnt't have time to actually study LISP yet... In what parts can LISP or Scheme be better than Haskell as a programming language from the practical point of view? I.e. why should I choose to code a program in LISP rather than in Haskell or some other functional language?
- mark_l_watson 9y agoI have been programming Lisp languages since about 1980, and in the last six years have become a Haskell enthusiast (but still learning). For what it’s worth, my opinion is that Haskell is a Lisp. When I am writing pure Haskell code (algorithms, not touching the external world) working in Emacs, it feels like my workflow is very similar to using Common Lisp or Scheme. If you like Haskell, then you have found a good home.
- pjmlp 9y agoYou should check the paper "Why calculating is better than scheming", from Phil Wadler.
- moocowtruck 9y agoi have and i'm still not seeing why calculating is better than scheming. it also lays into lack of lazy evaluation, but haven't we determined over time in haskell that lazy by default has it's own tradeoffs? Could you maybe break it all down for us ? thanks
- kqr 9y agoWhen you want there to be a lot of moving parts that are easy to swap out and change and develop as the end user, while using it, pick Lisp. When you want the design to be fixed and predictable and easy to develop for the developer, before the program runs, pick Haskell.
- gekkonier 9y agoIf you want to compare Lisps to Haskell I would think of "not so strictness" in functional programming or programming paradigm. Lisp is not only functional, it has much more to offer and that is in some situations more suitable. Choose the right tool, etc. etc. If you like Lisp for specific tasks then exactly this would be a good reason to do so.
- sifoo 9y agoLisp trades some of the strictness and static typing of Haskell and Scala, and the convenience of Python I guess; for more raw power. You won't really have a clue what macros are capable of before you see it yourself, I wholeheartedly recommend using Let Over Lambda (https://letoverlambda.com https://letoverlambda.com) as a guide. The other side of the coin is that you'll spend the rest of your days waiting for mainstream languages to catch up, but that's true of Haskell as well to some extent.
- macintux 9y agoThanks for the pointer, just ordered a copy.
- aidenn0 9y agoNote that let over lambda is ... let's say controversial among lispers. I think it is very good at teaching how to write macros, but very bad at teaching what macros one ought to write. It's a bit like that bit about making ruby accept bare words in Wat[1]. The fact that lisp lets you do the things that LoL presents is fine, learning how to do this is good. If you actually do this in production code, that's bad. 1: https://www.destroyallsoftware.com/talks/wat https://www.destroyallsoftware.com/talks/wat (45 seconds in)
- AKrumbach 9y agoI don't know about "won't have a clue what macros are capable of before..." -- there are quite a few use cases for macros which can be described easily to any programmer, even those who never used Lisp. I would like to believe it would suffice to say "macros in Lisp allow you to fully extend the the language with new primitives and abstractions in a way that no other language does", but examples are always helpful. Lisp has a macro called setf, which takes any call which gets a value -- whether from a local function variable, or a class, to an array or hash table entry -- and converts it to the corresponding setter call. (If you define your own value places/types, there are also functions to make setf aware of how they work, so this isn't restricted to just some defined set of features in the language. Anything that holds a value in Lisp can be "setf" to a new value.) There are a couple of other "big" Lisp macros in the language standard like with-open-file (which ensures a file is closed once control flow exits the body), loop (does pretty much what it says on the tin: provides whatever looping method you might want), or handler-case (try-catch style error handling; yes, Lisp allows for other methods). Or how about the example I recently saw in a cryptography library. Since a lot of cryptographic algorithms use integer math modulo some giant number, this library defined a macro "mod-n" which took a base and some Lisp code, and re-wrote the code so the common integer math functions (addition, multiplication, etc.) would only return values "modulo {base}" --that is, return only values between 0 (inclusive) and base (exclusive). This meant their modulo math code looked (nearly) the same as normal, just standard arithmetic functions. This wasn't a very large macro either: only around 10 lines long (and about half of that being the list of operator replacements).
- didibus 9y agoPractically I'd say Interactive Development and Metaprogramming facilities would be the top two reasons. Interactive Development let you iterate ideas really fast, and allows an ease of exploration that's refreshing and can really help to learn how to use a library, an API, etc. Metaprogramming lets you add whatever functionality you want. It can help reduce boilerplate code down to a minimum. Those are the two features where I think it distinguishes itself.
- js8 9y agoMy journey was from Python to (Common) Lisp to Haskell (which I decided to go with instead of Clojure). I got (almost instantly) sold on Haskell when I learned how to interpret the same code in different ways (http://www.haskellforall.com/2012/06/you-could-have-invented-free-monads.html http://www.haskellforall.com/2012/06/you-could-have-invented...) and that the types do not get in the way in Haskell as much as they do in C#/Java whatever. I think Lisp is interesting, but I doubt you will find many parts that are "better" (more powerful or succinct) than Haskell. Lisp is primarily about freedom that macros give you. However, the two huge use cases for macros, selective evaluation, and representing code as data (different interpretations of the same code), can be naturally done in Haskell. There are some other minority use cases for macros, but in my current view they do not justify the cost of losing the type system. I now think that macros are an evolutionary dead end. They are powerful, but they are hard to integrate with the type system. It's kind of surprising that progress (IMHO) in programming comes from (selective) restriction of freedom. And that's why Lispers will probably strongly disagree with me... Anyway, if you like Python, you might like Lisp. The core language is more elegant, and much more powerful, but the libraries are generally less polished. Somebody recommended Let Over Lambda to show what macros can do, I don't disagree but I would recommend reading On Lisp first, it covers more traditional uses of macros.
- pjmlp 9y agoLisp and Smalltalk are the precursors of modern IDEs. Many of the ideas presented by Bret Victor can be seen on those environments Allegro Common Lisp and LispWorks are the surviving examples how they used to be.
- aidenn0 9y agoThe language malleability of Common Lisp is quite nice. If you like Haskell, you will miss the types. SBCL (the most popular open-source common lisp implementation) does what is quite a lot of compile-time type checking and inference for a lisp, but very little compared to Haskell. Common Lisp has found a very high local-maxima for macros. If you knew all of common lisp except defmacro, I could explain how it works to you in about 3 sentences. This is an absurd lever for how much power it gives you. This is also where many "lisp-in-foo" implementations fall down. They (rarely) use the scheme macro system (which has a very complicated algorithm behind it) or more commonly implement the common lisp system, but without the features of common lisp that make it reliable. A major exception to this rule is Clojure. I'm not a huge clojure fan, but every single place in which it differs from common lisp, it is immediately apparent that Rich understood why it was done in common lisp, and has very good reasons for doing it differently. It's one of the very few lisp branches that I can't find Chesterton's fences[1] in. I don't think this is because there's anything wrong with lisp, but rather that it's very very easy to write a any lisp dialect, which means you get a lot more bad ones. You need to do a lot more work to write a bad 1: https://en.wikipedia.org/wiki/G._K._Chesterton#Chesterton's_fence https://en.wikipedia.org/wiki/G._K._Chesterton#Chesterton's_...
- grzm 9y agoThank you for the link to Chesterton's fence! What a wonderful way of framing reformation/reconstruction/refactoring.
- aidenn0 9y agoI do love that story, it really sums up one bit of knowledge that older and wiser people tried to impart to me. Anything that takes work required some form of motivation. It is very likely that the person that did the thing you think to be wrongheaded was a lot more like you than different from you. The times when experience gets in the way is when the reasons for decisions are no longer true, but you fail to revisit those decisions. My favorite example for this is the Jet engine: Radial-flow compressors create far too much drag to create efficient engines. Axial flow compressors generate too little compression in each stage to create lightweight engines. Therefore jet engines are not practicable. The above paragraph was true around 1930. Improvements in metallurgy, machining, and compressor design eventually made axial-flow compressors much lighter and more efficient. I can easily imagine a more experienced engineer telling a less experienced one something like "I looked into that and the math just doesn't work out." One can't fault the more experience engineer because one doesn't have time to reexamine all of the underpinnings for all of the knowledge one has about the world on a regular basis. Though I do recall hearing a few people (including Feynman) who would keep a journal of problems they failed to solve. Any time they would learn a new technique or about a new technology they would flip through and see if there was anything in it that could be solved with the new information.