6 ms·
It warms my heart to know that astronauts are using LISP in space because they want to. On the other hand, I wonder how practical it is. I've more or less conve
by lopatin 6y ago
It warms my heart to know that astronauts are using LISP in space because they want to. On the other hand, I wonder how practical it is. I've more or less converted from LISPy langs to Python for real work because I was tired of re-inventing wheels and wanted to use libraries like Pandas that truly have no equals in the functional world.
Edit: Question: How many LISPers truly use homoiconicity? Can you share any uses of it in real world software?
- cat199 6y agolisp has a long history at nasa http://www.flownet.com/gat/jpl-lisp.html http://www.flownet.com/gat/jpl-lisp.html https://news.ycombinator.com/item?id=2212211 https://news.ycombinator.com/item?id=2212211
- lopatin 6y agoGreat reading, thanks
- astrobe_ 6y agoAnd so does Forth [1] ;-) I suspect the fact that Chuck Moore, the inventor of Forth, started his career at the SAO [2] and worked at NRAO later. The other one is the extreme compactness of the runtime, and his chip designs that got "radiation hardened" versions. The RTX2010 was used in ESA's Philae/Rosetta mission [3]. [1] https://www.forth.com/resources/space-applications/ https://www.forth.com/resources/space-applications/ [2] In Forth, The Early Days, Moore writes "At MIT [1958], John McCarthy taught an incredible course on LISP. That was my introduction to recursion, and to the marvelous variety of computer language. Wil Baden has noted that LISP is to Lambda Calculus as Forth is to Lukasewcleicz Postfix". [3] https://en.wikipedia.org/wiki/RTX2010 https://en.wikipedia.org/wiki/RTX2010
- Mediterraneo10 6y agoEven for hobbyist stuff, Lisp’s lack of libraries can be frustrating. I wanted to build some useful things as I was teaching myself Common Lisp, but there either was no library at all for what I wanted to do, or on Quicklisp there was just some bare-bones library that offered some meagre functionality but warned that most things hadn’t been written yet.
- vikramkr 6y agoI guess thats what something like clojure is supposed to fix? Interop with Java to give you access to that world? Not sure how that plays out in the real world though
- danielam 6y agoIn my experience, quite well, though I have not had to reach for Java libraries that often, either because Clojure equivalents exist, or because someone else had already put a wrapper around the Java library.
- billfruit 6y agoYes, but clojure toolchain system seems a bit brittle to me, especially the rather onerous use of leiningen etc.
- ithrow 6y agoInterop with Java to give you access to that world? Yes but it's a big time sink, you waste time thinking on how to wrap library, and for some libs you end hitting some blockers cause Clojure's interop is not that smooth, ending up writing two wrappers, one in Java(to make the lib usable from Clojure without pulling your out) and one in Clojure. And I'm talking about ad-hoc use of Java libs, writing a more idiomatic wrapper is a lot work. The Clojure ecosystem is pretty much abandonware at this point, even for high profile libraries. In languages with big ecosystems, you simply just use the lib and get work done, no cognitive overhead, no time sink.
- grzm 6y agoClojure Java interop has been pretty painless in my experience. https://clojure.org/reference/java_interop https://clojure.org/reference/java_interop It's pretty easy to translate things like import java.time.Duration; import java.time.Instant; import java.util.Date; //... Instant nowInstant = Instant.now(); Instant fiveMinutesAgo = nowInstant.minus(Duration.ofMinutes(5)); Date nowDate = Date.from(nowInstant); to (import '(java.time Duration Instant)) (import '(java.util Date)) ;; static method call with / (slash) (def now-instant (Instant/now)) ;; instance method call with dot. First arg is the instance (def five-minutes-ago (.minus now-instant (Duration/ofMinutes 5)) (def now-date (Date/from now-instant)) Implementing interfaces and extending classes are a bit more involved, but I haven't had to do much of that in my experience, and when I have had to, that's been pretty good, too. Here's an example implementing the AWS Lambda RequestStreamHandler interface https://github.com/aws/aws-lambda-java-libs/blob/master/aws-lambda-java-core/src/main/java/com/amazonaws/services/lambda/runtime/RequestStreamHandler.java https://github.com/aws/aws-lambda-java-libs/blob/master/aws-... (ns com.example.hn.handler (:gen-class :implements [com.amazonaws.services.lambda.runtime.RequestStreamHandler]) (:require [clojure.java.io :as io])) ;; implement the RequestStreamHandler handleRequest method (defn -handleRequest "echoes request" [_ input-stream output-stream _context] (let [w (io/writer output-stream) event (slurp input-stream)] (-> w (.write event) (.flush)))) That's probably shorter than the equivalent Java implementation.
- danielam 6y agoClojure fills this gap rather nicely, and you can always fall back on Java libraries, if necessary. If you haven't given it a try, I recommend it. Rich Hickey has put a good deal of thought into its design. Furthermore, you will have a much easier time finding companies that use Clojure than any other Lisp (and where they don't, you stand a better chance of convincing management to allow it at companies that make heavy use of languages that target the JVM).
- dunefox 6y agoABCL is on the JVM as well and it's a full Common Lisp.
- ashton314 6y agoI've been very impressed with Racket's standard library. While yes, for certain domains, you'll go further faster with Python and its libraries, Racket has got a surprising amount of stuff in it and it's well-documented! (I bring up Racket because DrScheme has since become DrRacket, and the aside on the article explains that the astronaut in question was working through How to Design Programs, which uses Racket as it's teaching language. Also, this is Shriram Krishnamurthi's blog, and he's one of Racket's principle creators.)
- nobleach 6y agoI was always a little confused about the relationship between Scheme->DrScheme->DrRacket. I had always just considered them all interchangable.
- neilv 6y agoScheme is a (very nice) standardized programming language, with many different implementations and dialects. DrRacket (previously called DrScheme, before rebranding) is a kind of IDE specialized for teaching intro-to-programming. DrRacket primarily supports various dialects of Scheme, including a series of ones that incrementally add language features, as a student progress through a textbook. You can also implement your own programming languages so that they work with DrRacket, and researchers sometimes build other tools on top of DrRacket. One unfortunate thing is that, for decades, many students have been taught using Scheme or DrRacket -- and were given the impression that Scheme is a toy language, suitable only for homework exercises.
- gus_massa 6y agoInside DrRacket you can use the Student languages that are somewhat simplified, or you can use the full version of Racket or even Typed Racket if you like typed languages. I think the main problem is that debugging is enabled by default. You get a nice error exactly in the spot of the error, but the program is much slower. (I usually use DrRacket with debugging disabled, and when some error appears I enable debugging and run the program again.)
- socialdemocrat 6y agoReally? I would think both R and Julia covers much the same functionality as Pandas. I don’t know R well enough but Julia can certainly be used in almost exactly the same ways as LISP with respect to being functional. There are even REPL plugins which lets you write Julia code using LISP syntax.
- dunefox 6y agoFor Julia there are PyCall and RCall to seamlessly use Python and R libraries.
- agumonkey 6y agoIt's not bullet proof, but I've seen people describe reader macros and macros for semi advanced stuff on old mailing list. To them it was a natural too to turn annoyances into natural pleasurable work (think not having to deal with xml/html as strings). There's a couple of papers on some japanese research lab that showed how to turn your common lisp code into pascal with the generic pretty printer. These sort of things seem to be trivial in the lisp world, whereas until a few years ago it was alienating topics for most of the industry (since we had the transpilers fever and jsx for instance)
- matheusmoreira 6y ago> How many LISPers truly use homoiconicity? Probably not many. Due to the need for performance, everything that matters will end up being compiled to a more efficient representation. Functions and complex data types could be represented as lists but no real world Lisp implements them that way anymore since it's better to have a dedicated function or hash table types.
- slaymaker1907 6y agoIn Racket it still gets used all the time with macros. Macros are can be used like a customizable JIT compiler if you need the performance. In Racket's case, you can even run the expansion step separately like a compiler since it separates macros out as a distinct execution phase. Functions aren't represented as lists at runtime, but you still get a lot of control via continuations. You can even serialize continuations to send them over the network or save it to disk. That does have security implications, but it is flexible and convenient.
- p_l 6y agoHomoiconicity has nothing to do with actually storing code as lists when compiled. However, Common Lisp source code is defined in terms of lists (with text being a separate serialisation thing) and every time you use a macro, or backticks, you depend on such definition enabling homoiconicity.
- slaymaker1907 6y agoI actually find Racket easier to work with than some mainstream languages. It just gets all the basics right. You don't need huge libraries like Pandas because the base language is reasonably fast and comes equipped with the powerhouse "for" macros that make most data processing easy. Macros are used all over the place in Racket and implement a lot of the core language. One of my favorite ones lately is the threading/pipeline macro. I think JS has been debating about this for several years now, but implementing this in Racket is not only easy (available as threading-lib if you don't want to write it) but better than if it were a core language construct. It can be better since using a syntax-parameter, you can rename any of the "keywords" necessary to implement said macro as a user of said macro if you want to. Also, since Racket macros track source line information, you don't need to choose between good error messages and performance. I also feel like Racket strikes a nice balance between dynamic and static. Function and variable names being misspelled is a compile time error, though types aren't checked at compile time. However, Racket had a very sophisticated contract system to help address that as well. If you really want something more thorough, there is even Typed Racket which has easy interop with the rest of Racket and is actually a sound type system unlike TypeScript. (There is apparently a way to bypass the runtime checks when calling untyped code, but this is done for performance and is uncommon, not like with TS where "any" lets you do whatever you want). I should also mention that while Typed Racket is a full language and does some pretty involved stuff besides just basic macros, people have also been working on a library that lets you create new type systems at the macro level by specifying the type reduction rules. One final advantage of macros in Racket's case is that by implementing language features as macros, it is easier to see what the overhead of some particular feature is. Looking at fully expanded Racket code is like looking at the disassembly in C except names are mostly preserved, stuff just moves around and new stuff names come in as well.
- travv0 6y ago> Question: How many LISPers truly use homoiconicity? Every time someone uses a Lisp macro they're taking advantage of homoiconicity. Homoiconicity is a characteristic of the language, not something somebody "uses."
- jcl 6y agoPer the article’s side bar, the astronaut was working through “How to Design Programs”, a book by several of the Racket contributors, including the article’s author, Shriram Krishnamurthi. As far as teaching languages go, scheme does have the advantage of having almost no punctuation to mess up. And DrRacket is a wonderfully beginner-friendly environment. I guess Hacker News might qualify as a real-world use of scheme/homoiconicity? I believe it runs on Arc, which runs on Racket. https://github.com/wting/hackernews https://github.com/wting/hackernews