[HN Gopher] Ansible is a Lisp?
       ___________________________________________________________________
        
       Ansible is a Lisp?
        
       Author : soopurman
       Score  : 40 points
       Date   : 2024-05-05 17:56 UTC (5 hours ago)
        
 (HTM) web link (astrid.tech)
 (TXT) w3m dump (astrid.tech)
        
       | axblount wrote:
       | Not everything that can be represented with s-expressions is a
       | lisp. For example:                 (html         (body
       | (h1 "Hello, World!")))
       | 
       | This does not mean that HTML is a lisp.
        
         | anthk wrote:
         | Well:
         | 
         | This webserver in Maclisp http://up.dfupdate.se/httpd%20html
         | 
         | gave birth to this: http://up.dfupdate.se/ulml.html
        
         | anthk wrote:
         | Also, more than Lisp, clips would be a really good choice
         | there. Defining _constraints_ to configure a system? That 's
         | basically what literally Clips does.
         | 
         | https://www.clipsrules.net/
        
         | cess11 wrote:
         | OK, but what about the homoiconicity and syntax macros?
        
           | axblount wrote:
           | I don't know Ansible well enough to say for sure, but the
           | macro example seems like more of a C preprocessor style
           | "macro." I don't see how it's doing anything more than
           | filling in a template.
        
             | cess11 wrote:
             | It's executed at runtime, not before some compilation
             | stage.
        
           | simplify wrote:
           | "What is homoiconicity then? Typical definitions state that
           | it is simply "code as data", will point to a relationship
           | between a program's structure and syntax or note that the
           | program source is expressed in a primitive data-type of the
           | language. In the below, we will show that none of these
           | definitions make much sense."
           | 
           | https://www.expressionsofchange.org/dont-say-homoiconic/
        
             | cess11 wrote:
             | In this context it seems to refer to programming in a
             | language where the developer facing code is represented in
             | terms of data structure literals within the language. It's
             | a reasonable understanding of what is usually meant in a
             | Lisp-like setting. The code is a list, so you can trivially
             | construct and deconstruct executable lists, just like you
             | can trivially construct data carrying lists.
             | 
             | One could make clever quips that this isn't enough, you
             | need quote/unquote as well to make it practical, and is
             | that really implied by homoiconicity? Should we really use
             | this word? Maybe we should pay someone to make up a new
             | one?
        
         | mepian wrote:
         | I agree, recently I shared here a great article by Hayley
         | Patton on this exact topic: https://gist.github.com/no-defun-
         | allowed/4f0a06e17b3ce74c6ae...
        
         | saghm wrote:
         | You'd think this would be more understood given that pretty
         | much the whole point of lisp is to be pretty close to just
         | representing an AST without relatively few frills. The idea
         | that we can represent most languages with a tree-like structure
         | isn't particularly novel.
        
         | jimbokun wrote:
         | But that can be perfectly valid Lisp. Lisp libraries producing
         | HTML often look just like that.
        
         | btilly wrote:
         | Not all of HTML can be represented with s-expressions. The
         | following is perfectly valid.                   <b>Hello
         | <i>World!</b> Greetings</i> Earthlings!
        
           | MathMonkeyMan wrote:
           | I never noticed that, though "doesn't require a closing tag"
           | and "requires that there is no closing tag" ought to have
           | been hints for me.
        
           | LegionMammal978 wrote:
           | And yet it's semantically identical to
           | <b>Hello <i>World!</></b><i> Greetings</i> Earthlings!
           | 
           | You can see this by looking at the innerHTML, which is really
           | just a serialized form of the DOM tree.
        
           | ptx wrote:
           | Is it actually valid? W3C's HTML validator complains about
           | invalid nesting.
           | 
           | It might work because the HTML5 parsing algorithm produces
           | well-defined results for broken HTML, but I'm not sure that's
           | the same as "perfectly valid" - the spec calls such markup
           | "misnested" and "erroneous" [0].
           | 
           | [0] https://html.spec.whatwg.org/#an-introduction-to-error-
           | handl...
        
       | Attummm wrote:
       | This is quite a stretch to call Ansible, which consists of YAML
       | files with syntactic sugar and some light Python evaluation,
       | 'Lisp'.
       | 
       | I thought reading the article would make less inflammatory but it
       | didn't.
        
         | baq wrote:
         | Yeah I agree, Ansible would be so much better if it was Lisp-
         | first with a perfectly non-scary I'm-a-devops YAML syntax
         | instead of OMG-parens-nobody-understands-Lisp Lisp syntax.
        
         | jimbokun wrote:
         | It's a homoiconic language like Lisp, just with YAML instead of
         | s-expressions.
        
           | fargle wrote:
           | that's beyond a real stretch - is XSLT a LISP then? simply
           | using YAML (or json or any equivalent data/markup syntax as
           | the basis for a DSL syntax does not make it homoiconic.
           | 
           | in this case, the very rigid structure of playbooks and
           | tasks, etc. within YAML is also part of the syntax. just the
           | fact that you can _generate_ arbitrary YAML (or json or etc.)
           | from within a copy utility does not come close to
           | homoiconicity of a LISP. can you effortlessly move back
           | /forth from data to code? is everything both code and data at
           | the same time? what's the Ansible equivalent to quasi-quote,
           | for instance? is a bash script that sources (or creates or
           | evals) a list of variable assignments in bash syntax
           | homoiconic? due to eval, bash would seem a hell of a lot
           | closer.
           | 
           | and those really aren't "syntactic macros" either, unless
           | you'd be happy to define an MS-DOS .bat file that generates
           | and calls a .bat file fragment "syntactic macros". it's using
           | an external file ffs.
           | 
           | Ansible is good for what it does, but it has an extremely
           | limited and rigid "flow-control" (if we can even call it
           | that) and is more of a declarative language/config file than
           | a general language.
           | 
           | this represents a pretty naive superficial understanding of
           | these LISP features.
           | 
           | points for making us think though.
        
       | behnamoh wrote:
       | Either the author doesn't know what Lisp means (the "essence" of
       | Lisp), or just wants to stretch YAML to mean Lisp.
        
       | jeffrallen wrote:
       | See also https://en.m.wikipedia.org/wiki/Greenspun%27s_tenth_rule
       | 
       | "Any sufficiently complicated C or Fortran program contains an ad
       | hoc, informally-specified, bug-ridden, slow implementation of
       | half of Common Lisp."
        
         | anonzzzies wrote:
         | Yes, that's what I think off when I see ansible, not that it
         | actually _is_ a lisp. It's a poor hack for something you can
         | trivially do with lisp since forever. Like most of these things
         | and indeed Greenspuns rule says we will find that; you need the
         | solution for something complicated so you start building
         | something simple, add more features and end up with something
         | you should've done in lisp from the start. And of course now
         | you miss most (all) of the benefits.
        
         | sunshine-o wrote:
         | Blame the poor computer science education of most people
         | nowadays (could be self-taught or university).
         | 
         | Discovering that code is data and data is code is discovering
         | the moon. And inferring that your sad configuration management
         | system based on an ugly data language is kind of related to
         | Lisp must be mind blowing. Also bonus fact, XML is a lisp too !
         | 
         | Actually maybe we could have written ansible in lisp directly
         | to save us the trouble.
        
         | saghm wrote:
         | This quote has always seemed very strange to me. I feel like
         | the implicit argument (that just using lisp instead of making a
         | program that has more limited semantics that conform directly
         | to the intended purpose) is not a great one. Obviously
         | informally-specified, bug-ridden, and slow are not good things,
         | but I'd argue those are also not specific to Fortran or C but
         | just to any "sufficiently complicated program". People make a
         | big deal about the Church-Turing thesis, but I think it gets
         | taken too far sometimes because the important part of a
         | programming language isn't always what's possible to do in the
         | language but what _isn't_, and I'd argue most of the large
         | improvements in languages over time are about that; not having
         | undefined behavior, null-pointer errors, and runtime type
         | errors are all huge improvements in programming productivity
         | that only exist because we made languages that don't allow you
         | to do certain things.
         | 
         | At the end of the day, quite a lot of the work in programming
         | boils down to ensuring that what you wrote does _exactly_ what
         | you intend rather than behaving in some other way, and that
         | means identifying and eliminating places where it diverges.
         | There are a lot of common patterns for places where these
         | issues occur, and a language that can identify those patterns
         | and make it impossible for you to write a program that has
         | those mistakes is saving you time up front.
        
       | mattmein wrote:
       | Related: https://yamlscript.org/
        
         | baq wrote:
         | This is... beautiful.
        
       | medo-bear wrote:
       | My set of lego pieces is a Lisp
        
       | nathell wrote:
       | Bash is a Lisp, too.
       | 
       | https://blog.danieljanus.pl/2014/05/20/you-already-use-lisp-...
        
         | ptx wrote:
         | Bash feels more like a C buffer overflow vulnerability than a
         | Lisp: When you're not careful your data tends to leak across
         | its boundaries and get mixed up with your code.
         | 
         | Is there a way to quote data in Bash to safely insert it into a
         | piece of code, the way you can in Lisp?
        
       | James_K wrote:
       | > YAML as executable code
       | 
       | Why must we do these things to ourselves?
        
         | Zambyte wrote:
         | I don't think my aversion is actually YAML. I have been playing
         | around a lot with Benthos lately, and it is actually quite
         | pleasant.
        
       | lanstin wrote:
       | I thought this was going to be a python thing that exploited
       | functions returning functions with their lexical scope. I find
       | too many syntactical macros tends to encourage excessively dense
       | code. Tho I usually use packer and terraform to configure my end
       | VMs not ansible. A PR to either packer repo or territory repo and
       | push the button to recreate the resources.
        
       | fiddlerwoaroof wrote:
       | Actually, ansible is a prolog. I played around with marelle[1] a
       | bit for managing my Mac configuration and I realized that the
       | core of the typical configuration management tool just is a
       | prolog: it gathers facts from the systems you have, compares them
       | with a desired state you've specified declaratively and executes
       | a plan to get from the current state to the specified one. Prolog
       | does the planning more or less "for free" because of its
       | evaluation model.
       | 
       | [1]: https://github.com/larsyencken/marelle
        
       | sgt wrote:
       | Ansible is great, but using YAML still bugs me. Would just be a
       | lot easier with HCL (Hashicorp) or something else.
        
         | orwin wrote:
         | At my first job, we had a perl script to transform json into a
         | yaml inventory file (it then allowed us to serve a form to
         | clients that would act as a yaml, but i left a bit before the
         | feature was implemented). We still had to write our module in
         | yaml though.
         | 
         | Still, the greybeard who come up with the initial design and
         | architecture was the best dev i've ever worked with, to this
         | day. I wasn't ready to learn as much as i ought to do, sadly.
        
       ___________________________________________________________________
       (page generated 2024-05-05 23:02 UTC)