39 ms·
Why Lisp? (2015)
- lisper 5y agoI guess I'm a little late to the party, but... author here. AMA. :-)
- medo-bear 5y agodo you still use lisp ? i noticed a while ago you were working on a cryptographic project and i am sure you considered common lisp for this, but didn't pick it. is there a reason for this ?
- lisper 5y agoYes. In fact, I do almost all of my coding in Common Lisp. I'm even getting paid for some of it :-) I'm working part time for Intel helping them maintain an internal design tool written in CL. I run my own email server that runs a spam filter that I wrote in CL, and the e-commerce system that processes orders for my crypto dongle is written in CL. As an exercise I wrote a sudoku solver in CL a while back.
- zascrash 5y agosorry to ask, but what about that cryptographic project? why didn't you pick CL?
- lisper 5y agoBecause that product was an embedded system running on a very small SoC. It only had 1MB of flash and 192k of SRAM. It's theoretically possible to run CL on a system that small -- Coral Common Lisp ran on a Mac Plus with 1MB of RAM back in the 1980s -- but nothing off-the-shelf will do that today. (I did, however, put a little Scheme interpreter on it as an easter egg :-) I do have some CL code that supports the crypto project. The back-end for this: https://stage.sc4.us/sc4/sc4tk.html https://stage.sc4.us/sc4/sc4tk.html is written in CL (though all the actual encryption is done client-side in Javascript). I also have some prototype crypto code that I don't really use for anything, including this double-ratchet implementation: https://github.com/rongarret/tweetnacl/blob/master/ratchet.lisp https://github.com/rongarret/tweetnacl/blob/master/ratchet.l... and some elliptic curve code: http://www.flownet.com/ron/lisp/djbec.lisp http://www.flownet.com/ron/lisp/djbec.lisp
- AnimalMuppet 5y agoTL;DR: Because it uses a minimal representation for data (S expressions). This makes it much easier to write representations of data (compared to XML, or even JSON). This makes it easier to represent code as data, and that opens up the whole world.
- chmaynard 5y agoYes, but read the post anyway.
- AnimalMuppet 5y agoAgreed. It's worth reading. My TL;DR was not meant to imply that it wasn't.
- kazinator 5y agoPlus, that can be in addition to having JSON too. This is the TXR Lisp interactive listener of TXR 271. Quit with :quit or Ctrl-D on an empty line. Ctrl-X ? for cheatsheet. 1> '#J{"foo":[1,2,3,"bar"]} #J{"foo":[1,2,3,"bar"]} What is that literal syntax? 2> (typeof '#J{"foo":[1,2,3,"bar"]}) cons cons-cell based object under the hood. 3> (car '#J{"foo":[1,2,3,"bar"]}) json 4> (cadr '#J{"foo":[1,2,3,"bar"]}) quote It has a (json quote ...) structure. 5> (caddr '#J{"foo":[1,2,3,"bar"]}) #H(() ("foo" #(1.0 2.0 3.0 "bar"))) Followed by a hash table object. We can convert that to a vector to see it all: 6> (vec-list '#J{"foo":[1,2,3,"bar"]}) #(json quote #H(() ("foo" #(1.0 2.0 3.0 "bar")))) Now actually eval it instead of quoting 7> #J{"foo":[1,2,3,"bar"]} #H(() ("foo" #(1.0 2.0 3.0 "bar"))) The embedded hash table denoted by the literal is regurgitated. We can quasiquote JSON: ;; ^ is quasiquote in this dialect not ` 1> ^(,(+ 2 2) ,(list 1 2 3)) (4 (1 2 3)) ;; cannot use , in JSON for unquoting, so ~ is used: 2> ^#J["foo", ~(+ 2 2.0)] #J["foo",4] The quasiquote can be pattern-matched: 3> (match ^#J[~x, ~y] #(1.0 "foo") (list x y)) (1.0 "foo") Or, using JSON syntax on the right side, which produces the same vector: 4> (match ^#J[~x, ~y] #J[1.0, "foo"] (list x y)) (1.0 "foo")
- throw10920 5y agoExactly - it's not about whether it's possible to represent code as data (gcc is written in C, after all), it's about how easy it is. That's why Rust macros still don't come close to Lisp ones.
- firebaze 5y agoBetter question: why not Lisp?
- deleted 5y ago[deleted]
- Scarbutt 5y agohttps://groups.google.com/g/comp.lang.lisp/c/L5dZ-j6Id-s/m/9tOJorXPdW8J?pli=1 https://groups.google.com/g/comp.lang.lisp/c/L5dZ-j6Id-s/m/9...
- codr7 5y agoPerformance: Getting Lisp to run as fast as C takes major effort when at all possible. Resources: Lisp needs a lot of space to do it's thing; and while it's certainly possible to downsize it, you're left with something that's not really Lisp anymore. Ecosystem: Finding solid libraries is tricky since it's not very popular professionally. Power: Unleashing the full power of Lisp in a diverse team is a recipe for an adventure, if not disaster.
- agumonkey 5y agoIf performance was such a problem python wouldn't have a subreddit. I think a lot of lispers like handling various paradigms in their head and start with basic lisp, and resort to edsl to reach more appropriate semantics/mechanical sympathy. Just like people call out to C wrappers mostly. The social side of lisp I can't say for sure but I'm sure it's fuzzier than it seems. I've just talked to a dude saying his new guy was a clojurist and his thinking is way finer than the current team.
- hasmanean 5y agoLisp probably was invented in the age of the typewriter. If you look at mathematical notation, written with quill pens and paper…it’s even more concise. Functions are like lisp, f(x). Vectors are laid out on the page in an array and surrounded by two strokes. Matrices are a 2d array surrounded by two straight lines. This whole approach seems as archaic as Roman numerals is for representing numbers (they were based on lines and slashes like a tally system). Maybe there is an even better notation for representing code which will be as much a leap forward as the positional number system (which represents every number as a power series with base 10) was to numbers.
- AnimalMuppet 5y agoRoman numerals were based on lines and slashes? I mean, for one, five, and ten, sure. Fifty? Maybe. Beyond that? Not so much.
- jazzyjackson 5y agoI have a wonderful book in front of me called “From One to Zero: a universal history of numbers” by georges ifrah. chapter 9, roman numerals: a vestige of primitive origins? starts like this: —————————— I V X L C D M They are obviously letters of the roman alphabet, but this does not mean they have an alphabetic origin. The signs L, C, D, and M are not the original forms of the numerals 50, 100, 500, and 1000; they are altered forms of much older numerals. known instances of the use of L, D, and M as numerals do not go back much farther the the first century AD […] ————————— The chapter goes on to illustrate the resemblence with etruscan numerals and the tally marks of ancient shepards counting sheep, see the “tally marks” section of the wikipedia page, or borrow the book from archive.org, page 131 to 146 or so. https://en.m.wikipedia.org/wiki/Etruscan_numerals#Tally%20Marks https://en.m.wikipedia.org/wiki/Etruscan_numerals#Tally%20Ma... https://archive.org/details/lish00geor https://archive.org/details/lish00geor
- kazinator 5y ago> If you look at mathematical notation, written with quill pens and paper…it’s even more concise. Yes, but now mathematics publishing predominantly uses a typewriter-era language for achieving it: \documentclass{article} \usepackage{amsmath} \begin{document} \[ M= \begin{bmatrix} 1 & 2 & 3 & 4 & 5 \\ 3 & 4 & 5 & 6 & 7 \end{bmatrix} \] \end{document} Most programming takes place with what is more or less typewriting.
- codr7 5y agoWriting code that generates and compiles code in Lisp is just like writing any other kind of code. Writing a C program that generates and compiles C code is a major pita in comparison, same goes for most other languages. Even if you slap a different syntax on top, it's still a Sunday walk in the park to write a custom compiler. https://github.com/codr7/snabl https://github.com/codr7/snabl
- hesk 5y agoWhat's a good Lisp dialect to write small programs in? I have some Emacs Lisp experience but I wouldn't use it to automate small tasks. For that, I typically use Python.
- deleted 5y ago[deleted]
- zonotope 5y agoI think babashka [1] is what you're looking for. It's a limited Clojure interpreter suitable for anything a bash script is suitable for. 1: https://github.com/babashka/babashka https://github.com/babashka/babashka
- spicybright 5y agoI'd say the "python of lisp" is definitely racket. Beginner friendly, lots of batteries included, large community with lots of libraries. Here's an example of a simple webserver using the standard library: https://docs.racket-lang.org/web-server/run.html#%28part._servlet-env%29 https://docs.racket-lang.org/web-server/run.html#%28part._se... I'm also a fan of the first tutorial on the site. Instead of the boring stuff like hello world, 2+2, print your name etc, they use a built in library for drawing shapes to the console, and learn how to build up procedures for drawing more complex objects. It feels like learning to code with logo (which they also have a clone built in of https://docs.racket-lang.org/logo/index.html https://docs.racket-lang.org/logo/index.html) All the good stuff said, I've never used it for system plumbing scripts like I do with python. I'd imagine it's worse for that due to the sheer popularity python has. https://racket-lang.org/ https://racket-lang.org/
- hesk 5y agoThe homepage looks really interesting. I'll give it a try. Thanks!
- sometimesweenie 5y agoClojure through Babashka[0]. It's great for small tasks not related to your favorite editor. I use it for most of my scripting except for the really easy things in bash. [0] https://babashka.org/ https://babashka.org/
- Zababa 5y agoThat article partially validates my idea on why some people think that Lisp is such a force multiplier. The idea would be that compilers are one of the most important tool productivity-wise, and that Lisp allows you write your compilers yourself. That would also explain why not Lisp: First, libaries are the new important tool for productivity, and any language can have that. Second, a shared understanding is very important, either for building programs, or building the libraries. Writing your own compilers may reduce that shared understanding. You can see this in some ecosystems where there is a split between people using the language in different ways (OCaml with Async and Lwt, the few alternative standard libraries; Scala with Zio, Cats, the base language; C++ with C with classes, the standard library and probably a lot of other styles that I haven't met yet; JS with the "classic JS", the frontend framework people, the functional/immutable people; many language with the FRP). Shared understanding is important for building and maintaining software. You could also argue that it's important to make programmers more replacable. Another interesting thing is that some ecosystems are getting their macros: JavaScript has Babel, Coffeescript, Typescript.
- nemo1618 5y ago> Shared understanding is important for building and maintaining software. I think this is where Go (the language) really shines. Go is "boring" -- there are no macros, no operator overloading, no default arguments, none of that sort of thing. But if your goal is shared understanding, "boring" is a compliment. "Boring" means "after using the language for a few years, I can be confident that I will never be surprised by a piece of Go code again." (This has been true for me for at least 4 years.) In the same vein, Go famously doesn't support user-defined generics; the only generics it has are reified "builtins," baked into the language. People gripe about that, but the upshot is that every Go programmer understands the semantics of those builtin functions. They're Schelling points! When user-defined generics are added in the next version of Go, I worry that we'll lose some shared understanding. It will be a subtle shift, but the language will feel a bit less "cozy." :/
- pharmakom 5y agoI take a different view, that shared understanding comes from clear, concise code, which is not bogged down in ceremony. Lines of Go in isolation are easy to understand. However, Go is so lacking in expressiveness, that Go code-bases are hard to follow for any complex domain. The language doesn’t give you enough tools to tame complexity.
- slifin 5y agoAs someone that uses Clojure as a hobbyist I don't think I've ever used the fact it's a homoiconic language in my programs But I do suspect it's helping me indirectly it does make it easier to write static analysis tools for Clojure It does make it easier for IDEs to identify what expressions I'm sending to the repl And if I ever make a macro it will be helpful there For me the question of why lisp or why Clojure the answer would be much more broad A lot of the comments in this thread and the original article don't apply to all lisps
- libx 5y agoEveryday there's at least a post about Lisp. But I see none about TCL that is as regular in syntax as Lisp. Some call it a Lisp without parenthesis. TCL is also very stable between releases, it has industrial strength and threading support. But it lacks advocacy. It could get one tenth of what Lisp gets...
- lanstin 5y agoLisp compiles to native code, TCL is forever parsing the strings it passes around.
- kevin_thibedeau 5y ago> TCL is forever parsing the strings it passes around. No it isn't. Tcl has had dual-ported objects and a bytecode interpreter for over 20 years.
- lanstin 5y agoWell I learned something. But if you represent a list as a lift of strings wouldn’t it have to parse them as Argv in the c implementation? It has been a while but only 17 years since I wrote TCL commands but each one started with a list of strings. Maybe the byte code interpreter doesn’t work with older C extensions? But the main selling point of TCL was easy extension.
- pjmlp 5y agoOnly if you were using the pre-Tcl 8 FFI API, our startup was built on a Tcl "Rails" similar to AOL Server, and we did plenty of native bindings.
- pjmlp 5y agoTcl is quite nice, having been part of a product similar to AOL Server, I never got the hype around Rails.
- Zababa 5y agoI think at some point we should clarify why we mean by Lisp. I see a lot of mention of Clojure, while most people seem to assume that Lisp == Common Lisp. I feel like talking about Common Lisp, Racket, Scheme, Clojure at the same time while putting them all under the "Lisp" umbrella seem to be a bit pointless when we're talking about languages. It's like mentionning JS in a conversation about C because "JS is a language with a C-style syntax and macros (with Babel)". That's true but it's a totally different languages, and that's without even mentionning the different implementations of C and JS.
- delegate 5y agoI look at it as an intersection between the feature sets of Common Lisp, Clojure, Scheme, etc. In other words - the most basic features of these languages that are common - S-expressions, data is code is data, REPL-driven development, etc
- Zababa 5y agoThat's a nice way of looking at it, but that means we can't really talk about libraries, performance, dev tooling and stuff like that.
- dunefox 5y ago> It's like mentionning JS in a conversation about C It's not. It's like mentioning C++ in a conversation about OOP which is why Lisp is the appropriate umbrella term. For me, CL means Common Lisp.
- pddpro 5y agoI started my programming in the more "traditional" way i.e., C/C++ and then later python. When I started doing python, I was flabbergasted to find that I could just do 100**100 and get a complete number without using any additional libraries. Similarly, reversing string was trivial using the [::-1] notation. Heterogeneity of Lists, Dictionaries and the resulting versatility blew my mind. I now understand that I was discovering, at that time, what dynamic language had to offer over static languages. I say all this because I would really like some great examples and use cases which would sort of highlight what LISP has to offer over the, for the lack of a better word, non-LISP languages. All of the articles that pop up in hacker news or other portals only seem to highlight the fact that LISP presents a new paradigm (?), enhances intuition (?), and that LISP macros are the best-thing ever. I would like to share the sentiment but ideally via a few digestible examples in lieu of a serious commitment required to basically learn an entire language. I would appreciate a few concrete examples (very much like [::-1] and 100**100) that would allow me to get what LISP really is about.
- tmm84 5y agoSimple digestable examples that show off power is kind of a cart before horse situation. However, I will try to feed your curiosity. One simple example I can describe is from the book Practical Common Lisp and it is talked about to some degree in the SICP videos. The idea of the environment being captured as well as what it points to is a big idea. At the risk of not getting it explained 100% to everyone's satisfaction I would suggest reading about it. I also would suggest the problem of the N queens board. It is a pretty good starting point into how this problem can be solved in lisp. I suggest the MIT SICP lecture on it because it is well paced and interesting. Also it shows off some, for the time, advanced language features. Another good read is Norvig's PAIP book that you can read on Github. Lots of problems you can jump to with pretty good explanation in my opinion. I'm sure there are more interesting things I could point to. However, I still consider a read of Practical Common Lisp a good starting point. The book is fairly well paced and not bogged down with learn all the language first-isms. Also, the SICP videos are pretty good to watch. I hope these points are helpful to you.
- medo-bear 5y ago
- gaze 5y agoWhy does it feel like there’s more prose about lisp being written than lisp code? I swear there’s like 15 people writing Common Lisp — Nikodemus, Shirakumo, Stylewarning, Christian Schafmeister, Borodust, the ITA folks, and maybe 2 startups.
- vindarel 5y agoalso me o/ and https://github.com/azzamsa/awesome-lisp-companies/ https://github.com/azzamsa/awesome-lisp-companies/ (but I understand your feeling^^)
- dreamcompiler 5y agoHere are over 16k repositories. They're certainly not all by 15 people. https://github.com/search?q=language%3A%22Common+Lisp%22&type=Repositories&ref=advsearch&l=Common+Lisp https://github.com/search?q=language%3A%22Common+Lisp%22&typ...
- hajile 5y agoThere are three commercial lisp companies that continue to exist selling CL platforms. They exist despite SBCL being faster. They even make stuff like tools to build iOS and Android apps in CL. They didn't invest the money building that that out for no reason. The companies that use lisp don't tend to talk about it. For example, a company I worked for only talked about their Ruby/rails and javascript stuff publicly. It was only after I hired that I found out that the mission-critical core software was written in Common Lisp.
- bmitc 5y agoI love Lisp and Scheme and all their relatives (Clojure, Logo, Racket, etc.). However, the fact of the matter is, Common Lisp has not kept up with modern developments in terms of presenting a cohesive ecosystem with forward momentum. Everybody is off on their own doing their own thing with no shared goals or cohesion. Clojure seems to have this (I have not used Clojure much, so I don't really know). Elixir definitely has this. I think Elixir is the language ecosystem to look at in terms of having a solidified core language that is essentially done, and now the goal is to continue to flesh out the ecosystem with things like Nx, Axon, Livebook, Liveview, Mix improvements, Phoenix, etc. Elixir is pretty similar to Lisp/Scheme anyway given its macros, ability to live update, dynamically typed programming, but it goes well beyond any Lisp/Scheme (and many modern languages) in terms of having a practical but expansive ecosystem with a strong set of idiomatic conventions.
- lukego 5y agoThere was one cohesive tribe in the 00s centered around the quasi-annual European Common Lisp Meeting. I miss that and wish I could find the same thing again now. Maybe it exists somewhere online? The ELS community is still going strong. They have done a great job with continuity and moving forwards. That's a related but different tribe though.
- brabel 5y ago> ... it goes well beyond any Lisp/Scheme (and many modern languages) in terms of having a practical but expansive ecosystem with a strong set of idiomatic conventions. Does it, really?? Common Lisp is an ANSI Standard, I don't know how you get a more "strong set of idiomatic conventions" than that. And it's been "done" for 20 years now! People continue to use it just as it is, and there's very little pressure to change it because it simply works! You're trying to justify a new wave of "modern" languages with a very weak argument... just call it for what it is: you want "cool", hyped languages to succeed despite the fact they offer nothing that the CL standard did not 20 years ago.
- tho23u4i23o4 5y agoIn fairness, the CL spec being quite old, has a fairly dated type system. Obviously, CL is still blazing fast compared to Python, but it can't easily do the kind of things that Julia or even C++ can when it comes to numerical programming. You can write a lot of macrology to get around it, but there's a point where you want actual compiler writers to be doing this.
- clownpenis_fart 5y agoevery article about lisp is basically some guy jerking off because they discovered meta programming
- jimbob45 5y agoLisp seems a lot like Linq to me where it's an undeniably cool part of a language but crucially, just a part. If you plop Linq down on someone's lap, they're not going to know what to do with it. If you give someone Linq in the context of C#, suddenly it's the greatest thing you've ever laid eyes on. Likewise, if you're using Lisp within the context of some other language for scripting, it's fucking phenomenal. If you try to use it on its own to build a whole project from 0 to 100, you're going to be confused as to why you're not using a different language.
- musicale 5y ago(because)