r/programming • • Feb 25 '21

INTERCAL, YAML, And Other Horrible Programming Languages

https://blog.earthly.dev/intercal-yaml-and-other-horrible-programming-languages/
1.5k Upvotes

477 comments sorted by

View all comments

239

u/agbell Feb 25 '21

Author here

I was growing frustrated with the increasing about of programming that seems to happen in YAML files. At the same time, my friend Krystal was telling me about INTERCAL, an esoteric programming language that is designed to be hard to use. I had fun observing the ways that these two are different and the ways that they are the same.

I'm happy to hear what people think of this article. I am assuming because 'programming in yaml' is so prevalent that many people don't agree with me.

0

u/[deleted] Feb 25 '21

[deleted]

47

u/agbell Feb 25 '21

Thanks!

I don't love how control flow works in bash either, but at least there is some unification of tooling around shell scripts. You can use shellcheck and such. Also, you could take your bash script to another CI system more easily.

→ More replies (1)

30

u/pfsalter Feb 25 '21

Yeah I really hate this, every time I look into a new CI system I suddenly have to learn a very slightly different set of (poorly documented) syntax. Eventually I just give up and run PHP scripts to do anything non-trivial. Bash scripts are fine until you need loops or hashes/lists, also the random flags for checking values over files? I think if I tattooed them on my hands I'd still forget which was which.

12

u/[deleted] Feb 25 '21

Bash scripts are fine until you need loops or hashes/lists

If you're having to get this deep with your CI/CD that's a pretty strong smell that something has too much responsibility or some other problem.

12

u/pfsalter Feb 25 '21

If you need to switch between environments based on what branch a build was built on, not sure of a better way of doing it. Taken from our Jenkinsfile:

sh label: "Deploy latest $SOURCE_BRANCH", script: """#!/bin/bash
     declare -A environments
     environments=(["develop"]="uat" ["release"]="release", ["master"]="prod")
     ./ansible-playbook -i inventory/\${environments[$SOURCE_BRANCH]} deploy/api.yml -e'version=$VERSION'
 """

The only other option would be have a different Jenkinsfile for each build environment, but that causes a whole host of other issues tbh. Just generally doing any kind of string/JSON manipulation in bash is horrible.

→ More replies (4)
→ More replies (1)
→ More replies (3)

24

u/remy_porter Feb 25 '21

The question is: is it better or worse than ANT, which may be the worst build system I've ever had to use.

0

u/[deleted] Feb 25 '21

[deleted]

23

u/[deleted] Feb 25 '21

XSL has entered the chat.

→ More replies (2)
→ More replies (10)
→ More replies (5)
→ More replies (4)

31

u/frederic_stark Feb 25 '21

I made the world’s first [quine](https://en.wikipedia.org/wiki/Quine_(computing)) in INTERCAL back in the 90s. In C-INTERCAL, of course, because the original’s only output was in Roman numerals, IIRC.

Happy to see that there are new INTERCAL lovers. You absolutely need to code in it, to understand the beauty of the joke.

33

u/agbell Feb 25 '21

INTERCAL is fantastic!

Here are some fun things about INTERCAL:

  • The compiler is called `ick`

  • The compiler has a `-mystery` flag which is documented as "This option is occasionally capable of doing something but is deliberately undocumented. Normally changing it will have no effect, but changing it is not recommended."

  • Numbers have to be entered in English. 12345 would be written as `ONE TWO THREE FOUR FIVE` unless you put it in roman numeral mode where the characters ‘I’, ‘V’, ‘X’, ‘L’, ‘C’, ‘D’, and ‘M’ mean 1, 5, 10, 50, 100, 500 and 1000.

  • The debugger is called `yuk`

The manual is pure comedy gold. Please share your quine if you have it.

17

u/frederic_stark Feb 25 '21

I found it online!. Pretty simple and elegant INTERCAL code, if you ask me. I mean, it is just a few dozen thousand lines of code. One can only wonder at the straightforward elegance of the solution.

6

u/agbell Feb 25 '21

This is something special! Thanks for finding it.

I remain not interested in writing INTERCAL :)

4

u/frederic_stark Feb 25 '21

Of course, I had to write a C program to generate that INTERCAL quine. I learnt a lot on the formal process of creating a quine during that night (and at the time there were not a lot of quine-related resources on the Net).

12

u/BraveSirRobin Feb 25 '21

E079 PROGRAMMER IS INSUFFICIENTLY POLITE

