Live data from Hacker News

Ansible is a Lisp?

astrid.tech

31–40 of 45 posts

Re: Ansible is a Lisp?

#31
post #6

Earlier quoted context omitted.

OK, but what about the homoiconicity and syntax macros?

"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/

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?

Re: Ansible is a Lisp?

#32
post #6

Earlier quoted context omitted.

OK, but what about the homoiconicity and syntax macros?

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.

It's executed at runtime, not before some compilation stage.

Re: Ansible is a Lisp?

#33
post #24
post #2

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.

Not all of HTML can be represented with s-expressions. The following is perfectly valid. Hello World! Greetings Earthlings!

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...

Re: Ansible is a Lisp?

#34
post #4

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.

It’s a homoiconic language like Lisp, just with YAML instead of s-expressions.

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.

Re: Ansible is a Lisp?

#35
post #17

Bash is a Lisp, too. https://blog.danieljanus.pl/2014/05/20/you-already-use-lisp-...

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?

Re: Ansible is a Lisp?

#36
post #21

> YAML as executable code Why must we do these things to ourselves?

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.

Re: Ansible is a Lisp?

#37
post #35
post #17

Bash is a Lisp, too. https://blog.danieljanus.pl/2014/05/20/you-already-use-lisp-...

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?

In Bash, yes. Or, almost.

The printf built-in command has a %q conversion specifier which quotes the argument such that the result can be used as input into the shell.

Such a thing cannot be inserted into a quote without affecting its meaning, but what you can do is terminate the quote before and after it.

  'stuff before'$(printf "%q" "$value")'stuff after'
In this case, because it's a single quote, we need to terminate it anyway, order to activate the command substitution syntax.

Re: Ansible is a Lisp?

#38
post #12
post #4

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.

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.

I'm guessing you'd probably break the declarativeness if you exposed the full power of LISP, but limited subsets in YAML work pretty well.

I especially like how well suited it is to visual block based editing.

Blockly and Node Red let you put stuff anywhere in 2D space, a satisfying auto formatter isn't really possible, and traditional flow charts can easily get big and messy.

But if you look at DRAKON, their charts pretty much always look nice. And looking at ladder logic, It's almost but not quite a set of 1D flow charts.

If you strip it down more, events that trigger a list of commands until a command returns False is a really simple model without much learning time, and it's very easy to create a visual editor

Giving people the full power of LISP would probably result in people writing imperative programs rather than building up an ecosystem of declarative plugins though.

And it seems that the consensus is it doesn't become a LISP just because you can implement it in nested lists....

Re: Ansible is a Lisp?

#39

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."

Which are the dramatic examples of lead devs looking at a system, decided half baked configs/guis will start falling apart in a few years, so they moved to a powerful programming language? Blender and Maya getting Python scripting may be one.
Post reply on HN