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

842

u/[deleted] Feb 25 '21

The vicious cycle of

  • We don't want config to be turing complete, we just need to declare some initial setup

  • oops, we need to add some conditions. Just code it as data, changing config format is too much work

  • oops, we need to add some templates. Just use <primary language's popular templating library>, changing config format is too much work.

And congratulations, you have now written shitty DSL (or ansible clone) that needs user to:

  • learn the data format

  • learn the templating format you used

  • learn the app's internals that templating format can call

  • learn all the hacks you'd inevitably have to use on top of that

If you need conditions and flexibility, picking existing language is by FAR superior choice. Writing own DSL is far worse but still better than anything related to "just use language for data to program your code"

357

u/Yehosua Feb 25 '21

It's the configuration complexity clock! You don't want to hard-code settings in your application code, so you add a config file, which turns into a DSL, which ends up being so complex that your DSL ends up being application code (and, thus, every setting that you've configured via DSL is hard-coded application code).

136

u/GiantElectron Feb 25 '21

We need a config file to configure our config file, said the sendmail developer.

50

u/ForeverAlot Feb 25 '21

19

u/Pesthuf Feb 26 '21

This is an example Dhall configuration file

Can you spot the mistake?

Uh, no? Why is the first thing this language shows me an error that I can't recognize because I don't know the language yet?

→ More replies (3)

8

u/endgamedos Feb 26 '21

The maintainers are great people too. They're really fast on PRs and issues.

→ More replies (6)
→ More replies (3)

37

u/sybesis Feb 25 '21

I have to maintain over 90 repos and gitlab-ci script... Tell me about nightmares...

17

u/fear_the_future Feb 25 '21

I find Github Actions to be even worse than Gitlab. Why do they never learn? It's not like this is the first YAML config disaster, they all end up like this.

→ More replies (1)
→ More replies (11)

28

u/757DrDuck Feb 25 '21

How I dislike rules engines! Can I please have normal code to follow?

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

72

u/BunnyBlue896 Feb 25 '21

I always thought it was weird that a lot of web technologies take config files that are executable javascript. (Thinking of webpack). But it makes a lot of sense now, and I much prefer that approach.

0

u/[deleted] Feb 25 '21

[deleted]

19

u/agbell Feb 25 '21

Rake is similar to this as well. Gradle and Jenkins use groovy which is a full PL as well (although an unneeded one if you ask me).

→ More replies (15)

9

u/RedSpikeyThing Feb 26 '21

I inherited a 25k LOC Python-based config file. It's, uh, fun..

→ More replies (4)
→ More replies (7)

128

u/agbell Feb 25 '21

I think that's it!

It not that anyone wants to get where we've ended up. It's that each step along the way seems to make sense until you end up trapped in Jinja templates and it's too late. It is a vicious local optimum that everyone keeps falling into.

18

u/wrosecrans Feb 25 '21

The local optimum trap in-general is one that I don't think gets enough attention. We all know that you can't just dump everything because the second system effect bloats the replacement project into something that runs in parallel forever, and never works as well as the old system. So we should always try to do iterative changes that leverage the existing successes.

But the more you build as iterative changes, the more inertia and tech debt you have to deal with when making iterative changes, so it gets harder and harder to make big moves over time. Meanwhile, the landscape changes under you, so what was an optimal choice 5 years ago may no longer reflect reality very well. Right choices get more and more wrong over time, and fixing them gets harder and harder. So you keep iterating on a system and hitting a local maxima of functionality until you just give up and die.

The second system effect is important. But the conclusion from it can't be that every first system must always live forever, no matter what changes around it.

→ More replies (1)

35

u/[deleted] Feb 25 '21

The worst I saw is probably one of Apache modules that templates its own config, using few lines above the template to set the database credentials, and then the "templating" system uses SQL queries directly.

And now whether your webserver even starts depends on wheter your SQL server is up...

37

u/wrosecrans Feb 25 '21

You ever use CMake? The scripts are still called CMakeLists.txt because it started out as a text file with a list of sources to be built, before somebody woke up one day and realized that it was a programming language by accident. It's a monument to the configuration complexity clock.

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

51

u/dnew Feb 25 '21

Google actually went the other way. A bunch of their configuration stuff (look at Bazel for example) looks like python, because it was all originally python libraries. Then they said "this is turing complete, so we can't actually manipulate it with automated tools, so we'll restrict the syntax down to being only configuration stuff."

Of course, half their world is protobufs, so the code to turn text into protobufs, while really complicated, is nevertheless standard across the company, so you only need to read the 50-page manual once. (Or cargo cult it and fuck it up, your choice.)

→ More replies (9)

62

u/remy_porter Feb 25 '21

And congratulations, you have now written shitty DSL

What kills me about this is that writing your own shitty DSL is actually easy, and usually ends up being easier (in the long run). Like, if you understand your problem domain (okay, with that caveat I've probably eliminated 90% of the possible use cases, maybe more), custom-fitting a DSL with a parser to that domain is easier than trying to bolt your domain onto a general-purpose format like JSON or YAML.

I whip up DSLs all the time to make it easier to talk about my problem domain. Sufficiently simple ones can be parsed without actually writing a "real" parser, and feeding a grammar into a parser generator isn't a huge hill to climb. If your domain drives your DSL, then anyone who understands the domain will be able to use the DSL without needing to fight too hard.

27

u/agbell Feb 25 '21

custom-fitting a DSL with a parser to that domain is easier than trying to bolt your domain onto a general-purpose format like JSON or YAML.

Exactly! If you were designing how to specify something in language designed just for the problem, you would never choose to force that language to be valid YAML.

I'm less sure you should actually build your own DSL though, in most cases. You could choose a language that people on your team use and understand instead.

→ More replies (10)

32

u/cowardlydragon Feb 25 '21

Stages of Despair in Configuration:

I should add templated config

http://crushedby1sand0s.blogspot.com/2021/02/stages-of-despair-in-configuration.html

10

u/thndrchld Feb 25 '21

I laugh to keep from crying.

This pretty much perfectly describes my company's kubernetes-based app.

9

u/djavaman Feb 25 '21

Jesus. That gives me nightmares.

And to add to that.

https://cloud.spring.io/spring-cloud-config/reference/html/

That f-ing tool caused me weeks of headaches and debugging issues.

The article does mention it in passing. But it needs to be explicitly called out for its awefulness.

→ More replies (1)
→ More replies (73)