14 ms·
Tutorial Series to learn Common Lisp quickly
- plaguepilled 5y agoThis is a great idea - I'm looking forward to trying it. One nitpick: the Google Docs code does not display favourably on mobile. It might help to publish in HTML if you're interested in targeting those readers.
- pronoiac 5y agoThe table of contents is on GitHub; I was honestly surprised the individual posts weren't too. Turning t into markdown would be fairly quick, I think?
- buggythebug 5y ago
- juliend2 5y agoCome on, this is HN, you're not even allowed to think that here.
- rtz121 5y agoWrong.
- stnmtn 5y agoI'm a software engineer interested in getting more productive at my job, which namely involves the current React/typescript ecosystem. I have no interest in lower-level programming as a career path. What benefits would learning Lisp provide me so that I "Need" to learn it?
- lispm 5y agoSome people recommend to learn some basics of Lisp to better understand JavaScript. Though one of the core Lisp/Scheme books now has a JavaScript edition: https://mitpress.mit.edu/books/structure-and-interpretation-computer-programs-1 https://mitpress.mit.edu/books/structure-and-interpretation-...
- User23 5y agoThere’s a solid argument that JavaScript is a Lisp descendant.
- dunefox 5y agoReading a couple chapters of SICP (https://xuanji.appspot.com/isicp/ https://xuanji.appspot.com/isicp/) or these articles might give you an idea: https://michaelnielsen.org/ddi/lisp-as-the-maxwells-equations-of-software/ https://michaelnielsen.org/ddi/lisp-as-the-maxwells-equation... https://queue.acm.org/detail.cfm?id=1039523 https://queue.acm.org/detail.cfm?id=1039523 https://www.defmacro.org/ramblings/lisp.html https://www.defmacro.org/ramblings/lisp.html
- stnmtn 4y agoI read the defmacro link and found it very interesting and cool; but I still feel as if I'm missing what makes this so earth-shattering? Do not get me wrong - it is insanely cool and wonderful to be able to modify lisp's syntax with lisp... but it just seems like that... it's cool. I don't see why this would be any different than defining a function like I normally do. Sure, I can create an entirely new operator that becomes valid syntax, like `*` which creates an exponential operator. But why is this more productive than simply defining a "exponent()" function or something similar? It seems also that tech debt would accrue incredibly fast as joining a lisp codebase would require learning almost an entirely new set of syntax. I'm sure I 'm missing something, but I can't see at all why I need to learn LISP. It's cool, neat, and wonderful... but that's about it from my understanding.
- dunefox 4y agoIt's not easy to get the point across just by reading about it. Id honestly say you should just learn some lisp and implement something cool. > I don't see why this would be any different than defining a function like I normally do. Because with functions you don't define any new syntax or implement a DSL; you don't have access to the compiler during read, compilation, and run time. This allows you to easily extend the language: do you miss list comprehensions from Python? Add it yourself with a macro. Want to generate boilerplate code? Macro. Prolog compiler? Yes. Basically anything in this book: https://github.com/norvig/paip-lisp https://github.com/norvig/paip-lisp > But why is this more productive than simply defining a "exponent()" function or something similar? It's not just about defining a new operator, you can basically implement a DSL with C-like syntax if you want to: https://github.com/y2q-actionman/with-c-syntax https://github.com/y2q-actionman/with-c-syntax
- amar-laksh 5y agoOkay but everyone needs to think deeply about lisp.
- Zababa 5y agoNo, I think most people don't need to think deeply about lisp. I'd even argue no one "needs" to think deeply about lisp.
- tmountain 5y agoSome people want to. It’s good for those people to have resources.
- DerArzt 5y agoNeed, maybe not, but want to yes some folks do. Even though Common Lisp isn't used widely it never hurts to learn new things (especially when those things can be quite different than what you normally use).
- __oh_es 5y agoTake a look at this - https://www.defmacro.org/ramblings/lisp.html https://www.defmacro.org/ramblings/lisp.html, it may give you a different perspective :)
- pfdietz 5y agoNeed for... what? To survive? To get a job? Need is always relative to a goal, so what you are saying there is there is no legitimate goal for which learning Lisp would be an appropriate step.
- Rerarom 5y agoIndeed, I've been told countless times I don't "need" to learn some branch of math I was interested in (by mathematicians no less). Also, I've been told I "can't avoid" some branch of algebra (I've never touched it since).
- t-3 5y agoThose aren't necessarily incompatible. Nobody can avoid linear algebra, but almost nobody actually needs to use or know linear algebra. Heavily symbolic fields like math are probably not great examples though - different methods can be used to reach the same results because it's all fundamentally the same, just differing representations.
- smegsicle 5y agodidn't godel prove something like the conclusions you can reach depend on your axioms?
- teddyh 5y ago“LISP is worth learning for a different reason — the profound enlightenment experience you will have when you finally get it. That experience will make you a better programmer for the rest of your days, even if you never actually use LISP itself a lot.” — http://www.catb.org/~esr/faqs/hacker-howto.html#skills1 http://www.catb.org/~esr/faqs/hacker-howto.html#skills1
- jstx1 5y agoHonestly, "just because I want to" sounds like a more compelling argument than talking about enlightenment. Mainly because the latter implies that people who don't know lisp are somehow unenlightened or lacking in some way - that comes across as really arrogant and it's clearly false since there are many successful and highly skilled programmers who don't know or care about lisp. I kind of agree with the GP comment - nobody needs to learn lisp. The main reason to learn it is some personal interest or curiosity.
- PheonixPharts 5y ago> Mainly because the latter implies that people who don't know lisp are somehow unenlightened or lacking in some way But if you haven't learned Lisp you are absolutely lacking in some way as far as understanding programming languages. One obvious example is don't really understand what the url of this website is referring to (though I do suspect a huge number of today's HNers have never implemented the y-combinator). To be clear, you can be an excellent software engineer and never touch or understand lisp, but if you are seriously interested in programming languages you really are missing a major part of picture if you don't know a lisp. Anyone who is seriously interested in programming, beyond just creating software, absolutely must have experience in a lisp. It's completely fine if you aren't interested in programming other than solving a specific problem, but the idea that "nobody needs to learn lisp" is false.
- lubesGordi 5y agoWhat is it about lisp that's so important? Is it just the functional programming side? Metaprogramming?
- goatlover 5y agoWhat's the point of this comment? If you don't care about Lisp, skip the thread.
- Veen 5y agoPerhaps not, but need is not the only reason to learn; people also learn things because they are fun, pleasurable, interesting, challenging, entertaining, beautiful, revelatory, creative, inspiring etc. It'd be a dull life if we only learn what we need to know.
- rfrey 5y agoNo one needs to learn anything.
- rayiner 5y agoGreat to see a chapter on LOOP: https://docs.google.com/document/u/0/d/1L9jdKE-XrCU0VhdsmO5w9-2ozNDrrW1-JOAi3kHrlu4/mobilebasic https://docs.google.com/document/u/0/d/1L9jdKE-XrCU0VhdsmO5w... If you’re unfamiliar with Common Lisp, it’s important to understand that it’s a multi-paradigm language. The presence of closures, key functions in the standard library, and the syntax often push you naturally to a functional solution. But you shouldn’t feel bad about writing a LOOP that mutates a bunch of state under the hood. This isn’t scheme!
- eadmund 5y ago> But you should feel bad about writing a LOOP that mutates a bunch of state under the hood. I think you omitted a word there: one should not feel badly about writing a state-mutating LOOP. That's okay, and often the best solution to a problem. Heck, I wrote a state-mutating TAGBODY just yesterday …
- rayiner 5y agoThanks! TAGBODY is another non-Schemish part of Common Lisp that has its uses.
- roenxi 5y agoGood to see, but at this point in its lifecycle I don't really believe a lack of good tutorials is a barrier or even impediment for CL. The problem is after the tutorial is done, all the libraries (look (like (this))) and the language is so powerful it is difficult to know if this 10kb contains a life-changing insight into the nature of programming or a half-hearted implementation of half of something that was a bad idea to start with. Knowing the syntax and technical semantics of the language doesn't help with that. The topic has been done to death, but the lisps seem to have a social organisation problem that the community never quite managed to get a grip on.
- agentultra 5y agoGlad to see this old horse is still being pulled out and beaten every now and then. I think this is the worst part of learning to program in CL: the self-flagellating, cynical CL users and the haters that parrot this old, barnacle-ridden trope: it's too powerful! Macros! Nobody can understand it but gods and strange people on the Internet! You will have to listen to these people constantly invade every forum, discussion group, and chat room on the Internet to tell you how you shouldn't be learning CL. I like powerful languages. They have neat ideas. If they help you get more done in less time with less code, great. Not every software project needs to be a tedious, boring slog that takes 30 developers 8 months to do what you can with CL in a week. Keep learning CL if that floats your boat. I had a blast learning it and it's a great tool to have and a constant source of inspiration for ideas.
- watmough 5y agoYes, it's great to experience the 10x or 100x developer syndrome sometimes. Using Clojure changed my life somewhat, as at some point I rewrote 2000 lines of C++ (to handle splitting and coalescing NAESB cycle pipeline nominations) in about 27 lines of pattern-matching Clojure, and just no one, no one would take it seriously. A usable UI in Swing to manage it wasn't much more, and was cross-platform. Not a fun experience overall, I ended up quitting that company, doing iPhone dev for a bit, then moved back into G&G. Other than that rewrite experience, I just used Clojure like I used to use Perl. Easy to bang something out in, and performant native Java libraries for things you might not expect, like low-level SQL Server (2005 at the time!) and Oracle (8 at the time) drivers. I'm back mainly as a C++ developer now in visualization and HPC.
- qwerty456127 5y agoLooks really cool (because classic GUI pictures, desktop or desktop-like GUI is what I want). Feels like I'm going to learn it finally. Thanks!
- usgroup 5y agoFeels appropriate to say that Hylang is in version 1.0 alpha: https://github.com/hylang/hy/releases/tag/1.0a4 https://github.com/hylang/hy/releases/tag/1.0a4 That's Lisp over Python -- you can do data science properly in Lisp now using all you favourite Python packages. I repeat you can do data science properly in Lisp now.
- zqkamp 5y agoWell, Mathematica is lispy, and there is: https://www.wolfram.com/data-science-platform/ https://www.wolfram.com/data-science-platform/ I suppose Hylang is quite slow (and possibly has leaky abstractions). Ideally the main C/C++ libraries like libtorch should be wrapped in Common Lisp and not Python.
- mark_l_watson 5y agoYou have a few options for this: The TH package wraps Blas, etc., and has MINST, GAN, etc. examples. My preference is using py4cl to use pre-trained TensorFlow models in Common Lisp. I wrote a short book on Hy that has some deep learning examples, but I don't use Hy that often any longer. I am looking forward to the 1.0 changes.
- V1ndaar 5y agoMaybe things have changed over the years. I've played around with Hy in 2017 and in the end felt like it combines the bad parts of Python with the bad parts of a Lisp. If you're forced to use Python it's usually because of one of 2 reasons: Either you need to work with colleagues on something (in which case almost certainly they wouldn't accept a lispified version of it) or because you need some of the libraries that are already implemented. In the latter case, you might say Hy is a good option. But why bind yourself to the slowness of Python when you could just as well use some fast Lisp (e.g. Common Lisp) that interacts with a Python interpreter similar to nimpy [0] from Nim? Not sure if such a thing already exists for CL, but it should be quite feasible to write and then you get access to all your Python library needs while actually using a better language for the rest of your code. But I'm all ears on the real advantages Hy provides aside from being neat. [0]: https://github.com/yglukhov/nimpy https://github.com/yglukhov/nimpy
- goranmoomin 5y agoI’ve never did anything serious with Common Lisp, but my light experience on it was that - the idea that almost all language constructs are user-implementable with macros is quite impressive (but I don’t buy the argument that “real” macros are only able in s-exprs) - and the REPL-driven development model was a really beautiful and seamless experience. But… every time I try to use it on some code, I find too many warts and inconsistencies that I just didn’t want to spend too much effort in making it work. It’s a beautiful language in it’s own ways, but the other parts are too ugly (to me, of course). I’m fine with it being a lisp or not; I just want a clean language with macros baked in (and becomes the basis of most language features), and with a REPL-driven development model as a first class citizen (with interactive restarts and all). Unfortunately it seems a pipe dream… so I’m stuck here. [0]: https://mikelevins.github.io/posts/2020-12-18-repl-driven/ https://mikelevins.github.io/posts/2020-12-18-repl-driven/
- the_duke 5y agoJanet [1] is a clean, modern LISP. Clojure is also an option, but of course that comes with a heavy JVM burden. [1 ]https://janet-lang.org https://janet-lang.org
- ogogmad 5y ago> Janet is a clean, modern LISP. This does seem cleaner. I have some questions though: - What about the interactive environment like the one in Common Lisp? It's not enough to only have a "REPL", I think. - There are so many Lisp dialects. Is this one going to remain obscure? - What's the library situation?
- db65edfc7996 5y ago>What about the interactive environment like the one in Common Lisp? Never used a "real" Lisp REPL, but Conjure[0] seems like it ticks a lot of boxes. >Is this one going to remain obscure? There are only a ~dozen mainstream languages. Once you get outside of the popular zeitgeist, you have to appreciate exactly what you are getting. It takes a lot of dedication to become fluent in a language/ecosystem, so it is no surprise that people are reluctant to switch to a novel platform. Clojure is far more likely to ever become mainstream (owing to the huge JVM ecosystem), but even that seems to have only limited industry penetration. [0] https://github.com/Olical/conjure https://github.com/Olical/conjure
- medo-bear 5y agothe point of the tutorial is to give you enough knowledge of common lisp in order to use the author's clog gui-web-framework, which btw is pretty neat
- deleted 5y ago[deleted]
- xaxaxb 5y agoRacket is another dialect of lisp.
- greymalik 5y agoThis is a true statement.
- nekomorphism 5y agoRabbibotton is really motivated and putting in a lot of effort with CLOG and with these tutorials. I think he's even offering monetary rewards for others to write tutorials. Its nice to see his efforts make it to the front page here. :)
- solarmist 5y agoI agree. And he’s putting tons of work and evangelism into his CLOG framework. It’s pretty fantastic.
- __del__ 5y ago>ball of goop can you please talk to us like programmers? your audience is programmers.
- pfdietz 5y agoOne of the salient features of Lisps is that they are dynamic languages designed so they can be compiled into very efficient code. The details of how this works are interesting (for example, the use of low order bits as tags to efficiently detect common error cases, and also to allow types like characters, fixnums, and some floats to be represented without allocation.) A downside of this is that lisp implementations may not be ABI compatible with other language implementations. The macros are orthogonal to this. Macros are really just an example of a more general thing: features that are used to effectively implement parts of the language definition are often lifted up and also made available to users. This effectively allows the language to be extended in a way that very closely resembles the language's built-ins. (This is not always the case; lifting more such things would be a good avenue for extending Lisps.)
- latenightcoding 5y agoPractical Common Lisp gets you up to speed very fast. I wish there was something similar for scheme. Most scheme books focus on teaching you compsci with the language and not on teaching you how to build practical things with it. It's quite hard to onboard someone to a scheme codebase, despite scheme's reputation of being a simple language.
- vivab0rg 5y agoUpvote for a Practical Scheme book.
- leobg 5y ago„The Little Schemer”?
- wk_end 5y agoThe Little Schemer is a great book but it's in no way practical and very much focuses on teaching you comp sci - it's been a while but IIRC doesn't it culminate in constructing the Y combinator? Realm of Racket [0] seems like it might be more OP's speed. [0] https://www.amazon.ca/Realm-Racket-Learn-Program-Game/dp/1593274912 https://www.amazon.ca/Realm-Racket-Learn-Program-Game/dp/159...
- solarmist 5y agoHe links to that near the top
- deleted 5y ago[deleted]
- ilrwbwrkhv 5y agoSteel Bank Common Lisp has been one of the most enjoyable, performant, powerful languages I have ever used. Till now when I hack on something I use Steel Bank Common Lisp. Only for the most basic of web apps do I switch to Rails. These set of tutorials are excellent. Thanks for sharing.
- taude 5y agoWhat are people using LISP for? Other than the Emacs flavor, and some companies using Clojure, I'm not really sure what I'd use it for? Would I use it to replace Python or Shell scripting for my custom CLI tooling? Anyway, I've seen a lot of people talking about the Lisps lately, and trying to figure out what I'm missing.
- llanowarelves 5y agoYou can use Guile Scheme for using Guix so you get a more transferrable language for your reproducible OS/package manager instead of Nix/Nix Language.
- vindarel 5y agoSome companies: https://github.com/azzamsa/awesome-lisp-companies/ https://github.com/azzamsa/awesome-lisp-companies/ An interview: https://lisp-journey.gitlab.io/blog/lisp-interview-kina/ https://lisp-journey.gitlab.io/blog/lisp-interview-kina/ Hint: all Quantum computing companies, Google for ITA Software, the NASA for James-Webb's planning and scheduling system, smaller companies (Kina), solo devs that find they are more productive than in Python (like myself).
- mikelevins 5y agoI've used it for a lot of stuff over the years: a constraint-based GUI framework, a knowledge-based automated testing system that ran tests remotely on fleets of target machines, a model-building-by-demonstration system for the aforementioned testing system, an experimental operating system for Apple hardware, a direct-manipulation rapid-application-development system, a WYSIWIG programmable word processor, an artificial life simulator, a help and online-documentation compiler, a commercial graph database, a full-stack embedded control system with GUI for a forensic fingerprint-scanning machine, a syntax-aware diff program for code, a series of name and vocabulary generators for use in fiction and games, a list manager, several versions of a Lisp interpreter and compiler, a file-browsing program, several games, a knowledge-based machine-control program for laser-sintering machines, an anomaly-discovery system for various kinds of data, and a radar image analysis and classification system. Plus a whole bunch of supporting libraries, tools, and random toys. I've used it in preference to anything else since 1988. Lisp is an exotic niche option in the programming language space, so a Lisper needs to be prepared to work in other languages, and I often have. I've been fortunate, though, in that I've been able to work mainly in Lisp for more than half my career since 1988. I use it every day in my current job (working on the radar stuff and some other projects at the same employer).
- shadowgovt 5y agoMy favorite common lisp thing is the special operator `the`. http://clhs.lisp.se/Body/s_the.htm http://clhs.lisp.se/Body/s_the.htm `the value-type form) => result*` Looking at its use, you might think it lets you declare types of things for type-checking purposes. i.e. (the integer (operate-on 1)) ... would make the program assert-fail if (operate-on 1) were somehow not an integer. The real story is it can do that, but the spec actually says behavior is undefined if the value is not the specified type. So check-failing is one of the many things it's allowed to do. In practice, depending on your compiler settings, `the` can act like asserts or it can act like places the compiler's allowed to paint racing-stripes on your code to make it go faster by skipping dynamic type checks and letting data structures mangle up if the types are wrong. ;)*
- User23 5y agoOr both! The CMUCL and SBCL compiler manuals are well worth a read.
- unionpivo 5y agoThe only Lisp I know of is Emacs Lisp. I thought It was implementation of common lisp, but according to Wikipedia I am wrong. So If primarily Linux user (sysadmin/devops/ occasional embedder programmer), wanted to learn lispy like language, that is useful which one would you pick? Emacs one? some common lisp or scheme ?
- vindarel 5y agoWell CL is pretty useful, lightweight, featureful… and Emacs Lisp is very similar to it, so you won't be lost.
- User23 5y agoI’m not sure I’d call CL lightweight. It’s a large language that also has some very interesting gaps in the standard. It is possible to write very performant code with modern implementations though. One of my favorite examples is the regex library cl-ppcre. Thanks to the nature of Lisp, the recognizer for each regex you create can be compiled to native code on compiler implementations of CL. And as a practical matter if you want to learn Common Lisp you’re probably going to be using GNU Emacs. Thus you’ll probably end up picking up some Elisp too. Both have their share of idiosyncrasies, but a great deal of what you’ll learn applies to both.
- hayley-patton 5y ago> One of my favorite examples is the regex library cl-ppcre. Thanks to the nature of Lisp, the recognizer for each regex you create can be compiled to native code on compiler implementations of CL. That is not true - cl-ppcre generates a chain of closures. Experimental performance is in the same ballpark as typical "bytecode" interpreting regex implementations. However, the "compiler macro" feature in Common Lisp allows for generating the chain of closures to be performed at compile-time, and invalid syntax (in string literals) can be detected at compile-time. (Disclosure: I wrote another regex library at <https://github.com/telekons/one-more-re-nightmare https://github.com/telekons/one-more-re-nightmare>, which does do native code compilation.)
- 4y ago
- solarmist 5y agoRabbibotton has created the CLOG framework and it is fantastic. It supports a full desktop gui experiences over websockets all the way down to static webpages and any combination in between that you could want. It’s really impressive work. I guess it’s a reimplementation of a framework he wrote in ADA years ago, so it’s really well developed and thought through.
- forgotpwd16 5y agoBut why Google Docs rather directly on GitHub as md files?
- dbotton 5y agoMy plan is after another iteration or two of editing to move it to markdown.
- bc4m 5y agoDude, incredible work. I've only discovered CL in the last couple of months and everything I learn and discover brings me so much joy after being solidly disillusioned with programming after a decade-ish career. The first page of your tutorial cracked me up and a quick glance at CLOG has blown my mind. I can't wait to dig into it all.
- timonoko 4y agoOff hand question. From which lisp did I learn (compress (reverse (explode 'ABC))) ==> 'CBA I tried to google it, but I only found some shit I have written myself. First thing I did with my very own Symbolics-machine, was to implement explode & compress, because I did not want study those marvelous string-manipulating possibilities it may have. Compress & Explode manipulate of list of numbers, of course. In my latest Brain-Fart production I think have finally solved all problems. List of numbers, whose first number is 34 aka \" , is printed as "string" in ppretty-printer and editor. No need to implement strings *EVER*. https://github.com/timonoko/nokolis.py#readme https://github.com/timonoko/nokolis.py#readme