28 ms·
How to write Common Lisp in 2017 – an initiation manual
- ConanRus 10y agoShort answer: don't do that, use Clojure instead. It doesn't have any of listed problems.
- azrazalea 10y agoNope, it has new problems that are (IMO) worse.
- sigjuice 10y agoI have dabbled in Common Lisp over the years and am quite comfortable with it. I know nothing about Clojure. What are the problems with Clojure? I am just curious. Thanks!
- macco 10y agoUsually, people tend to see the following problems: * no native support, hosted language (js java) * unreadable (java) tracebacks * no tail call optimization These are not my problems with Clojure, but then things I often read. I am interested in Common Lisp because of the native support.
- markc 10y agoI prefer loop/recur to TCO. You know exactly when you are, and are not, in tail position (which can be a bit obscure) and the compiler won't let you recur from non-tail.
- lispm 10y agoloop/recur handles only a tiny part of TCO. TCO means all calls in tail position are optimised, not just the self-recursive ones. Personally I find loop/recur ugly. It's a partial hack around the lack of TCO. Though I prefer looping statements like Common Lisp's ITERATE, whose design I like a lot... https://common-lisp.net/project/iterate/doc/index.html https://common-lisp.net/project/iterate/doc/index.html
- SomeHacker44 10y agoTo add to what @macco said: No reader macros. Apparently this extraordinarily powerful tool violates a religious principle with the inventor Rich Hickey.
- emidln 10y agoIf it was powerful enough to warrant use, someone would hack it onto tools.reader. It's obvious where it would go. For some reason, nobody has bothered with this. Likely because the reader already has programmable data (via tagged literals) and anything beyond that results maintaining your own special reader. I haven't yet encountered somewhere that I'd have used reader macros for that wasn't better solved by using data literals or tagged literals. There might be some random place where I need syntax beyond clojure's data literals, but I'm far more likely to use a combination of data literals + tags. If absolutely required (it hasn't been yet in 5 years of daily production usage), I could simulate custom grammar using clj-antlr and a macro. If, for some unknown reason, I needed a custom non-sexp grammar embedded in my lisp that I wanted to serialize exactly and then read back in the same syntax (probably because I hate myself and/or my team), I could hack it tools.reader. tldr; you have reader macros if you want them. Nobody wants them who uses Clojure day to day. If they did want them, they could trivially extend tools.reader themselves.
- azrazalea 10y agoVirtually nothing requires reader macros. That doesn't mean they aren't useful. Personally if I wanted reader macros in clojure I wouldn't bother implementing them because it wouldn't be worth the pain to me. However, if clojure had them I/libraries would likely make good use of them.
- emidln 10y agoIt has a reader as a library. It's entirely possible for you to change its lookup map to a defmethod and go to town altering s-expressions for arbitrary syntax if you wish. You're not hacking a new reader here, you'd refactoring something that probably should have been a generic method to begin with into one. Nobody has bothered with this because it's not useful to anyone, as far as I can tell. People who want non-data syntax write it with clj-antlr/instaparse (which are very easy to use) and use a macro when they want to interleave it into their code. These universally end up with a data-based AST that is readable and printable.
- yarrel 10y agoIn addition to the other problems described, Clojure just breaks the value of Lisp's syntax. Common Lisp does have its irregularities but code littered with Java imports and square brackets might as well just use C formatting and be done with it.
- Zak 10y agoThe primary value, to me of Lisp syntax is that code is represented as data structure literals which can be manipulated as easily as any other data structure prior to execution. Clojure has that; it just comes with literals for a few more data structures and uses two of them, vectors and maps in the syntax of built-in forms.
- quickoats 10y agoEmacs Lisp also has syntax for vectors.
- lispm 10y agoWhy would arguments in Lisp (= "list processor") form a vector? Is it so that the syntax of vectors can be used? Then it has technical consequences. Is it because of technical issues (arguments are vectors internally) and thus it can be exposed in the syntax, too? Or both?
- Zak 10y agoI think the motivation for making the sequence of arguments in function/macro definitions vectors instead of lists was primarily syntactic - to make them look different from the body. They're definitely vectors internally though.
- int_19h 10y agoHow do square brackets break the syntax? Aren't they just syntactic sugar for (vector ...), exactly the same as ' is syntactic sugar for (quote ...)? And imports, obviously, are just special forms. It's not like Lisp doesn't have others. It's still an S-expression, so why is it problematic?
- brudgers 10y agoIf you know Common Lisp reasonably, you'll probably have some insight into Clojure, e.g. Leiningen is a system definition facility; seq is an extension of sequences; and multimethods are generics much like methods. I'd say Clojure stands on the shoulders of giants. There are some Lispy things that Clojure does out of the box that are more Lispy than than Common Lisp does out of the box, e.g. lists and other seq's as functions in the function position of an x-expression. There are things Clojure will not do such as reader macros. Clojure's syntax is a bit different, but generally reads cleaner in the same way one might say a font reads cleaner. YMMV.
- lispm 10y ago> lists and other seq's as functions in the function position of an x-expression. Makes code more difficult to read. I consider this a language design error. I had that on the Lisp Machine 30 years ago (example callable arrays, ... - maybe even Maclisp in the 70s had it), few people used it and it did not make it into Common Lisp. Common Lisp was designed such that for the programmer and for the compiler the first element of a Lisp form is easily recognisable as a function: it has to be a symbol naming a function or an actual lambda expression. Pays back it code maintenance over time... > but generally reads cleaner in the same way one might say a font reads cleaner. I think it reads cleaner in the way PERL code is read cleaner.
- brudgers 10y agoPersonally, I find code easier or harder to read in the same ways I find prose easier or harder to read -- it depends on the author's ability to tell a story and the story the author is trying to tell and my interest in hearing the telling. Seq's as functions are sometimes more readable to me for the same reasons code that uses reader macros may be more readable to me (even though reader macros may do away with normal s-expression syntax entirely). But again, mileage varies.
- int_19h 10y agoArrays are functions, by definition. They relate inputs to outputs.
- quickoats 10y agoFor me, it is firstly a computing resource issue. I dont have much RAM or processing power for clojure to be creative or productive. It is like playing in a sandbox in the rain rather than the sunshine. Which leads into my second thing about it as well as scheme for me, it feels to inspire toward too much symmetry in a place that is supposed to be asymmetrical.
- platz 10y agoSorry, there is a temporary ban on speaking about clojure in OP's thread. This discussion is about Common Lisp.
- baldfat 10y agoI am sure there are plenty of people who have a preferred Lisp. It does drive me nuts how if there is a post on R the top comments are people touting Python as being the bigger player in statistics and data science (Which it isn't) or a ton of other languages. PS I perfer Racket :)
- sleibrock 10y agoCame here to share my love for Racket. Parameterization, custodians, threading, channels, message inboxes, and the packaging tool is also great. I just recently published my first application to the Racket package repo, and I found it to be the least painful experience so far.
- mehaveaccount 10y agoR is pretty pointless though. Unless you want to rewrite everything between prototyping in R and real deployment with a real language, you are better off writing in Python.
- baldfat 10y agoThat right there is what I am talking about. I make a point and people have to attack that that the language is pointless when it is the number one language in that domain, which just happened the last two years. Why would you ever have to rewrite the code? Python isn't faster and has less function then R and if you want you can just drop a few lines of Python in a cell of a Notebook. I like Python and its a good choice but R is a great language that in fact that Python's pandas library is trying to make a R equivalent.
- cat199 10y agoR is useful only more in pure analysis - interfacing to other systems and dealing with application/control logic is not it's strong point, so unless you are embedding R into a larger project (e.g. R batch scheduler), if you need these features, you'll likely need to rewrite.
- 10y ago
- kahrkunne 10y agoBut it has many other problems.
- agentultra 10y agoIf you're so inclined I'd make it a "living document" that gets updated as the state-of-the-art evolves. Writing CL in 2017 is not likely to change rapidly in the next decade but even compared to what writing CL was like 8 years ago it has changed enough. Nice job.
- azrazalea 10y agoIt is. https://github.com/articulate-common-lisp/articulate-common-lisp.github.io https://github.com/articulate-common-lisp/articulate-common-...
- pnathan 10y agoYes, send in PRs if things significantly change! It's a stable ecosystem, but things do improve over time. Things like examples would be quite useful.
- ntdef 10y agoAh yes this is exactly what I needed. I was recently trying to start a CL project but I had trouble wading through all the outdated material, especially with regards to including external packages. Thanks for putting this together!
- brudgers 10y agoI'm going through a similar process. My caution is that 'package' has a very technical meaning in Common Lisp that is at odds with how 'package' is used in other languages (and a bit at odds with how the author uses it in their tutorial). A package in Common Lisp is a set of interned symbols. In Common Lisp, systems are more in keeping with an ordinary understanding of packages...but combined with the idea of a build system just for fun. ASDF is a way for managing systems (but it is worth keeping in mind that Common Lisp does not have any 'official' understanding of systems). ASDF is pretty much a de facto standard by consensus. Quicklisp is a 'package manager' in the sense that it will go out and fetch a dependency from a repository. But what it fetches is a system: it is usually not a package in Common Lisp's technical sense. From the Quicklisp FAQ: How is Quicklisp related to ASDF? Quicklisp has an archive of project files and metadata about project relationships. It can download a project and its dependencies. ASDF is used to actually compile and load the project and its dependencies. ASDF is a little like make and Quicklisp is a little like a Linux package manager. On the other hand, Common Lisp is very stable around ASDF and SLIME and QuickLisp. ASDF was started in 2002. Quicklisp in 2005. SLIME in 2003.
- pnathan 10y agoHmmm. I tried to convey the idea, without getting too bogged down in the details that don't per se matter on Day 1. I would be interested in any PRs you have to clarify the matter adequately for people just starting out.
- azrazalea 10y agoI'd have to review it but i found Common Lisp Recipes to be excellent at explaining well... everything. Useful inspiration may be found there.
- lerax 10y agoNICE!
- Scarblac 10y agoI'm used to languages like Python, that have a number of files that are modules, and to start a program you run one of them as an entry point. C programs consist of a lot of files that are compiled and linked into a binary executable. Whenever I've tried to learn CL, I couldn't really wrap my head around what the eventual program would be. You build an in-memory state by adding things to it, later dump it to a binary. How do you get an overview of what there is? I'm just too used to my files, perhaps. Or I'm missing something.
- reikonomusha 10y agoLisp offers a lot of ways to check what there is. You can inspect, search, look at source code, docs, assembly code. All of these things are dynamically inspectable. Tools like Emacs and SLIME make it easier. You can still look at the files that get loaded. Lisp organizes itself around systems (libraries) and packages (namespaces). It's good to check what packages a system has, then you can check out the symbols provided by a package. Lisp isn't totally wild-west in the concept of the Lisp image. There is organization to good code.
- jlarocco 10y agoI don't know where you got that impression, but CL development is no different than Python development. Code goes in .lisp files, and then you either load it into the REPL or pass it to the compiler and tell it what the entry point is. I suppose it's technically possible to develop an entire application at the REPL and then dump to a binary, but I don't think anybody does that any more than they do it in Python.
- chaoky 10y agoIn Common Lisp, you write to source code files and then use ASDF/Quicklisp to compile/load that project. If you feel the need to create a standalone executable you can dump the image with an entry function specified. It's essentially the same as python, although standalone executable are less prominent than in-image programming.
- quickoats 10y agoLisp is quite abstract, let us say more so than C, where we can visualize the pointers and memory chunks and operators fairly accurately while programming. Lisp is more symbolic and ethereal; like the ocean full of its interlocking organic forms. One would wonder what lies below the surface upon merely apprehending the calmly undulating surface...
- lenkite 10y agoI wish an experienced LISPer would explain why should one use Common Lisp over a language like Golang. Golang now has https://github.com/glycerine/zygomys https://github.com/glycerine/zygomys for scripting. For that matter, why would one choose Common Lisp over GNU guile ? (guile now supports fibers). What does Common Lisp offer for the working programmer that is an advantage over other languages ?
- kruhft 10y agoStability of (most) implementations and solid language standard.
- kgwgk 10y agoYou can run the code you wrote 15 years ago, and (hopefully) you will be able to run in 15 years the code you write today.
- SomeHacker44 10y agoGiven a reasonable choice, I would almost never use a language like Golang that doesn't enforce memory safety (at least, by default). Null pointers, ugh.
- deleted 10y ago[deleted]
- jerf 10y agoMost of the traditional definitions of "memory safety" are not violated by having null pointers, as long as they just crash when used incorrectly. nils in Go don't let you start accessing things you shouldn't or anything. Golang is memory safe by most definitions. (Possibly not by a definition that includes concurrent memory safety. I expect in 20 or 30 years the term "memory safe" will indeed involve that. But at the moment, it doesn't, because almost no language has that right now.) This doesn't invalidate your underlying point that you want to use a language without implicit nulls... it's just the wrong terminology.
- 10y ago
- quickoats 10y agoi do not know how to message the guy "Scott" author of page, so i am putting this here. in the "LispWorks CL" page, under "Implementations", the "Notes" section elicidates a mystery about the Personal Edition not recognizing the lisp init files. This is actually a limitation in LispWorks Personal Edition which is described on the link provided to retrieve said edition.
- deleted 10y ago[deleted]
- pnathan 10y agoAh, interesting! I don't remember reading that when I wrote it. I'll go back and correct it after my current project wraps up (but PRs are also accepted!).
- lispm 10y agoThe Personal Edition has several limitations: does not load init files supposed to be used with the IDE IDE quits after some hours Memory is limited can't create applications --- Actually the Personal Edition is mostly for people to play around a bit or students doing some homework. Other than that the typical user will buy a version, which won't have the above limitations. Users also may also test a time-limited full version, before buying. People use either LispWorks or Allegro CL, then.
- pnathan 10y agoYeah, I recall using it a bit more now. The personal edition is really a trial edition, it's not a 'low budget low features' edition, which is what I was thinking when I originally was fooling with it back then. (These days I use SBCL nearly exclusively for my CL implementation)
- lispm 10y ago> 'low budget low features' edition In some school/university course it would be like that. The students get a simple installer, get the IDE up and running after a few clicks and thus they don't have to learn GNU Emacs + installing Lisp infrastructure for some basic homework.
- yarrel 10y agoI'd replace the first few steps with "Install Roswell" - https://github.com/roswell/roswell https://github.com/roswell/roswell Roswell will install a Lisp and QuickLisp for you, and give you a single point of entry to install libraries, create and run code, and launch en editor (Emacs with Slime of course). I can't recommend it highly enough (I'm nothing to do with the project, just a very happy user).
- iak8god 10y agoNeat. Does Roswell do all this without modifying your current lisp/emacs/slime/quicklisp if you already have them set up the way you like but want to play around with it? And is there something like Roswell for Clojure?
- aidenn0 10y agoI don't know about emacs/slime, but it can manage local quicklisp and local implementations (and even have e.g. multiple sbcl versions installed simultaneously).
- nerdponx 10y agoThis sounds a lot like Pyenv and Virtualenv for Python. Neat!
- _pmf_ 10y agoI don't like Clojure (any more), but one nice thing about it is that is includes the Clojure implementation itself as regular versioned dependency on a project-by-project base (thanks to the transparent usage of Maven by the leiningen build tool). Once you tried this, everything else feels like a cludge; there's simply no reason the language version should be managed by some obscure mechanism instead of being a regular dependency!
- AlexCoventry 10y agoCan someone point me at an argument for why I'd want to write CL in 2017, given all the great alternatives available now?
- agentultra 10y agoI'll take a stab at this glib comment: 1. You've inherited an application written in Common Lisp 2. Common Lisp has features you find desirable that aren't available in another system 3. You like Common Lisp 4. Common Lisp helps you get the thing you're trying to do, done
- AnimalMuppet 10y ago1. Because I was forced to? That's not why I'd want to. 2. Examples? 3. Fair enough. Though AlexCoventry's question probably shows that he does not (currently) like Common Lisp, so this answer doesn't give him a reason. 4. Sure, that's true for every language and tool. Choose it when it helps you, don't when it doesn't. But why would CL help me more than another language?
- agentultra 10y ago> 1. Because I was forced to? That's not why I'd want to. You might find it pleasant. Who knows? Maybe you're a professional and you'd want to understand CL so that you can embrace and extend the system you've inherited. > Examples? Conditions and restarts. Incremental compilation. CLOS. Numerics. > 4. Sure, that's true for every language and tool. Choose it when it helps you, don't when it doesn't. But why would CL help me more than another language? CL is more like a system than a compile-and-run language. The compiler, debugger, standard library, and platform libraries all live in the image. You build the program as you go, incrementally, and can inspect it while it is running. An error doesn't halt the entire process... instead condition handlers can either choose a restart (including asking the user what to do) and the execution continues. That's where you can attach to a remote image running on a server, notice that there's an error with a particular request, inspect the entire stack, fix the problem, and continue the request. No need to crash or anything like that. If a more hands-off approach is necessary then a handler can be written to choose an appropriate restart. CLOS is great. You can change the class definition in a running image and the instances will incrementally update without recompiling and restarting the program (and rebuilding all of that state). You can develop the language you need with these tools instead of using the language you've chosen (or inherited). Need an interactive prover? Try ACL2. Experimenting with sequent calculus? Want a language built around recursive fractals?
- na85 10y agoIf emacs is an obstacle to Common Lisp in 2017, maybe what's needed is a Lisp-interaction plugin for vi(m) (or whatever it is that vim uses in lieu of emacs modes). I don't get the hype for modal editing but you can't argue with the data clearly showing emacs users are in the minority.
- dlowe-net 10y agoslimv is a swank client for using Common Lisp inside vim. http://www.vim.org/scripts/script.php?script_id=2531 http://www.vim.org/scripts/script.php?script_id=2531
- kahrkunne 10y agoHonestly I don't think Emacs is an obstacle to people who use Vim. It's an obstacle to people who use IDEs
- ruleabidinguser 10y agoI use(d) vim and see EMacs as annoying.
- cat199 10y agoI use vi and emacs and see vim as some odd vi that is trying to be emacs but ends up being neither.
- kahrkunne 10y agoIt might be annoying but it probably wouldn't be an "obstacle", especially considering things like evil-mode exist. That's how it went for me, anyways. From vim user to trying Emacs because it has some feature that I need to becoming a full-time Emacs users with evil-mode
- aidenn0 10y agoIMO, It's an obstacle only to people who don't use IDEs. Someone who uses e.g. visual studio for C++ isn't going to balk at the suggestion of installing IntelliJ for Java, and I doubt that they would balk at the suggestion of installing SLIME for lisp. In my experience it's people who live in their editor (sublime, vim, &c.) that balk at the idea of installing an IDE as the first step for using a new language.
- macco 10y agoIf somebody is not comfortable to use emacs (I am), there is a atom plugin for use with CL: https://atom.io/packages/atom-slime https://atom.io/packages/atom-slime It doesn't replace emacs, but it works as a first Lisp ide.
- pnathan 10y agoReally! Do you use it? Would you feel comfortable submitting a PR explaining how to set it up? I HATE recommending emacs as the IDE for Common Lisp if it's not something people are comfortable with already.
- baggers 10y agoIt's very promising but still very young. I manage to break it very quickly each time I have tried using it. Eventually though this will be a huge boon.
- snowcrshd 10y agoHmm, this just gave me an idea: Visual Studio Code Common Lisp plugin might also be a good way to expose the language to people unfamiliar to the language.
- int_19h 10y agoEvery time I tried to get into CL, having to use Emacs/SLIME (which, let's face it, is the development environment for it for all practical purposes) has been a huge turn-off. So, yes. Please?
- provemewrong 10y agoI had (and still have) a similar aversion to emacs, so I used to use Sublime with SublimeREPL plugin, which allowed me to run Common Lisp and Clojure (or any other language with a REPL) inside the editor. Pretty much a makeshift IDE, with an interface you're already used to. I've since moved on to VSCode, and I bet there must already be a way to replicate this in it, I just haven't had the need to work with Lisp since to explore this.
- TeMPOraL 10y agoWhile I remember - we need a refreshed SOTU for 2017. 2015 one[0] seems to be still mostly correct, but the CL scene is pretty active. [0] - http://eudoxia.me/article/common-lisp-sotu-2015 http://eudoxia.me/article/common-lisp-sotu-2015
- znpy 10y agoSome notes based on my (brief) experience toying with Common Lisp: * Why hasn't anyone made a more eye-frendly version of the Common Lisp Hyper Spec ? Having good, easily-browsable documentation is a core-problem. * The relation between the various native data-types were quite unclear to me. * dealing with the external world was quite a mess. Many project/libraries implementing only half of something and then got abandoned. * some libraries had a compatibility matrix... with common lisp implementations. that seemed weird to me.
- TeMPOraL 10y ago> Why hasn't anyone made a more eye-frendly version of the Common Lisp Hyper Spec ? Having good, easily-browsable documentation is a core-problem. A friend of mine is working on that as we speak. The CLUS, or Common Lisp UltraSpec: https://phoe.tymoon.eu/clus/doku.php https://phoe.tymoon.eu/clus/doku.php That said, CLHS isn't bad - it's lightweight, available off-line, and on-line you can pretty much always find what you're looking for by searching for "clhs [term of interest]". > some libraries had a compatibility matrix... with common lisp implementations. that seemed weird to me. Common Lisp has a pretty good standard, but it's a bit old so it didn't predict some things we're currently using, and also left some other things to the implementers. So some features are only available via vendor-specific extensions, which makes it necessary for some projects - especially compatibility libraries - to be tested across plethora of CL implementations. The flip side is that you have a few commercial and open source implementations to choose from, which is valuable if your project can exploit strengths of a particular one.
- db48x 10y agoAh, this is something to follow. Sadly it doesn't seem to have a permuted symbol index, which is what I really love about the CLHS. Still, I suppose they have to start somewhere.
- sedachv 10y ago> Why hasn't anyone made a more eye-frendly version of the Common Lisp Hyper Spec I mostly access the HyperSpec using Erik Naggum's hyperspec.el while programming in Emacs, configured to bring up Lynx. A lot of other people probably do something similar, so there has not been much interest in adding CSS.
- pnathan 10y agoHi, HN! I made this! Ask me any questions you like. I'll try to respond as the workday progresses and I wait for deploys to complete! paul@nathan.house if you want to email me instead. (or @p_nathan on Twitter, if that's your thing).
- aidenn0 10y agoIMO the "Getting Started" section presents way too many choices. Perhaps instead just link to Portacle (or some other lisp quickstart) with a mention that there are other options?
- aidenn0 10y agoAlso, the ASDF information is somewhat dated. It will work, but the central-registry has been deprecated for years. I'm not even sure how it might work on windows. If you're recommending quicklisp, there's the local-projects approach, otherwise there's $HOME/common-lisp/
- pnathan 10y agoYeah, I need to examine a bit more of the situation with local-projects. I reject ~/common-lisp because I have my own directory structure, thanks. If I can symlink farm under ~/common-lisp, then what's the difference? :) (and it's not even a hidden directory, so it clutters up ~).
- aidenn0 10y ago> (and it's not even a hidden directory, so it clutters up ~). Well in that case you have two options still: ~/.local/share/common-lisp/source/ or put config file(s) in: ~/.config/common-lisp/source-registry.conf.d/ And keep your lisp source in any arbitrary number of directories. Of course if the symlink farm is working for you, that's fine; it just has issues (some historic with some implementations doing odd things with TRUENAME, and of course the big one is "windows"). [edit] forgot some other options: * setting the CL_SOURCE_REGISTRY environment variable * using one of the newer functions for configuration, particularly with the :tree directive which in many cases removes the need for symlink farms.
- gravypod 10y agoIf this could have a "start" page and a "next" button that will take me from topic to topic in order I'd enjoy that.
- s_kilk 10y agoWhile people are directing their attention here: Last year I looked into Common Lisp for a while, but got turned off when I found that there's no distinction between the empty list and boolean false (or nil, in CL-speak). I found this kinda weird and vaguely off-putting. I don't want to write code to handle the diffence between, say, an empty array and false or null in deserialized JSON data. Can anyone comment on whether this comes up as an actual issue in practice?
- aidenn0 10y agoIt comes up in practice but is easilly avoided with the mapping of: null -> :null [] -> #() and false -> nil Mapping arrays to lists instead of arrays seems wrong to me, but is what most json libraries do by default. Fortunately most of them allow you to change that.
- s_kilk 10y agoWould that mean I'd need to carry the `:null` symbol all throughout the codebase, wherever that data-structure might be accessed?
- aidenn0 10y agoI'm not sure I understand the question. If you need to check if a value is null, you compare it with :null. It does mean that values you are going to serialize out to JSON should use :null rather than the more lispy nil, but JSON interfaces where you are required to send null values are quite rare (in fact I don't recall ever encountering one), so it hasn't been a problem for me in practice.
- db48x 10y agoSymbols are interned, and become a simple integer comparison once compiled. It's no different than comparing against 0, except that :null will have some other non-zero value.
- fiddlerwoaroof 10y agoSo, I really dislike truthiness and falsiness in other languages but somehow, in Lisp, it just seems to work. One thing that helps is that, in places where the distinction between null and false matters, other features of lisp help keep them distinct: so, for example, getting a value from a hash table returns nil if the value is not found and, consequently, you can't distinguish a missing key from a stored null. GETHASH solves this by returning multiple values: the first is the value stored (if there is one) while the second indicates whether or not the key was found in the hash table. Similarly, optional arguments [declared like (defun foo (&optional bar))] default to null but, if you want to no whether a value was actually passed, you can change the argument declaration to account for this: (defun foo (&optional (bar nil bar-p))) In this case, when bar isn't passed, bar-p will b nil but when bar is passed, it will be t.
- throwaway7645 10y ago"Dear windows user, tell us how this is done for SBCL" Watch YouTube video from Baggers. It's a lot more complicated than your average windows user will want to go through. Than you have to setup EMACS, quicklisp...etc. I never really new what quicklisp was doing and it made me nervous (I trust VS nuget).
- orthecreedence 10y agoI've been telling people for years to just use Clozure CL on windows. It might be a bit slower, but it's still blazing fast and you don't have to deal with compatibility issues.
- Grue3 10y agoEverything should Just Work (TM) on Windows these days. SBCL provides reasonably fresh binaries to download. Quicklisp can be installed by entering the necessary commands into SBCL console. Emacs has a Windows installer. SLIME can be installed from Quicklisp. And so on. I develop in Lisp on both Windows and Linux machines, it works exactly the same (which cannot be said of some other languages).
- aidenn0 10y agoPortacle[1] and lispstick[2] both provide portable sbcl-based development environments on windows. Quicklisp is really simple to track what it's doing, and trivial to manage multiple installs of quicklisp simultaneously (though you can only use one install at a time in a given lisp image). Everything goes in <install-directory>/dists/<distribution-name>. 1: https://shinmera.github.io/portacle/ https://shinmera.github.io/portacle/ 2: https://github.com/jasom/lispstick-automate/releases/tag/1.0 https://github.com/jasom/lispstick-automate/releases/tag/1.0
- baggers 10y agoThe video in question: https://www.youtube.com/watch?v=VnWVu8VVDbI&t=744s https://www.youtube.com/watch?v=VnWVu8VVDbI&t=744s As aidenn0 mentioned portacle will hopefully be a good option for some when finished as it gives you a complete environment in one shot. For installing CL I may update my video to use Roswell at some point, I've been having good success with it when using TravisCI.
- hydandata 10y agoI started a big project at work using Common Lisp in 2017 and could not be happier. Sure, most nice features have trickled down to other languages, but they are rarely as nicely integrated. And Lisp still has many advantages that are not found elsewhere: Unmatched stability, on-demand performance, tunable compiler, CLOS, condition system, and Macros to name a few. It has its warts too but which language does not? I found lack of high quality library documentation a bit annoying, but a non-issue, there were tests and/or examples included in practically all of the libraries I have used so far. Lastly, this rarely gets brought up, but I think Common Lisp has some of the best books available out of any programming language. The fact that it is so stable means that most of material, and code, from the end of 80's and 90's is quite relevant today, and new stuff is being written. The biggest downside is that it makes JavaScript and Python revolting to work with. But I can still enjoy SML for example.
- shady-lady 10y agoCurious over why CL vs Clojure? Any comments.
- edem 10y agoI'm also interested in an insightful answer.
- Jach 10y agoWhy Clojure vs CL? The parent already mentioned some features that Clojure lacks, so if you don't care about features, what do you care about?
- spraak 10y agoThe child likely didn't know that
- SolarNet 10y agoI'm not OP, but there are a few I could see some mentioned in the OP's post in passing. * The common lisp condition system [3, 0] is a way better way to do errors. * Tune-able compilers [1] allow you to make better trade offs than even gcc allows for c, let alone Clojure's very opaque compiler. * CLOS [2] is a very powerful object system which clojure does not replicate (they have multi methods, and java classes, but not a meta class system; think python's meta class features but better (because of macros and compiler access) and with multi methods designed in). * Nice native interoperability (Clojure generally being on the JVM, and common lisp capable of direct calls and memory manipulation). That being said. Clojure's unparalleled concurrency features are amazing. I would compare them as: if Clojure is the Java of lisps, then Common Lisp is the C++ of lisps. [0] http://www.gigamonkeys.com/book/beyond-exception-handling-conditions-and-restarts.html http://www.gigamonkeys.com/book/beyond-exception-handling-co... [1] http://franz.com/support/documentation/current/doc/compiling.htm#decl-opts-1 http://franz.com/support/documentation/current/doc/compiling... [2] http://www.laputan.org/pub/papers/MOP.pdf http://www.laputan.org/pub/papers/MOP.pdf [3] http://axisofeval.blogspot.com/2011/04/whats-condition-system-and-why-do-you.html http://axisofeval.blogspot.com/2011/04/whats-condition-syste...
- mikelevins 10y agoFor people using macs, it's probably worthwhile to mention CCL's IDE, which you can easily build from within the CCL sources using (require :cocoa-application), or which you can get for free from the Mac App Store (it's called "Clozure CL"). It's a little bit bare bones and a little bit perpetually unfinished, but it works and it gives you a Lisp-aware environment for editingand running Lisp code, and even has a few handy tools.
- sigjuice 10y agoIs there something like paredit available for CCL's IDE?
- Grue3 10y ago>Repository for local libraries with the ASD files symlinked in This method is so old, I can't believe people are still doing this. You can easily setup ASDF to look in a subtree of a directory and never care about it finding your libraries again. [1] https://common-lisp.net/project/asdf/asdf.html#Configuring-ASDF-to-find-your-systems https://common-lisp.net/project/asdf/asdf.html#Configuring-A...
- Iispm 10y agohttp://zeniv.linux.org.uk/~ober/clb/ http://zeniv.linux.org.uk/~ober/clb/ has some recent comparisons of CL options. Sbcl is but one of the available options.
- edem 10y agoHow does Common Lisp compares to Racket nowadays? I've seen a lot of activity but I can't decide which one to try out. I only have time for one of them ATM.
- aidenn0 10y agoI think you will be happy with either one. It's targeted mainly toward people familiar with them, but here's a recent comparison: http://fare.livejournal.com/188429.html http://fare.livejournal.com/188429.html Note that a lot of what Faré likes about racket is somewhat intrinsic in there being one implementation, and a big part of why racket branded itself away from scheme (it was formerly PLT-Scheme). In lisp there are still a lot of very different implementations in use, so if you want to "grow down" you either have to be non-portable or do a lot more work. I love Common Lisp, so I will say "learn Common Lisp" but you'll probably be just as happy if you flip a coin (and I would recommend doing so rather than debating much as learning the "wrong" one now is probably better than learning the "right" one in the future).
- spdegabrielle 10y ago1. Racket is a multi-paradigm programming language. It has Java-style class/object system, a CLOS-like object system(swindle) and a prototype object system (like self and JavaScript). 2. The macro system is arguably the most sophisticated available. 3. Functionsl programming! including '(purely)Functional Data Structures'. 4. Parallelism (futures) 5. concurrency 6. Contracts 7. Typed Racket 8. Pattern matching 9. Modules 10. Units 12. Pattern Matching 13. Exception, continuations 14. Reflection 15. arguably the most sophisticated tools for creating full languages and DSLs 16. Datalog language (like in datomic) 17.an amazing IDE - it has a tool to debug macros! (but you can also use Emacs) 18. Typed Racket 19. Functional pictures (pict) 20. OpenGL 21 cross platform (win, mac, Unix, Linux) it will even run on a raspberry pi 22. Amazing community 23. Math library (and plot library) 24. Scribble/@-expressions (like markdown but much more powerful) 26. Quite a few libraries
- lispm 10y ago> Racket is a multi-paradigm programming language and its only implementation. 1. I use LispWorks, a multi-paradigm programming language (and its implementation) based on Common Lisp. It has CLOS and can use multiple other object-systems. 2. uses procedural macros 3. procedural functions, 3. concurrency, 6 assertions, 7 type declarations, 8 unification 9 systems, 10 conditions 11 reflection 12 arguably excellent tools for creating languages and dsls, 13 prolog 14 rule system 15 database interface 16 OpenGL 17 cross platform and will run on the raspberry pi 18 nice community 19 interface builder 20 delivery as shared libraries and applications, ... and a long list of other features... It's commercial and closed software, though.
- kunabi 10y agoI've been working on a CL project for a couple of years. Was my first big stab at using CL for something other than a toy. Sbcl is a nice choice, but far from the only option. It has many tradeoffs. CL is not without its frustrations. Documentation that has not aged well. A community that can be less than welcoming. (in contrast to say the Racket community) Inconsistencies, e.g. first, nth, elt, getf, aref... However portability appears to be a strong point vs on the scheme scene. Single binary compilation on SBCL/LW/ACL/CCL are great. Found GC to sbcl to be lacking on large garbage rates. Tended to promote garbage to a tenure that prevented it from being removed. It would max out 32GB of memory, even with explicit gc's enabled between files. Where as the other implementations would stay below 4GB. So ymmv. Performance benchmarks using cl-bench really highlighted some strong points http://zeniv.linux.org.uk/~ober/clb http://zeniv.linux.org.uk/~ober/clb AWS Cloudtrail parser. https://github.com/kunabi/kunabi https://github.com/kunabi/kunabi
- azrazalea 10y agoThis talks about GC settings that worked for them in SBCL for production, not sure if you already tried the same kind of stuff but may be an interesting read http://tech.grammarly.com/blog/posts/Running-Lisp-in-Production.html http://tech.grammarly.com/blog/posts/Running-Lisp-in-Product.... If you can make an easy to run example of the garbage collector not working correctly, the folks in #sbcl on freenode are very responsive and have commit access to fix it.
- lafytahoe 10y agoThey say to never #+sbcl (gc :full t) ;;ar
- kunabi 10y agoGood to hear someone had good interactions in #sbcl Still have a bitter taste from attempting to report the issue there.
- azrazalea 10y agoYeah, i've had good and bad interactions. They seem to be cranky due to getting a lot of idiots (including sometimes me) coming in thinking something is sbcl when it was actually the programmer's fault. Generally if I think something is sbcl now I put together example code that clearly shows the issue and that seems to work well.
- lisper 10y agoIf you have a Mac you should try Clozure Common Lisp (http://ccl.clozure.com http://ccl.clozure.com). It has an integrated IDE so you don't have to futz with emacs and slime. Also, this library smooths over some of CL's rough edges: https://github.com/rongarret/ergolib https://github.com/rongarret/ergolib
- cody8295 10y agoProbably the worst implementation of the 5-puzzle problem you can write. Artificial Intelligence Assignment 1 Problem 09: Write GET-NEW-STATES to implement all possible movements of the empty tile for a given state. CG-USER(151): (defun get-new-states (state) (setf new-states '()) (cond ((= 0 (first state)) (setf new-states (list (list (second state) 0 (third state) (fourth state) (fifth state) (sixth state)) (list (fourth state) (second state) (third state) 0 (fifth state) (sixth state))))) ((= 0 (second state)) (setf new-states (list (list (first state) (fifth state) (third state) (fourth state) 0 (sixth state)) (list 0 (first state) (third state) (fourth state) (fifth state) (sixth state)) (list (first state) (third state) 0 (fourth state) (fifth state) (sixth state))))) ((= 0 (third state)) (setf new-states (list (list (first state) 0 (second state) (fourth state) (fifth state) (sixth state)) (list (first state) (second state) (sixth state) (fourth state) (fifth state) 0)))) ((= 0 (fourth state)) (setf new-states (list (list 0 (second state) (third state) (first state) (fifth state) (sixth state)) (list (first state) (second state) (third state) (fifth state) 0 (sixth state))))) ((= 0 (fifth state)) (setf new-states (list (list (first state) 0 (third state) (fourth state) (second state) (sixth state)) (list (first state) (second state) (third state) 0 (fourth state) (sixth state)) (list (first state) (second state) (third state) (fourth state) (sixth state) 0)))) ((= 0 (sixth state)) (setf new-states (list (list (first state) (second state) 0 (fourth state) (fifth state) (third state)) (list (first state) (second state) (third state) (fourth state) 0 (fifth state))))))) GET-NEW-STATES CG-USER(152): (get-new-states '(1 2 3 4 5 0)) ((1 2 0 4 5 3) (1 2 3 4 0 5)) CG-USER(153): (get-new-states '(1 2 3 4 0 5)) ((1 0 3 4 2 5) (1 2 3 0 4 5) (1 2 3 4 5 0)) CG-USER(154): (get-new-states '(1 2 3 0 4 5)) ((0 2 3 1 4 5) (1 2 3 4 0 5)) CG-USER(155): (get-new-states '(1 2 0 3 4 5)) ((1 0 2 3 4 5) (1 2 5 3 4 0)) CG-USER(156): (get-new-states '(1 0 2 3 4 5)) ((1 4 2 3 0 5) (0 1 2 3 4 5) (1 2 0 3 4 5)) CG-USER(157): (get-new-states '(0 1 2 3 4 5)) ((1 0 2 3 4 5) (3 1 2 0 4 5))
- GreyZephyr 10y agoWondering if anyone has any experience using lisp for machine learning? I'm aware of mgl[0], but it seems to be abandoned. The lack any wrappers for tensor flow or caffe is also a bit surprising to me. The cliki page [1] is also unhelpful and out of date. Is machine learning on lisp dead or are there projects out there that I'm just not aware of? [0] https://github.com/melisgl/mgl https://github.com/melisgl/mgl [1] http://www.cliki.net/machine%20learning http://www.cliki.net/machine%20learning
- cat199 10y agoNot directly, but have been following various projects over the years.. My take on this is that the people using CL for machine learning have been doing this for some time, and so have their own toolsets; tensor flow is relatively new in that regard, and w/r/t lisp interfacing would entail low-level binary interfacing (and therefore mostly non-portable between implementations) to hook CL code with tensorflow kernels (definately not an expert here on either however). also, what is popularly referred to as 'machine learning' is in my opinion mostly only one aspect of the field - e.g. classification neural networks - while lisp can definitely do this, lisp AI programming (in my amateur opinion) shines more in the realm of machine reasoning/inference due to the symbolic / dynamic nature of the environment - e.g. constructing a set of reasoning primitives (e.g. functions and facts and decision trees) and a meta-interpreter to reason/infer about external data and walk around a problem space.. also, owing to the dynamic and rapid development nature of the language, likely many people are working with their own prototype/core frameworks, possibly cobbled together from various small bits and pieces of 3rd party code. Also, neural networks have been around for quite a while - what these new frameworks bring to the table is not so much new core algorithms, but the ability to quickly cobble them together in a more popular/user friendly way, and also take advantage of fast hardware (e.g. GPUs) as for projects - in the general sense, lisp has been a latecomer to the 'languages with cpan-style trove of public addon modules' crowd, owing in my opinion to the need to support multiple implementations in order for such a project to take hold - so older but yet still quite functional libraries might be around in various hodge-podge repositories which are not standardised but old timers have already included in their own local systems, etc. (see also CMU AI repository) In the last few years, much has been done in the module space - I would definately consider 'quicklisp' to be roughly the defacto definitive list of current modules, especially those under active development, since the active community is basically converging on this as a module/distribution platform and so many (most?) active community projects are available as quicklisp modules and included here - and so would probably be the one of the first places to start in checking into for available libraries for any topic. Also, the best way to 'explore' quicklisp is to install it, and then install various packages and then muck around/explore with the source code that they download into your environment - the documentation tends to be much less 'external' (e.g. websites) and much more 'internal' (e.g. READMEs, in-tree code examples or unit tests). https://www.quicklisp.org/beta/releases.html https://www.quicklisp.org/beta/releases.html
- killin_dan 10y agoThe biggest problem with lisp adoption imo is that the first step of every path begins with emacs. Emacs needs to die for lisp to flourish in a more modern editor. Light Table was a good start, but we need some power behind similar projects. I always thought guilemacs was the obvious successor, but it still hasn't happened.
- macco 10y agoUse atom with slime: https://atom.io/packages/atom-slime https://atom.io/packages/atom-slime
- killin_dan 10y agoAtom is somehow even heavier than emacs. Because EVERY editor should definitely include the bloat of a web browser.
- krylon 10y agoLisp and Emacs have decades of shared history, it's unlikely someone will really break this bond. It would be nice to have alternatives, of course, but there is a reason certain people like emacs. (To be fair, I was an emacs user before I came across Lisp, but I can imagine how annoying/intimidating/frustrating it can be to somebody who has never used emacs before.)
- peatmoss 10y agoSince you mentioned Light Table, I'm going to guess that you're open to other lisps. I think this is one thing that the Racket folks get right. My wife's first foray into programming was a coursera course starting with a simplified variant of Racket, and the dev environment could not have been less of an issue. EDIT: Also, emacs doesn't have to die. I love emacs! But DrRacket is a nice alternative for beginners (and I'm told) advanced users alike.
- killin_dan 10y agoYes, but racket is a terrible language to work with. I've mentioned for years that drracket needs a general sexpr mode and integrated terminal for something like geiser. They don't listen. I am working on a general purpose solution, but I'm just one person. And I don't leverage public dollars to write bad tools from the safety of university, so that slows it down a bit.
- juanre 10y agoI wrote in Common Lisp the star map generation software at the core of my startup, http://greaterskies.com http://greaterskies.com, and could not be happier. But now that it's getting off the ground I wonder whether it may adversely impact my chances of being acquired. Are there any known examples of recent CL-based startups?
- dtornabene 10y agoI don't know about being acquired but I believe there is a canadian travel-oriented startup using CL for an algorhythmically important part of their stack. I forget what it was called.
- TeMPOraL 10y agoNot a startup per se, but Grammarly is a well-known company using Common Lisp for their core product.
- tarrsalah 10y agoA newbie question please, How to deploy CL on production? I mean for long running programs.
- aidenn0 10y agoThere are a few ways of doing it all with different tradeoffs: If very quick startup times are a necessity, then you just build a standalone image. This is very much like deploying a program in e.g. C. You build it with asdf, and then install it (and any dynamic libraries) into your deploy environment. For "long running" programs, this may not be as necessary, and since the lisp runtime includes a full lisp compiler, it's not uncommon to just have a script that launches your lisp executable, uses ASDF to load the system, and calls the entry point. For either one, it can also be useful to expose a swank server, though that does have security implications (anybody who can connect to the swank server (either localhost or unix domain sockets) can run arbitrary code).