10 ms·
Lisping at JPL Revisited
- 082349872349872 4y agoBb looks suspiciously like an identity monad comprehension :)
- bsima 4y agoI was thinking similarly, reminds me of `do` notation in Haskell. Which is great, Haskell and Lisp are my two favorite languages :)
- revskill 4y agoIs a do notation same as chain of responsibility GoF pattern?
- Twisol 4y agoNot exactly (although maybe you could implement that pattern with the right choice of monad). do x <- [1, 2, 3] y <- [4, 5, 6] return (x + y) -- [5, 6, 7, 6, 7, 8, 7, 8, 9] Here we have a series of assignments followed by an expression computing a result. You can't tell directly, but this is using do-notation in the List monad -- an assignment `x <- [...]` picks a value from the list, then continues. In fact, this code is run once for every possible choice from the given lists, and all of the results are aggregated into a list. The earlier commenter referred to the Identity monad, which would look like: do x <- 3 y <- 5 return (x + y) -- 8 No special lists this time -- what you put on the right is what gets stored in the variable on the left. This is what you're used to in any imperative language. I suspect `bb` is a little more special, because Ron mentioned it has similarities to LOOP. I'd guess it supports recursive definitions somehow, but it's not clear what the difference actually is.
- revskill 4y agoCurious to know how to implement Do pattern in an OOP language consistently.
- Twisol 4y agoGood question. "Do notation" is sometimes referred to as "the programmable semicolon", because how you go from one statement to the next depends on which monad you're in. (In the List example, the assignment `x <- [1, 2, 3]` forked execution three ways before proceeding to the next assignment.) In Java, the semicolon is pretty much fixed; you can't change the relationship between statements in any meaningful way. So you have to play tricks. You can implement the List example in a crafty but leaky way: do(() -> { var x = choose(1, 2, 3); var y = choose(4, 5, 6); return x + y; }); When `choose` is called for the first time, it remembers which choice it returns to you. When you `return` from the block, your result is stored, and then the function is re-executed -- except this time, `choose` will now return a different value (the next one). You can implement this in a rather small handful of lines, but it's very tight and clever code, and not at all obvious how it works at first glance. There's another way to do this, with chained `flatMap` calls, like: list(1, 2, 3).flatMap(x -> list(4, 5, 6).flatMap(y -> list(x + y))); ...but that's so different from "normal" use of a language like Java that readers and writers alike are likely to balk to some extent.
- rightbyte 4y ago'do' in Haskell is like PROGN right? I guess in a OOP langague like C++ it would be something like: foo1(); foo2(); return foo3(); ?
- agumonkey 4y agoprogn has a fixed meaning in how to sequence sub expressions do, afaik, just flips the written expression and use actual bind functions depending on the typeclass at point
- dragonwriter 4y agoDo isn't a pattern, its a notation for monad operations. Any pattern implementable in it can be reproduced in any language where there are objects which support monad operations by using those operations directly. Some languages (e.g., Scala and its comprehensions, which use monad operations rather than imperative operations over collections the way Python does) also have a do-notation-like syntax sugar, as well.
- agumonkey 4y agoi wonder what's the difference between CoF and a sequence of conditionals (except maybe being reified at the application layer and potentially adjusted without changing source, a bit like a macro)
- mwcampbell 4y ago> Different people like different things, and that's OK. Drink whatever is the best fit for your palate, and code in whatever is the best fit for your brain. Doesn't this ignore the need to work together and build on each other's work? To me, that's not about companies being able to treat programmers as interchangeable, but about us collectively building higher, i.e. building towers of Babel rather than suffering from the curse of that story.
- Twisol 4y agoTake one: We need people moving together just as much as we need scouts who can push ahead and find the best paths for the rest of us. Take two: Working in the best fit for your brain is not incompatible with working with others -- enough companies are Java shops, why can't there be CL shops? (There are assuredly Clojure shops at the very least.) Take three: Not everything has to be about work. Programming is a skill, not an occupation; there are lots of ways to apply programming as a skill that don't require you to build large edifices in teams.
- jvanderbot 4y agoAnd how nice when those scouts lay groundwork that is useful for others, rather than creating something only they can use? Yes, you may think better in lisp than c++, but that doesn't help your team when you created something and moved right along. Better to speak the same language.
- Twisol 4y agoI was referring to the discipline as a whole, not scouting at the granularity of a single team. Also refer to take three: working in an industrial team is not a prerequisite for an application of programming to be valid. But to your very specific point: I have in the past developed prototypes in Rust whilst on a Java-only team. It's actually a good thing: these prototypes were meant to be thrown away, so working in a different language (and one that helped me model things effectively) meant we were forced to throw it away then write it right in Java once we knew what we were doing. (We did the same thing for another feature, but it was someone else and they preferred Python. Again, we were able to prototype more rapidly and then implement a solid solution in Java once we knew how things should shake out.)
- bifftastic 4y agoI wasn't aware of this: Clozure Associates is no longer a going concern, and the volunteer effort to port CCL to the M1 appears to have stalled. Sad news if true (and I have no reason to doubt it). I had kind of assumed that an M1 version of CCL would appear as a matter of course.
- phoe-krk 4y agoAFAIK the task is looking for volunteers (who have the necessary low-level knowledge) and/or funding. The mailing list at openmcl-devel@clozure.com has some threads related to it - see https://lists.clozure.com/pipermail/openmcl-devel/ https://lists.clozure.com/pipermail/openmcl-devel/
- lisper 4y ago> I have no reason to doubt it Point your browser at clozure.com if you want confirmation. (There's a reason I didn't include that link in the post.)
- batman-farts 4y agoAs a Lisp neophyte, I've been watching the Clozure CL situation with some interest -- I really want to give it a try, especially the macOS/Cocoa bindings, but my only Mac at the moment is an M1. A couple of specific questions I've been wondering about: 1) Does the port require a rewrite of the compiler? It seems like it was only ever released for 32-bit ARM, not even generic ARM64? How much of that work can carry over to an Apple Silicon port? 2) Will the announced rewrite of Core Foundation in Swift and/or the transition to SwiftUI put the CCL Cocoa bindings at risk of obsolescence anyway? My current job doesn't demand much coding out of me, so I feel lucky that I'm able to focus my personal learning efforts on interactive development environments like Lisp and Smalltalk, and grateful that solid free implementations are available in any event. If somebody does start up Apple Silicon CCL crowd-funding, I'd be in for at least $100.
- fithisux 4y agoFor me this is the year of Lisp. Julia and R for warm up, and then Common-Lisp. R7-Large Schemes do not seem to me ready (apart from Racket which is not R7-Large). Look the beautiful Handbook of Julia. R is full of documentation. Common Lisp is steadily improving. Schemes need something similar.
- tmtvl 4y agoOu of curiosity , what is the main problem you see with Gauche Scheme?
- lisper 4y agoAuthor here. AMA.
- tosh 4y agoWhat are you using Lisp for lately?
- lisper 4y agoI'm not doing a lot of coding nowadays. But for the past five years or so I have had a consulting gig helping to maintain and extend a tool for VLSI chip design written in Common Lisp. Unfortunately, I can't say anything more about that at the moment. Before that I wrote an e-commerce system that I used to run my company, Spark Innovations. It used Stripe for billing, Easypost for shipping, and Hunchentoot as the web server. I also wrote a spam filter that is still in production on my personal web server.
- krmboya 4y agoWhat does the Common Lisp consulting market look like? If one puts themselves out there (build reputation on the Internet) as a CL programmer, are they likely to land consulting gigs?
- eliben 4y agoThanks for writing this followup, Ron. This paragraph really resonated with me: > All this is a reflection of the so-called Lisp curse, the fundamental problem with Lisp -- its great strength is simultaneously its great weakness. It is super-simple to customize Lisp to suit your personal tastes, and so everyone does, and so you end up with a fragmented ecosystem of little sub-languages, not all of which (to put it mildly) are particularly well designed. I have a career-long love and admiration for Lisp, but I've never used it for "real" things because of this precise reason. I wanted my code to be understandable and modifiable by others who are already familiar with the programming language I'm using. With Lisp, it's almost guaranteed that any sufficiently large program will be written in its own dialect no one but the author knows.
- sampo 4y ago> even inspiring some people to plagiarize it That's not what plagiarizing means. Plagiarizing means to pass off as one's own. The website only copied the essay, without trying to pass it off as their own. They also linked to the original. What they did is maybe a pirate copy?
- vindarel 4y agoI find those exaggerated: > I don't really program in Common Lisp any more. I program in a little custom language that I have incrementally built on top of Common Lisp over the years so yeah, that's CL. ergolib is a CL library, like any other, with a cool macro to learn, if you want. > A CL programmer looking at my code would probably go, "WAT?" it's OK :] There are still defun and opening parens. > a fragmented ecosystem of little sub-languages but what sub-languages are we talking about? I only see a library with helper functions and macros. That's Common Lisp, not a derivative. You can pick any other library of the ecosystem, it's compatible, like Serapeum, another common library with many useful stuff baked-in, compatible with all CL implementations. I don't call that a fragmented ecosystem. Only some authors have their fav' utility and that's ok. Last words re implementations, for new readers: SBCL is thriving, LispWorks and ACL deliver, ABCL and ECL are active, CLASP (CL on LLVM) is financed and active, GNU CL got a new release, someone in Japan started a new implementation in C, someone else on Savannah another one in C again… And CCL is not thriving unfortunately :( There is room for contributors (there's some backing, contact the CL Foundation).
- lisper 4y agoIn Lisp, the boundary between a little macro library and new language is fuzzy. But my code looks pretty radically different from textbook CL code, much more different that, say, Scheme code looks from textbook CL code, and no one would dispute that Scheme is a different language. Maybe I should have said that I don't code in idiomatic CL any more. > SBCL is thriving... Indeed. The CL ecosystem in general is doing very well. It is only CCL that is fading away, and hopefully even that is only a temporary setback.
- phoe-krk 4y ago> but what sub-languages are we talking about? I only see a library with helper functions and macros. That's Common Lisp, not a derivative. If your language is a DSL factory, the line between your language and DSLs naturally blurs. If https://github.com/y2q-actionman/with-c-syntax https://github.com/y2q-actionman/with-c-syntax exists, does it mean that C is a DSL of Common Lisp, given a good enough standard library? If https://github.com/calyau/maxima https://github.com/calyau/maxima exists, does it mean that Maxima is just Common Lisp with more maths? If https://github.com/Shen-Language/shen-cl https://github.com/Shen-Language/shen-cl and https://github.com/coalton-lang/coalton/ https://github.com/coalton-lang/coalton/ exist, does it mean that Shen and Coalton are just a fancy way of writing Common Lisp in an immutable way? If https://github.com/froggey/Iota https://github.com/froggey/Iota exists and we can play sdlquake on Mezzano, does it mean that LLVM-IR is a dialect of Common Lisp? The above series of questions is not meant to be fully credible - it's meant to be food for thought.
- WalterBright 4y ago> It is super-simple to customize Lisp to suit your personal tastes, and so everyone does, and so you end up with a fragmented ecosystem of little sub-languages, not all of which (to put it mildly) are particularly well designed. This happens with any language that has macros, and why I have strongly resisted adding macros to the D language.
- gamache 4y agoI can offer a counterexample: the Elixir community, despite having a (very good) macro facility at our fingertips, is largely free of macro-mania as you describe it. Culturally, most folks use macros to import a few things into the caller namespace, or to wrap functions somehow (e.g., add timing metrics to every function in a module), and virtually all the functionality should reside in regular functions in regular modules, rather than having the macro inject a bunch of code that doesn't exist in a testable form. I'm not sure why we have it so good. Dreams can come true I guess. But I bet a community of low-level systems programmers might not be so well behaved :D
- WalterBright 4y ago> I haven't seen your code, so take this next comment as you see fit: Every person who advocates macros argues that they are not susceptible to the siren of creating their own incomprehensible and undocumented language. Every one who's code I had to work with, I'd point to it and say "what about that!" Even I was lured in by the Lorelei.
- pjmlp 4y agoTo be fair same applies when the languages have template metaprogramming with enough knobs, and nowadays it seems the answer to many inference issues in D is "write a template". Plus at least macros are much easier to debug than current infrastructure for D's string based mixins.
- WalterBright 4y ago> In every other language I have to think about whether to write op(arg1, arg2 ... argn) or arg1.op(arg2, ... argn) or "arg1 op arg2" In D these are interchangeable: op(arg1, arg2 ... argn) or arg1.op(arg2, ... argn) which is called Universal Function Call Syntax. It works very nicely. It enables a Left to Right reading of stacked function calls: a(b(c(d(1)))) becomes 1.d.c.b.a() which is a lot more readable.
- sokoloff 4y agoIf d takes two args, is there an inverted syntax as in “(1, 2).d.c.b.a” or must you do d(1, 2).c.b.a or something else?
- WalterBright 4y ago`1.d(2).c.b.a` and `d(1,2).c.b.a` both work
- oso2k 4y agoBeen almost 15 years since I was at the Lab but I don’t recall Lisp being at all popular. And I started there as a Perl & PHP developer before transitioning into Java.
- hvs 4y agoThe original article was written about 20 years ago and he says that by 1999 lisp was already falling out of favor (if it had ever been in favor). So, 15 years ago (2008?) would've been almost a decade after that.
- oso2k 4y agoI started at JPL in 2002 and worked with dozens of groups. Including many folks who had been at JPL since the 70s. No one ever talked about Lisp. I remember helping a former team member who had transitioned to ground systems port an old Mars Rovers Motif/Xt app to Qt (2 or 3?) on Linux. Blew his mind how much performant Qt was on the same hardware and with simpler code. He only ever mentioned being forced to use Ada for a few years and then being forced to port the code to C/C++ a budget cycle later. Probably around 2006. He had been at the lab since the 80s. But to be fair to the TFA’s author, prior to about 2007 when we got our first CIO, we could literally use almost any technology as long as it wasn’t illegal and wouldn’t get NASA, JPL, or CalTech in trouble. I ran databases & web sites with public IPs, ran myPHPAdmin, phpNuke, QTSS hosts and bunch of other crazy stuff with public IPs.
- deleted 4y ago[deleted]
- montmorency88 4y agoIs the source code for any of these really interesting JPL lisp programs available in a repo somewhere? e.g. I'd love to look through something like Eggemeyer's Plan-IT system referenced in the article.
- nickstinemates 4y agoI have started spending most of my time programming again after a long hiatus where I was primarily focused on business. One of the things I am picking up in the process is learning Common Lisp. I am tracking my progress here[1] Not for any particular reason, but because I think Lisp Macro/Metaprogramming is a fundamentally different thing that can only help expand my mind. 1: https://github.com/keeb/learning-lisp https://github.com/keeb/learning-lisp
- xwolfi 4y agoOr contaminate it with rot. Meta programming is an enormous risk in software, at least if the software has to last more than 20 years and maintained by more than 10 people. Every exemple I've seen, be it annotation aspects, script side loaders, preprocessing macros, "configuration" parsers etc has been a complete mistake vs writing what you want clearly, generate nothing or destroy the generator to let people touch the concrete thing rather than navigate a maze of indirection. I hope you ll end up expanding you mind with the conclusion that we should never program stuff that output other programs if what we want to program is the output.
- renewedrebecca 4y agoAh, a natural encourager, I see.
- nickstinemates 4y agoI am familiar with code generators (in general) and macros from other programming languages like C. And "no"/"lo" code solutions which behind the scenes are code generators. I have the same bias as you at the outset of this endeavor. But I also like to learn. Maybe there will be an aspect that will grow on me.
- 100001_100011 4y agoCan you say how you made AdWords' billing system impossible to hack by employees that had root access?