by 21 · 9y ago · 0 comments
If one were to learn a functional language, is Lisp a good choice today? Or is Haskell more appropiate?
If you are hacking on stuff or doing it as a hobby, learn Scheme. Something like Chicken Scheme is good. Small concise language but a great scarcity of libraries. If you want a pretty ide for scheme or write your own scheme use Racket.
If you want production code in lisp with good library support use Common Lisp. Clojure is better because of better functional programming features than CL but debugging requires knowledge of Java as it runs on a JVM but the plus is you can seamlessly call java libraries which are numerous (more than what is in CL).
OCaml is functional programming with Objects. It it used where there is a need for performance like compilers with the advantage of a functional paradigm. But OCaml is a pain to work with for any Non Unix systems. F# is functional programming for dotNet. Then there is Scala which runs on JVM like Clojure and so has the same pros and cons except Scala is closer to OCaml and Haskell than to Lisp.(ML family)
Depending on your platform make your choice. OCaml is horrible for Windows. Haskell works. Scala and Clojure just need java so platform makes no difference. Schemes mostly have an interpreter for most platforms. Make your choice.
CL now has [shameless plug] an excellent functional collections library, FSet [0]. Using FSet greatly expands the range of algorithms that can easily be written in a functional style. It's been a while since I looked at Clojure, but my impression is that FSet has a substantially richer API, including a bag (multiset) type and many more operations.
I don't know exactly which Clojure features you have in mind, but I suspect that FSet makes CL at least as good for functional programming as Clojure.
It's an interesting coincidence - just yesterday I learned about FSet while searching for something else and thought it's interesting. However, after arriving at https://common-lisp.net/project/fset/Site/Project.html and reading through the page I left it without installing.
For the very wrong reason, too: I just couldn't find the source code. Obviously, I didn't try very hard, but on the project page (which looks a bit too minimal, btw, some CSS wouldn't hurt) I didn't find a link to the repo. I think it would be great if you added it on top of the project page.
My only complaint about FSet would be map default values; not necessarily the fact they exist, but (1) when using defaults, that two maps can compare equal even though they have different defaults, and (2) when not using defaults, the way they nevertheless intrude upon the map-union protocol, necessitating handling of otherwise unused default values (usually NIL).
But I love FSet when using CL. Thank you for writing and publishing it!
Agreed on both counts about map default values. I've been wanting to change how they work, but the change I have in mind would be incompatible. Here's what I'm thinking. Instead of every map (and seq) having a default, which defaults to NIL, we would distinguish maps with defaults from those without. Doing LOOKUP on a defaultless map at a key it has no mapping for would signal a condition (similarly for an out-of-bounds lookup on a defaultless seq). Then the defaultless versions could be used more conveniently with UNION (and COMPOSE, another place where I've tripped over this problem).
I was thinking that creating a map without supplying a default should give you a defaultless map, and that's how I wish I had done it from the beginning, but making it work that way now would break a lot of code. I could release it as a new major version (and call it "fset-2" in Quicklisp so people don't pull it down accidentally). Or, I could leave the existing constructor behavior unchanged and just add a new defaultless map (and seq) constructor. I think this is considerably less elegant, but it wouldn't break existing code. What do you think?
Lisp is a multiparadigm language. It has closures and higher order functions and uses them where they make sense; it also has a lot of imperative constructs, and a very sophisticated object system. They all work together and make Lisp a unique, interesting language. If you're only interested in the functional parts, you'd probably be happier with Haskell or Clojure.
Common Lisp has an implementation, ABCL, which runs on top of the JVM. Access to the Java ecosystem is a shared trait, not a difference.
Being a multi-paradigm language CL has a wealth of features That Clojure doesn't and they all play well together. Except for the type system and the class system.
For example, it has places and the ability to define your own setf forms.
Common Lisp makes iteration easy with the lisp macro.
Common Lisp has tagbody and gotos so one compile FSMs efficiently
Common Lisp has an object system were the semantics are describe using the same object system. So users can extend the object model according to their needs.
Clojure is designed to support one style of programming envisioned by its hypemaster. Rich Hickey is a brilliant person, and has done an excellent job designing Clojure, but
Clojure approach to 'user erros' is we don't guarantee to signal an error, we may do w/e.
By momentum you mean it is trending. We know mainstream programming is a pop culture, but we shouldn't encourage it by recommending one language over another based a FAD.
To further underscore this point, Common Lisp was created in 1984 incorporating elements of proven late 1970s Lisps like MACLISP; CL has been successfully used on spaceships and important complex systems, and the CL ecosystem continues to evolve and grow till today. The specification has been unchanged since the '80s and probably won't change any sooner, since the language is extensible and thus can evolve as the state of the art evolves.
CL is largely free from any kind of fad; everything that is built into the language is there either because (a) it has been proven to be necessary and proven to work correctly in the best way possible, or (b) was needed for backwards compatibility with earlier lisps.
Clojure is a new language and tries to be nice to newcomers, but it's difficult to compete against technology that has at least 33 years of continuous evolution. Also, if you need to interoperate Java classes with CL, there's ABCL which will do it nicely.
As a lisper said, "those who don't know Common Lisp are doomed to reinvent it."
Are you sure about that? RPLACA, RPLACD, NCONC, etc are present in the Lisp 1 Programmer's Manual dated March 1st, 1960: http://bitsavers.trailing-edge.com/pdf/mit/rle_lisp/LISP_I_P...
Or the more accessible explanation by Paul Graham http://www.paulgraham.com/rootsoflisp.html
There are only few primitives and no such things as RPLACA, RPLACD, and NCONC.
In 2017 the status of Lisp is about the same as it has always been only more accessible than ever given faster networks over which to download tools and to find documentation...e.g. the Racket ecosystem. And a person who starts exploring one of the Lisps today will learn as much or perhaps more (due to generally better access to diverse information about programming) than at points in the past.
My opinion reflects my bias, but in general I think Lisps are more accessible than Haskell because there has been more time to smooth over the rough edges related to the more significant underlying mathematical/theoretical concepts (lambda calculus versus type theory) and perhaps because lambda calculus is a bit more easily understood than type theory (or perhaps not). There's also a much stronger pedagogical tradition of Lisps as teaching languages (forty years or so) at the undergraduate level than with Haskell.
But in the end, why not both?
DrRacket looks a little dated in its vanilla configuration, but the layout of the editor / REPL parts can be changed around a bit, the color schemes swapped out. There's even a paredit mode for DrRacket. Overall, if I were somehow coding more exclusively in Racket, I could easily see using and extending DrRacket rather than my current emacs.
Common Lisp may be old, but it is extremely powerful relative to Clojure IMO. Clojure startup times are awful, it takes a very opinionated approach to programming (immutable data), its debugger is buggy, it produces unsightly error messages.
Sure, these problems may be fixed, but for me, I want a powerful tool that I can use now.
I've tried several new hot languages at the time (Rust, Dart, Clojure, Go).
I have come to a point in my career where I want to stick to highly complex, but slightly dusty artifacts defined by a standard( C++ & ANSI Common Lisp).
The SBCL implementation of common lisp does not give me all of the headaches of Clojure. I also don't have to restart the repl to load libs.
On using another dynamic language that isn't a lisp... Forget about it.
...Python maybe for machine learning, but I will probably just wrap cafe in CL or something.
PS. I am 25. Seems relevant to this discussion.
This made me LOL. I figured you were 50 or older based on the top of your post. You are wise to pick languages that are proven and "just work " though. I would say Go, while young, is incredibly stable and predictable.
Sadly the only Lisp environments that resemble in any way the old Lisp Machine or Xerox PARC ones are comercial.
Emacs is kind of ok with SLIME, but it still isn't the same as using Allegro Common Lisp[0] or LispWorks [1].
Just grab the latest release from https://github.com/slime/slime/releases Install atom-slime and sbcl (something like brew install sbcl on osx) Point atom to the directory you extracted slime to and then hit packages > slime > start
Most Common Lisp IDEs had a collection of these tools: Editor, Listener, Inspector, Debugger, Stepper, Preferences, ... Additionally there were various browsers, an interface builder, profiler, ...
The Lisp Machine IDEs had most of these tools, too. But they weren't only styled for development, but also for general use. Thus a Lisp Listener was not only a REPL, but also a general command line interface to interact with the machine. They were also more oriented towards group work and had additional features like versioned file systems, software versioning systems, databases, support for multiple programming languages (like C, Pascal, Ada, Fortran, Prolog, ...), source repositories, ...
Over the years (80s onwards) a multitude of these IDEs on Workstations and PCs were developed. CMUCL comes with one for X11 (debugger, editor, ...), Macintosh Common Lisp, ExperLisp, Procyon Common Lisp had one for Macs and Windows, Golden Common Lisp had one for Windows, Corman Lisp for Windows, SPE from SUN, Lucid CL had one (called XLT, their editor was called Helix), Star Sapphire Common LISP had one, Clozure CL has one for macOS (which one can run on a current Mac), ...
Then there were always IDEs based on GNU Emacs or XEmacs. Ilisp was once popular, Allegro CL has ELI, SLIME currently is the most popular with Sly as a fork. This is not so bad, since there are decent versions of GNU Emacs for Windows, Unix/GTk+ and macOS.
Of the commercial ones only Allegro CL (IDE for Windows and Unix/GTk+) and LispWorks (IDE Windows, Unix/Gtk+, deprecated for Unix/Motif, macOS) survived with regular releases.
Of the non-commercial ones SLIME/GNU Emacs is the most popular and it is also used by some users of Allegro CL and LispWorks. McCLIM lingers in the background with a collection of tools which would make an IDE, but it lacks one or more better GUI backends.
There are also a bunch of other ways to use Common Lisp with other editors (vim, atom, ...).
Now 'darkmatter' is another one. Let's see what people think from using it...
The IDE screenshots for Windows show off Windows XP.
Maybe they could improve their marketing message, but I doubt most wannabe Common Lisp developers are willing to pay for comercial tools, with enterprise prices, even if they had the best marketing of all times.
The IDE is based on their native GUI backend. Thus it picks up much of the looks of the current OS automatically (windows, buttons, dialogs, ...).
https://github.com/slime/slime/issues/286
If it has being left unaddressed because no one thinks it is enough of a problem. That is how free software works
Many hobbyists and professionals use Lisp to solve their problems and make money.
IDEs are in a sorry state. If you're an Emacs user, you'll be happy. Otherwise, unless you spend hundreds of dollars for a professional IDE, you won't have much. Editing Lisp requires a good IDE.
Is there anywhere that one can read about such cases? Would be interesting to read about both how well they are doing and what sort of apps they use Lisp for making.
Also, aren't there any other OSS or free Lisp IDEs outside of Emacs? Or are they all crap?
Really for a good experience you just need something with Swank support and ability to highlight matching parens. Eclipse would even work, though I haven't tried any of the plugins for it. IDE features like introspecting values, breakpoints, tracing, profiling, stepping, recompiling are all part of the Common Lisp standard so you'll get them for free just by running the Lisp REPL in a terminal. What you use on top of that is really just making it more convenient to interact with the Lisp environment than typing everything in by hand. I like slimv with its auto-paren-infer stuff turned off (matching and rainbow parens are fine for me) but I've also just used a tool that uses two screen sessions to send data back and forth without using Swank (or even Lisp, I use it sometimes for Python but that's trickier because I can't just send a class to (re)define if I have newlines between methods and I can't casually change my namespace).
And [Portacle](https://shinmera.github.io/portacle/) is an Emacs shipped with SBCL, Slime and Git in a portable and multiplatform way, so it's straightforward to begin with.
Just grab the latest release from https://github.com/slime/slime/releases Install atom-slime and sbcl (something like brew install sbcl on osx) Point atom to the directory you extracted slime to and then hit packages > slime > start
The Common Lisp Cookbook
https://news.ycombinator.com/item?id=14661239
262 points by macco 9 days ago | 184 comments
Not so much about CL vs. functional languages, but it gives a sense of the current scuttlebutt about CL.
Is Lisp a good choice (for a functional language)?
If you want to program in stricly functional and only functional style, being totally forbidden of incorporating side effects into your functions (except via Monads), and want to feel a sensation of "types are checked and enforced everywhere, thus I can sleep happy", then go try Haskell.If you want to be free to do whatever you need to do, to apply the paradigm you need at every moment -- be it procedural, imperative, logic, aspect-oriented, object-oriented, functional... then Common Lisp is for you. If you need the full power because you know what you are doing, then Common Lisp is for you.
Status of (Common) Lisp in 2017
- You can have a fully configured, ready to use, CL environment in under 5 minutes by downloading and executing Portacle. No configuration needed, it just runs and gives you Emacs, SLIME, Paredit, SBCL, Quicklisp and other nice tools.- Free books and resources are available, for example "Practical Common Lisp"
- Package ("system") installation is damn easy with Quicklisp. Download package from the web, compile it and load it... with only one command: (quicklisp:quickload <package name>)
- There are libraries out there for anything you need: REST services, web frameworks (many), JSON, machine learning, math, anything really.
- There are many ANSI-compliant CL implementations out there, most of them free: SBCL, CLISP, Clozure CL, SICL, ABCL, LispWorks (commercial), Allegro CL (commercial)
- Interoperability with C is easy with CFFI (there are other ways as well)
etc etc. Lisp in 2017 is better than ever! - Interoperability with Java is easy with the ABCL implementation.
- IMO the documentation state is not great, but it's being worked on. (it's said to be non-existent for Haskell :p ) CL has many books to learn from (CL recipes of 2015 being the more interesting to me http://weitz.de/cl-recipes/), but the online documentation is not brilliant. Often the web page isn't attractive at all, not every project provides good documentation, the "official" websites are bad (cliki, others). It's being fixed by https://github.com/CodyReichert/awesome-cl, http://lisp-lang.org/, https://lispcookbook.github.io/cl-cookbook/, http://quickdocs.org/ and http://phoe.tymoon.eu/clus/doku.php
- one can feel the language is dating. It has IMO too many weird semantics: no map and filter but map which takes a second argument telling the type of the structure or mapcar and others, remove-if[-not], etc. Creating hash-tables is too verbose and not consistent, et. That all a lot more are fixed in CL21 http://cl21.org/ (its wiki https://github.com/cl21/cl21/wiki). CL21 also offers more functional-oriented stuff like shorter lambdas, lazy sequences, generic functions, or string interpolation, regexp literals, and more. It's a bit under-documented, but its wiki is ok.
- web dev in CL is another topic. I sugest https://stackoverflow.com/a/42838145/1506338 but what's doable now is very elegant.
- CL has a big ecosystem, we can use Emacs/Vim/Atom, Portacle is straightforward is portable and thus straightforward to use (https://shinmera.github.io/portacle/),…
The fact that it runs on the JVM and makes it easy to interop with existing Java code makes it practical to integrate in many organizations already using this stack.