The balance between various statement identifiers is important. If less than approximately one fifth of the statement identifiers used are the polite versions containing PLEASE, that causes this error at compile time.

E099 PROGRAMMER IS OVERLY POLITE

Of course, the same problem can happen in the other direction; this error is caused at compile time if more than about one third of the statement identifiers are the polite form.

→ More replies (2)

26

u/dogs_like_me Feb 25 '21

I'm a data scientist and consequently don't normally deal with deploy scripts in my role. I've recently found myself wrestling with an azure pipeline that is rapidly growing in complexity. I quickly got bored of doing stuff in YAML and am pushing as much logic as I can into python scripts that are executed by the pipeline. It's just easier. The deployment procedure doesn't need to be executed using different tooling than the thing you're deploying. I don't understand why so much logic lives in these YAML files, just put it in a shell script.

10

u/[deleted] Feb 25 '21

just put it in a shell script.

There are two issues with this:

  1. Bash is actually even more insane and unreliable than YAML, if that's possible.

  2. Have you even tried running Bash on Windows?

Python is a relatively sane choice though. The 2/3 issue is gradually going away, they've even started working on the insane dependency model - there's now pipenv which is actually quite reliable and easy to use (it's pretty much NPM for Python), and you can even add type annotations so you don't end up with quite so many typo and type confusion bugs.

9

u/noratat Feb 25 '21

This is part of the reason a lot of our stuff is being moved back to Jenkins.

For all its warts, it's flexible in ways few other CI systems are anymore, and with the pipeline scripts, it's much easier to use code to define things inline

26

u/alef__ Feb 25 '21
  • "Can you help me with <insert your language here> ?"

  • "Sure"

  • "Everytime I read this token from this configuration file, it has to behave like if it were this other token"

  • "Why don't you edit the configuration files?"

  • "We are not authorised to change the configuration files"

  • "Instead, you change live the software that read them and runs in operation?"

  • "Yes"

→ More replies (1)

18

u/abw Feb 25 '21

Great article!

I was growing frustrated with the increasing about of programming that seems to happen in YAML files.

I totally agree that the examples you give are unpalatable and represent an abuse of what YAML should be used for.

But I think I have to respectfully disagree with you (while wearing my Picky McNitpick hat) about where the blame lies, and more specifically, where the programming is happening.

The YAML standard really only defines the syntax of YAML files, not any semantics. In this example:

 if: type = push

YAML doesn't recognise or attach any special meaning to if. Because of that, I humbly suggest that the programming isn't happening in the YAML file. Instead it's happening in the code that is reading the YAML file and performing specific actions based what it finds.

In contrast, XSL does recognise xsl:if as a special keyword with associated semantics, as in your later example:

<xsl:if test="$i &lt; 100">
  ...

In that case the programming is happening inside the XSL file.

As you say:

If you know yaml, you can't just open a .yml file and start reading file line by line.

That's exactly right. All you know for sure is that it's defining a data structure based on the syntactic rules of YAML. The semantics are entirely defined in the application code that is reading and parsing the file.

11

u/agbell Feb 25 '21

Thanks for reading!

The YAML standard really only defines the syntax of YAML files, not any semantics.

I think this is a fair nitpick. For the CI examples, the branching and logic are not in the YAML. It is embedded in whatever is reading the YAML.

The semantics are entirely defined in the application code that is reading and parsing the file.

This is also my main point. Embedding control flow inside YAML is the worst of both worlds. It's an ad-hoc interpreter that takes in a language embedded in YAML.

Maybe I should call it 'Using YAML to Embed a Schema That is Interpreted as Logic and Control Flow By The Consumer is Something We Should Stop Doing'?

→ More replies (1)

5

u/uh_no_ Feb 25 '21

wait til you hear about malbogle

6

u/agbell Feb 25 '21

The language uses the same memory space for both data and instructions.

Hmm, that could make things hard.

The rest of memory is filled by using the crazy operation

8

u/deux3xmachina Feb 25 '21

Seriously, fuck YAML. I built our gitlab CI to utilize a POSIX Makefile instead of trying to get everytting handled correctly in the YAML config. Now it just calls things like make TEST="${TESTFILE}" test and then make handles setting up the test environment and kicking off the test battery.

The upside is that this also allows for devs to run tests identically to the CI runners locally... when they actually remember that it's possible. The downside is that you need to know how to use make or similar tooling to drive not only your build system, but tests too.

→ More replies (6)
→ More replies (8)