Re:An Intuition for Lisp Syntax
by threatofrain on Thursday May 27, 2021 @09:06PM
(#27310633)
YAML sort of addresses this, but I really wish companies would just go with Lisp when they want to do weird DSL's, such as, ahem, Ansible with their weird YAML. As weird as Lisp is, it can never be as weird as learning idiosyncratic languages for different products. It is the most minimalist machine-human compromise for lists of lists.
[ Parent
| on HN ]
Re:An Intuition for Lisp Syntax
by eyelidlessness on Friday May 28, 2021 @02:19AM
(#27312298)
Yes, let’s dump YAML. Yes, let’s dump arbitrary DSLs for declarative data structures. Yes, let’s adopt a lisp’s syntax. Just... let’s adopt the one (EDN) with more than one kind of bracket, some kind of traction, a surprisingly good mapping to static types, and a surprisingly robust compatibility with existing tooling (Transit).
Re:An Intuition for Lisp Syntax
by eyelidlessness on Saturday May 29, 2021 @12:30AM
(#27323037)
It’s true there are some rough edges here, notably mostly in the actual Clojure(Script) implementations (unfortunately unsurprising) rather than in EDN. Also worth emphasizing that Transit addresses many of the issues highlighted (as well as EDN’s biggest downside outside the Clojure ecosystem: it’s slow).
YES! Preach! Stop making me write DSLs in things that aren't programming languages, and start using programing languages that naturally allow DSLs.
There are places where it makes sense. I don't love Kubernetes' YAML, but it makes sense as a serialization format. I think LISP would be out of place here firstly because your serialization format really shouldn't be executable, and secondly because it offers few advantages. You can implement any DSL you want and just have it output YAML.
Ansible really should have ditched the YAML format a long time ago. The YAML is practically designed to be executable; I'm almost surprised that you can't add a shebang line pointing to Ansible at the top of your YAML. I'm actually a little surprised they've never offered an option to write parts of your Ansible setup in Python.
I would love to make some of my roles and my playbook into Python code. I am forever googling the syntax to set up a loop in Ansible YAML, as well as how to make dependencies between roles, which is pretty cleanly solved with Python modules (just import and execute the role at the top of your new role).
> I'm almost surprised that you can't add a shebang line pointing to Ansible at the top of your YAML.
You actually can do that, with something like:
#!/usr/bin/env ansible-playbook
---
- hosts: localhost
tasks:
- debug: var=ansible_distribution_release
It works pretty nicely, just remember to make your playbook file executable. It's a bit cumbersome though since you cannot use `ansible-playbook` arguments like `--limit`, `--diff`, `--check` and so on to have better control over the playbook execution.
Re:An Intuition for Lisp Syntax
by throwaway77112 on Friday May 28, 2021 @02:26AM
(#27312330)
What about UCL?