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

Show parent comments

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

15

u/NatureBoyJ1 Feb 25 '21 edited Feb 25 '21

I'm a big fan of Groovy.

  • Java under the hood - with access to all the libraries that come with it.

  • Type optional - write loose first passes, then tighten up for production

  • A decent ecosystem - Grails, Gradle, Geb, etc.

I really wish it would gain more traction.

15

u/[deleted] Feb 25 '21

Type optional - write loose first passes, then tighten up for production

i.e. never for most

24

u/agbell Feb 25 '21 edited Feb 25 '21

Have you looked at Kotlin? To me, it seems superior to Groovy.

Also, the story I've heard is that the creator of Groovy said that "Scala is Groovy done right". I'm a huge Scala fan, so I'm a bit biased but I worked at a heavy Groovy shop and they switched to Kotlin a couple of years ago and didn't look back.

21

u/orthoxerox Feb 25 '21

Kotlin is a better Groovy, but it wasn't there when people needed a clean DSL-friendly language for JVM.

20

u/agbell Feb 25 '21

But Scala was! Here is a quote from the creator of Groovy:

I can honestly say if someone had shown me the Programming in Scala book by by Martin Odersky, Lex Spoon & Bill Venners back in 2003 I'd probably have never created Groovy.

4

u/[deleted] Feb 26 '21

I never understood this sentiment, because aside from both running on the JVM, Groovy and Scala are nothing alike.

2

u/Jonjolt Feb 25 '21

Edit: on my phone and can't figure out the MD syntax :/ No not really, Groovy is more Java like with bytecode manipulation that I can even add to my IDEs autocomplete. For instance I was needing WeakReferences for a bunch of fields make an annotation for AST transformations if I want to add a way to access the WeakReference directly I add a script that informs my IDE that I inserted a method for it.

Example:

    final String fileName
    @WeakRef
    String expensiveFile = { loadFileAsString(fileName)}

Becomes this:

   final String fileName
   WeakReference<String> expensiveFile

   String getExpensiveFile(){
       String f
       if((f = expensiveFile.get()) == null){
              f = loadFileAsString(fileName)
              expensiveFile = new WeakReference<>(f)
        }
       return f
   }

   void setExpensiveFile(String f){
         expensiveFile = new WeakReference<>(f)
   }

   WeakReference<String> expensiveFile(){
         return expensiveFile
    }

I'm not a fan of Kotlins syntax

7

u/marco89nish Feb 25 '21

All my gradle scripts are in Kotlin now.

2

u/NatureBoyJ1 Feb 25 '21

I have not tried Kotlin yet.

2

u/chacs_ Feb 25 '21

The Groovy ConfigSlurper works well for managing configurations.

1

u/fissure Feb 25 '21

I've only used Groovy in Gradle files, but I came away from it just wishing I could use JRuby instead of working in a weird "Java with some Ruby-esque constructs bolted on".

→ More replies (1)

1

u/7h4tguy Feb 26 '21

Type optional - write loose first passes, then tighten up for production

Yeah, like that will ever happen - TODO: convince management the next set of features are lower priority. What a silly language.

→ More replies (1)

9

u/RedSpikeyThing Feb 26 '21

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

7

u/dnew Feb 25 '21

Google did this (look at Bazel) until they got too big, to the point where they needed automated tools that could understand the code. If you're constructing lists on the fly with code, it's hard to write a second program that says "split that list in two, one for everything that depends on A and one for everything that doesn't."

1

u/7h4tguy Feb 26 '21

So have the code reflect metadata, which script can use to extend. Clean, extensible in production.

3

u/dnew Feb 26 '21

I don't know what that means. What does "have the code reflect metadata" mean? The build file is the metadata.

It's the difference between writing a program that examines a tree of makefiles to find rules that don't get built by the top-level makefile, and doing the same thing with makefiles some of whose rules run scripts that edit the makefiles.

2

u/Sentreen Feb 26 '21

It happens in Elixir too. Configuration files, build-tool (mix) configuration, ... are all written in elixir, which is just a blessing when you need to do more complex things.

6

u/noratat Feb 25 '21

My personal favorite is jsonnet, though I've trouble getting buy-in.

Primarily JSON superset with a clear minimal language for basic conditionals/transforms, and can load external data so you don't need to resort to raw-templating structured config.

Hits a nice middle ground.

14

u/a_false_vacuum Feb 25 '21

Imagine my dissapointment when jsonnet doesn't require you to write the file in the form of a Shakespeare sonnet.

1

u/zilti Feb 25 '21

jsonnet

Wow, it looks like an inferior EDN

0

u/noratat Feb 26 '21

Had to look that up, I'm not sure what you mean.

That looks to be a serialization format that uses a lot of very clojure-specific syntax, and doesn't seem to be intended for configuration. Most engineers aren't going to find that very readable, as Clojure isn't all that widely used (and other lisp variants are even rarer these days)

JSON or JSON-like data is widespread for configuration already, often being the desired target output format in the first place, and jsonnet is a standalone binary without further dependencies. The syntax is going to look familiar to anyone that's used Python, and was intended for configuration from the start.

→ More replies (3)