top | item 37381409

DSLs are a waste of time

95 points| jaxxstorm | 2 years ago |leebriggs.co.uk

162 comments

order

eduction|2 years ago

We stop calling the useful ones “DSLs” so this is a truism.

Is SQL a “waste of time?” Regular expressions, HTML, Makefiles, CSS (and CSS selectors aka jquery selectors)?

It’s the bad ones that are a waste of time. The ones still called “dsl” instead of just “language, “format,” or “syntax.”

randomdata|2 years ago

> Is SQL a “waste of time?”

It certainly wastes a lot of my time because it is considered just a DSL and not a "real" programming language, and therefore doesn't get the same kind of attention towards making it better that "real" programming languages get. Maybe there is something to the original thesis.

Like, why can't I import shared query modules to compose into my queries? I can't imagine any other programming language without that feature. The execution engines support it in concept, allowing you to get there with some painful copy/pasting or using code generation (which seems to be how most people use SQL these days[1]). But because SQL is seen as just a DSL it doesn't get any attention towards making the language better.

[1] Which I'm not sure SQL is all that good at being the assembly language of databases either. It is strangely irregular.

dunk010|2 years ago

I think your examples are spurious and wrong, when compared with the specific kind of DSL the article talks about. SQL is a "Fourth Generation Language", much like Prolog, which is quite different to what is being discussed. HTML isn't a DSL; it's a type of SGML, a specific document markup language - you can't just shout "DSL" and squint a bunch and assume "All sort-of-languages are DSLs". Regular expressions, sure, but that's not relevant here because it's so universal - and mathematically backed (ever done a CS degree?) - that it's embedded inside every language now - i.e. this representation is a somewhat fundamental and mathematically general representation of interacting with strings - the DLSs in question here are, quite obviously, nothing of the sort.

The article is right. DSLs are, universally, awful, as they grow and grow until they encompass all features of a general programming language - but because of their evolution path the're awkward and twisted and lack basic features of a general programming language (and definitely lack all the tooling you get). Witness what happened with XML as a configuration language. What started off as another leaf node under SGML ended up - by way of the Java ecosystem - growing if statements and loops and all the rest, only in a horrendous, hard-to-read and harder-to-debug monstrous language.

So he's right. We should use real languages. And we should probably all just use Pulmi.

schmichael|2 years ago

JavaScript was a cute little DSL once too!

I feel like the author missed a more obvious comparison between Puppetlang and HCL: vendor specific languages.

When you consider them from that perspective it’s clear that the decision is based more on which company you trust to serve your long term needs over any point in time implementation details. Is that company Puppet? HashiCorp? Pulumi? The implementation details obviously matter but if you’re investing 7+ years into an ecosystem like the author did, then there are a lot more factors than just syntax.

SPBS|2 years ago

It's like (speaking) languages really. The good ones are ones that have always been there and people have just sort of accepted into the mainstream (like English). Don't invent your own language. If you can do it in an existing language, don't invent your own.

SQL and CSS selectors fit the bill. Everyone has just kind of accepted them now. It's not an excuse to try creating new languages for every new thing, it's an uphill task.

dybber|2 years ago

My take is that all embedded DSLs are bad. By embedding your DSL in another language you might gain certain things for free, but you also sacrifice a lot of control and often extra boilerplate code is necessary.

The exception of course is Lisp where embedded languages can feel like standalone languages.

kazinator|2 years ago

According to the article, the alternative to DSL is the programming language. So what the author understands as a DSL is some special-purpose language that is self-contained with its own run-time such that you have to string multiple of these to solve the task. Possibly, the author might have

The article doesn't discuss the possibility of building DSLs with the programming language and using them, all integrated together.

Yes, CSS is crap for instance. The web should have one language for everything in which styling is a DSL.

Regular expressions are better when they are in your language:

  2> (regex-compile '(0+ (or "a" "b")))
  #/(a|b)*/
E.g. we can cleanly stick something into a regex's syntax tree without worrying about escaping:

  3> (regex-compile '(0+ (or "*" "b")))
  #/(\*|b)*/
  4> (let ((x "[")) (regex-compile ^(0+ (or ,x "b"))))
  #/(\[|b)*/

bob1029|2 years ago

SQL would be my #1 example too.

It is probably the ultimate DSL if you are willing to get deviant with your tech stack.

diego_moita|2 years ago

> We stop calling the useful ones “DSLs” so this is a truism.

Bingo!

Lua was born as a DSL for configuration files. Today is way more than that.

JSON was born as a DSL for describing data, a less verbose alternative to XML. It is more than that.

chubot|2 years ago

FWIW this wiki page I started may help frame discussions like this:

Survey of Config Languages - https://github.com/oilshell/oil/wiki/Survey-of-Config-Langua...

It puts a bunch of languages in 5 cateogires.

Terraform is at least not a YAML DSL, a very common pattern which I don't understand the appeal of. I guess the main appeal is that you can copy and paste, and pretend it's data in simple cases.

But even Terraform suffers from the problem of "external" DSLs -- you end up needing a general purpose language. And yes this pattern has repeated itself so many times.

Awk and Make both grew into general purpose languages, and in Make's case it's particularly bad.

Most SQL dialects have also grown a pretty bad stored procedure language.

So I do think making internal DSLs in general purpose languages is more promising. But they have to be designed for it. There have been many attempts to use Python as a DSL/config language, but it's missing a few things for that, and gets awkward pretty quickly.

Ruby does a bit better, but it's not perfect either. It's fairly big and heavy if you just want a config file.

pydry|2 years ago

>Terraform is at least not a YAML DSL, a very common pattern which I don't understand the appeal of. I guess the main appeal is that you can copy and paste, and pretend it's data in simple cases.

It's easy to write an interpreter for - everything maps to either a scalar, list or a hashmap in any language.

It also looks pretty familiar to most people.

It gets abused an awful lot but so does every language that gets popular.

ohgodplsno|2 years ago

You can add other languages, such as Kotlin to that list. It is explicitly made to give you the ability to build a strongly typed DSL with proper scoping, references, validation, comes with all the benefits of a real language, including working language servers right out of the box that autocomplete everything properly. But that would require sysadmins to admit that editing all their config through nano with no syntax highlighting is an awful idea, no matter the amount of time they tell BUT WHAT IF I'M SSHING ON A SERVER IN ALASKA.

Despite all the complaints I have for Gradle (which, arguably, solves problems much more complex than "Ask AWS to burn through my cash"), its Kotlin DSL is impressively powerful and extensible.

marcosdumay|2 years ago

So, the author considers platform specification languages a waste of time, and has no idea what DSLs are (except that he knows about plartform specification languages)...

Yes, platform specification languages are a mess. Making them without the "language" part keeps all of the mess (the language is absolutely not the source of it). There are people trying to fix this, although I'm not sure if I'd place Pulumi on that group.

And DSLs are still a great software architecture technique with all kinds of applications.

AtlasBarfed|2 years ago

DSLs are often the advanced step to a programmer guaranteeing his future employment:

1) don't document

2) obfuscate

3) pick obscure language

4) implement with your own language

I will grant that the most succinct representation of a problem is a DSL, but DSLs are inherent obfuscation to some degree.

Just because a perfect mathematical representation exists doesn't mean anyone besides the author will understand it inherently

joshmarinacci|2 years ago

This really rings true for me. I’ve used many DSLs over the last 20+ years. Build systems. UI definition files. Orchestration languages.

They always start simple and easy, but they always eventually grow so complex that using a real language would be preferable.

I’ve never seen a system remain at the same level of complexity (or much less shrink) over a multi year timeline.

nly|2 years ago

This is simply because over times systems destructure.

Some developer eventually can't be arsed to stop and _think_ for half an hour about how to solve a problem, so proposes replacing the carefully thought out DSL with a Python script.

The typical programmer does have any respect for code they didn't write themselves or what it was trying to accomplish.

fishnchips|2 years ago

Marcin here, one of OpenTF folks.

I think the redeeming factor of Terraform is not the language itself, though I really like the fact that it's not a programming language. But I think the redeeming factor is the tool that interprets this language, and the fact that this tool can be taught new tricks - one of which is the CDKTF (not a fan, I think we can do better than that).

Here's an analogy. Most folks I know are at least skeptical about Java. The same folks would then praise Kotlin, Scala or Clojure as "good" JVM languages. The relative success of these languages owes much to the Java ecosystem and the JVM interop.

That's the reason I find Terraform worth saving. It's the JVM and the Java ecosystem of our cloud world. We can still build great things on it, whether you like HCL or not.

waffletower|2 years ago

This is a great takeaway from the article-- "programming languages are the better authoring model for cloud infrastructure". I was surprised by the simplicity of the "complex" terraform example the author offered, I have seen much thornier Terraform. The title, while appropriate for an article inspired by Terraform, I think misses the benefits DSLs have paricularly in LISP-derived ecosystems. A much better title for the article would definitely be "Terraform(ing) is a Waste of Time"

OhMeadhbh|2 years ago

Well... it's part of the cycle. First you create a declarative language to describe WHAT you want the infrastructure planner to generate. Then when your customers discover its limitations, you create a pulumi style imperative "infrastructure builder" language (or library). Then when people complain they have to do everything by hand, you create a different declarative language using whatever transfer syntax is popular that month. Then you keep repeating the cycle to ensure you have something to talk about on your blog every funding cycle.

Though... yes... I've had decent luck with DSLs in Lisp-land. It's not a panacea, and there's a couple months of training when we pick up new engineers, but for our app, it seems to work out fine.

PaulHoule|2 years ago

I like DSLs for many things but not for building out cloud infrastructure. It seems like the whole point of those things to build layer of complexity on top of layer of complexity. If any if those things meant you didn’t need to know all the thorny details of bash scripting, charsets, quoting and all, they might be a met positive but as they don’t you might as well write some bash scripts.

OJFord|2 years ago

I think calling terraform a DSL in comparison to general purpose programming languages misses the point. If it used a declarative GPPL instead of HCL I wouldn't care, but imperative alternatives general purpose or not are 'a waste of time' & not fit for the domain, IMO.

jen20|2 years ago

CDK for Prolog would be quite the trip.

As it turns out, what matters is whether the model is declarative. As some uses of YAML go to show, declarative vs not is an orthogonal axis to how general purpose or otherwise a language is, and orthogonal again to whether it looks like a configuration file or code.

gregmac|2 years ago

Pulumi is an example that proves the exception: using a general purpose language, you create a declaration of desired state.

Think of it like if you used a GPPL to emit HCL. You get the power of that language: loops, function calls, unit tests, or even the ability to call external APIs. You're declaraing desired state and letting the framework sort it outb which is you say you aren't writing imperative code like:

    if (!exists(dnszone)) create(dnszone);

denton-scratch|2 years ago

> I was left with an expertise and knowledge of a language that was now, effectively useless.

VB did that to me; the lesson I learned is to avoid[0] languages with just a single implementation. As a consequence, I'm not very interested in languages like Ruby, Go and Rust. In the old days, every language had a train of compilers/interpreters following it. Pascal, COBOL, FORTRAN, even ALGOL. I believe that in those days, building a compiler for an existing language was a pretty standard hobby project. Everyone and his dog had built one, and manufacturers bundled their own ones with the hardware.

[0] Learning is hard; I jumped from VB to PHP.

tremon|2 years ago

Ruby has multiple implementations: https://github.com/planetruby/awesome-rubies

The main implementations are:

  - MRI (aka CRuby, the reference implementation)
  - mruby (lightweight embedded engine)
  - JRuby (on top of the JVM)
  - IronRuby (on top of the .Net stack)

em-bee|2 years ago

not sure why you are making that distinction. sure, a few decades ago, a single implementation meant that a language was not widely used. but that is no longer true today. the biggest example for a widely used single implementation language is probably java.

and learning ruby, go or rust surely is not useless

spion|2 years ago

The frontend ecosystem realized (at the time of React) that the (template) DSL isn't really the point. Its the declarative description of what the end result should look like (as well as applying the diff) which is the important bit, not how you generate that declarative description. The devops space is slowly moving in this direction too.

TypeScript is a great fit to model the unwieldy yaml / json schemas with precision, getting less in the way compared to most languages with sum types. Deno could be a great player in this space that avoids the complexity of npm, especially with its sandbox to restrict side-effects, networking and external commands.

CDKs come with their own multi-language compiler (jsii-rosetta) which results with a ~300MB npm install. Even when all you wanted was to use simple typescript functions to output some JSON and/or yaml.

cogman10|2 years ago

This push and pull on "programming language vs DSL" will be with us forever. Some people love maven because it's a concise DSL, easy to understand if you understand maven. Some people like gradle because it's a DSL with a major escape hatch in that it's also just the groovy programming language with all that entails.

This dance has played out with the likes of the Javascript community. Just write a js script, no actually we need a pipeline so let's use grunt. Actually we hate grunt so let's use gulp, actually gulp is just wrong lets get declarative with webpack. Actually that's too inflexible and weedy let's just use a framework (like react-scripts) which just runs our code and gets out of the way.

After 10+ years of programming, it seems like we are on an endless loop of "let the framework do everything" to "let's enable maximum flexibility with a full programming language". (see ant in the java world for an even earlier version of this). It seems like the push and pull is this constant problem that "describing the problem is hard, and messing up that description makes everything more complex to maintain". The lack of flexibility feels nice because there's less to mess up, but then when something really complex arises you usually end up doing something 10x more nasty than you would with an ultimate flexibility framework. On the flip side, super flexible frameworks lend themselves to being completely unique butterflies that require a heavy up front research to understand (as, you don't know what that foo method is doing and why it does it). They can 1x the complex situation but it feels like the tendency is to want to overcomplicate simple problems by reinventing a framework for your company. (My company is dealing with this and jenkins pipelines)

denton-scratch|2 years ago

> After 10+ years of programming

Ah - you're a young whippersnapper! I lived through those changes. I never understood why people thought it was a good idea to have a build-pipeline for an interpreted language like Javascript. But my colleagues did; grunt->gulp->laravel->nodejs->react, with a parallel succession of CSS compilers. That was in just the 5 years before I retired. It became a sort of Red Queen race; you have to run just to stand still.

I'm glad I'm out of it.

gumby|2 years ago

Ultimately, what is an API but a domain-specific language? This article could well have been written about that.

People often talk about Lisp as a language in which people specify DSLs, but that acronym was something I only encountered outside the Lisp community. The way it always felt to me was that I "simply" designed a set of datastructures and operations around the abstractions and metaphors of the problem domain and then manipulated them to solve my problem. Isn't that the essence of programming in any language?

kagevf|2 years ago

It seems to be more of a spectrum in Lisps, spanning from syntax enhancements to full blown languages.

phendrenad2|2 years ago

Yes DSLs have been a terrible failure in the infrastructure space. But that's just because DSLs are suited to a class of problem where the language of the domain is well-defined and changes infrequently. What we've seen with devops is an ecosystem that changes even more rapidly than frontend software development (in other words, a brakeneck pace). DSLs are great in any area where you want to allow less-technical or untechnical users generate some simple rules. So think finance teams using Microsoft Excel, or video game story writers using in-house DSLs to define game events.

skywhopper|2 years ago

What specific DSLs are you talking about being failures? Because this is absolutely ludicrous claim.

OhMeadhbh|2 years ago

DSLs aren't a waste of time. But when you create a DSL, you limit the size of the community that will interact with it. So if you create a DSL, make sure that the benefit in expressiveness is worth the down-side of a smaller community.

fnordpiglet|2 years ago

The title is overly broad. They mean a very specific set of infrastructure automation related DSL

I tend to agree on that point. I think CDK and related approaches are much easier. I also find just writing SDK based scripts faster and more reliable. I find very little advantage in things like Terraform, despite my driving a few megacorps to adopt it. (Listen, in my defense, I couldn’t sell the idea of just scripting things, and generally they were repurposing admins who had no programming experience and had a mental block against learning a real language - but somehow a configuration file like language was ok)

However I’ve written a ton of DSLs in my life. They’re always useful, because I write them when I find it cumbersome to not. The broad statement about DSL is of course absurd. However at one point in my life I built a system that made it easy to write DSLs in a monorepo, and it was a huge mistake. Everyone wrote dsls everywhere and you constantly encountered code in some weird language that you had to reverse engineer. So, there’s a DSL entropy principle to be aware of - DSLs are useful if they are bounded. But like anything too much of a good thing ain’t

raffraffraff|2 years ago

Hmmm. I just have to strongly disagree. I hit those hard spots in terraform, just like I did in puppet years ago. But I'd still prefer to use a DSL for configuration management (because that's what both are). Puppet actually managed to get to a very usable state by v5, if used with hiera, you could essentially define some types and fling data at them using 'create_resources', which is the equivalent of "for each" over a data set. If you stick to that pattern and make good use of hiera, your codebase will be compact and easy to reason about. The difference between your environments will be a few lines of yaml. In fact I use his with terraform, to that same end. I've looked at pulumi and I just don't like it. Terraform has it's quirks and limitations but I still prefer it.

Maybe DSLs are a waste of Lee's time because he knows they'll be "dead languages" when the next major evolution of systems takes place. But meh, I'll learn the next DSL, and maybe even hook hiera up to it too.

dunk010|2 years ago

Steve Yegge made this same point ~20 years ago:

> The whole nasty "configuration" problem becomes incredibly more convenient in the Lisp world. No more stanza files, apache-config, .properties files, XML configuration files, Makefiles — all those lame, crappy, half-language creatures that you wish were executable, or at least loaded directly into your program without specialized processing. I know, I know — everyone raves about the power of separating your code and your data. That's because they're using languages that simply can't do a good job of representing data as code. But it's what you really want, or all the creepy half-languages wouldn't all evolve towards being Turing-complete, would they?

Via: https://sites.google.com/site/steveyegge2/the-emacs-problem

eternityforest|2 years ago

I'd rather they just fix whatever problem or missing feature caused me to want logic in the config file.

Ideally, why do I even need a nontrivial config file at all? I want more stuff that just works, and has standard interfaces to find and connect to all it's other pieces.

Even manually executing SQL to make a database is too much.

I don't want make files at all. They're only there because C/C++ doesn't handle it for you. Python doesn't need them. Node.js doesn't need them. They have build config stuff, but it's nowhere near as in depth as makefiles.

Apache is insane with all the different configurations, and how it's separate from PHP and MySQL and it all has to be configured to work together.

Lots of tools just work. They have few options, and all the important configuration options are set at runtime automatically based on input data, auto discovery, and things like that. Install and run. That's it.

If I need a full programming language to configure, then whatever I'm doing probably isn't configuration, it's more like plugin writing.

tremon|2 years ago

Over the years my opinion has grown in the same direction, but with a slightly different slant: domain-specific configuration syntaxes are a waste of time, and domain-specific processing instructions masquerading as a Turing-complete language are always inferior to a real programming language.

If you want to represent a data structure, PLEASE pretty please just use an existing data format (json, yaml, toml, xml). Those structures can be parsed and validated by generic tools, and you won't need to write your own domain-specific parsers and syntax highlighters to deal with a problem of your own making.

And if you want to allow for runtime evaluation of constructs, PLEASE pretty please just use a programming language that has friendly syntax (lua or python comes to mind). Don't get cute and try to invent your own language, just provide a good API on top.

jesseryoung|2 years ago

Programming languages will always be better, more feature rich and more capable than any DSL. However, the whole reason things like terraform or puppet become popular is because the people who write the DSL don't consider themselves "programmers" and they don't want to be thought of as "programmers".

As somebody who identifies as a "programmer" and often has to manage infrastructure I would absolutely love for a serious IaS library to pop up in my favorite language. I would switch to it immediately. However unless we start hammering home that if you are regularly writing in these DSLs that you are actually a programmer and there's nothing wrong with that people will still flock to these tools.

systemvoltage|2 years ago

Very much agree, I do wonder how can things like crontab be specified? The cron job syntax is its own fricking thing that I have to always look up. But then, I wonder, how else can it be specified? yaml file?

jamesblonde|2 years ago

We have seen this trend in feature engineering. Some companies selling feature stores try to promote their DSL as the way to create features - instead of general purpose frameworks, such as Pandas, Spark, Flink, or event DBT/SQL.

In this case, DSLs may have a short-term wow factor, that you don't have to build an maintain feature pipelines, but you're always playing catchup when the latest feature engineering technique is not available in your DSL. And then, you have your developers careers to think of - do they want to put a DSL for feature engineering on their resume?

intrasight|2 years ago

DSLs are more succinct. The are declarative. They are closer to English.

Perhaps if no relational database existed before today, the standard grammar would just be javascript - but I think not.

jen20|2 years ago

DSLs need not be declarative.

DSLs need not be succinct.

DSLs need not be close to English at all.

All of these are properties which may or may not apply to a _specific_ DSL, they are not defining features.

kwhitefoot|2 years ago

Surely all programming is essentially the creation of a domain specific language, or at least a domain specific vocabulary that describes entities in the domain, the actions that they can perform, and the messages that they can send and receive. You can be fluent in Fortran yet be completely bewildered by a Fortran program because the vast bulk of the meaning is in a language that you have yet to learn.

As for being left with expertise in a language that no one uses any more, welcome to the club. My first language was Algol-60, the next was Leasco Basic, after that I wrote some Fortran IV, then whatever dialect of Dartmouth Basic was on the Exeter Uni time sharing system, then Z80 assembler, then 6502 assembler, followed by Turbo Pascal in its various versions (I skipped all the 'standard Pascals), more Fortran (but I forget which version) then VB4, 5, 6, then VB.Net then C#. SQL was involved for quite a lot of the time too. Then I retired and now I play with Nim.

Were all of those a waste of time too? I certainly have no use for the specifics of Fortran, Algol, Dartmouth Basic, VB.Net, any assembly language, or even C# now, but they were all useful at the time and I created things that were important and valuable for the companies in which I worked.

_hcuq|2 years ago

Oops, there goes the first 10 years of my career, where I used DSLs almost exclusively.

aranchelk|2 years ago

Ultimately learning a DSL is learning a syntax, a vocabulary, a model of execution, and the underlying domain.

The syntax shouldn’t take you terribly long unless it was badly made.

In my experience virtually any project whether you use a standalone DSL, an embedded DSL, framework, library, or writing something yourself, you will have to understand the underlying domain to be useful.

The model of execution can be simple or possibly tricky. There may be a small benefit to having an embedded DSL or framework over a standalone DSL as information learned could be transferable, but model of execution could still be more complicated and different than the underlying language in the other case. I’m thinking of things like Chef, Angular, and Parsec.

That leaves the vocabulary which you’ll either need to learn or develop.

You’ll take all of the domain knowledge, which as already stated, is the important bit. If you work in the same domain, even if it’s with a very different language, model, etc., you’ll have a great insight into what’s going on.

I feel like the opinions expressed in the article really just show a lack of experience of what happens after you’re done working with a piece of tech.

skywhopper|2 years ago

Nothing new or interesting in this article. I find the idea that a general purpose programming language is better for infra/config-as-code to be utterly laughable. No one is out there saying DSLs are “easy”. They are just far more constrained in a way that’s often useful.

His examples of confusing Terraform are not particularly interesting without some counterexample showing how his preferred CDK-style alternative is better (spoiler: it isn’t any less messy).

In fact, CDK/Pulumi-style programming is actually just an imperative-style wrapper that generates the underlying declarative IaC code. You might even call it a reverse DSL. But adding one more layer of abstraction away from what’s actually happening isn’t actually useful. It just adds more seams and more opportunities for leaky abstractions. Using a generic programming language to wrap your declarative infrastructure actually encourages more layers of abstraction. Not a good idea.

Could Terraform’s language be improved? Yes. But replacing it with JavaScript or Python is not the answer.

zamalek|2 years ago

Buildah, specifically after struggling with containerfiles/dockerfiles nonsense, entrenched beliefs that agree with the author of the article. Dockerfiles are just an obnoxiously limited DSL that make all the worst assumptions (especially concerning layering), while providing nearly no flexibility. Buildah (when not using buildah bud) lets you write a container build script in the scripting language of your choice - most likely bash - and puts you in charge of layering.

I mean, sure, you don't get that automagic in-between later reuse - but I've rarely come across a project that does the magic incantations to get that to work anyway. Rather delegate the rarely changing stuff to a base image, probably updating in CI.

olvy0|2 years ago

I agree. I wrote a long rant against DSLs here [0]. I won't repeat it here. This isn't an infrastructure DSL though, just a private DSL for our product.

Since then the situation hasn't gotten any better, but sort of stayed the same. Two people on our team have been solving bugs in this DSL for the last few months, rather minor ones. Tomorrow in fact I have a meeting with one of them about adding a sort of limited pass-by-reference semantics into the language (which currently doesn't allow pass-by-reference). I'm very torn about it, as I feel this is a waste of time, and we should ditch this DSL. Users complain rightly that it isn't a "real" programming language. Our "standard library" is very very lacking, for example there's no I/O.

We just added FFI 2 months ago. My team lead who was supposed to do this years ago didn't, and in fact effectively stopped developing it 2 years ago, feeling overwhelmed, and ended up leaving a couple of months ago.

What this language or rather ecosystem DOES do well is having an internal build system that is completely transparent to the users (unless there are bugs). Well, I designed this build system so I'm partial to it.

I had actually written the C# API which I wrote about at the end of [0], that was supposed to be a replacement of this DSL with a "real" language. However I got burned out a couple of months ago after my team lead left, and halted development. There was also a long series of heated discussions with some of my users, who wanted me to remove some of the (rather simple) guardrails I made, and give them the ability to build complex hierarchies above this API, an API which I designed for simplicity. I warned them those hierarchies would end up creating DLL hell and would make it necessary to build devops tooling and maybe even infrastructure as code [1], which IMO is silly for most of the internal projects, which contain at most 5-6 people. From 2 different organizational groups, but still. My users aren't developers per se, and have a more or less support role.

I'm still torn as to what the correct direction here. Long term our small team (only 2 full time developers and 3 part time) cannot support 2 half-assed non-standard DSLs, plus that C# API for our many internal users. Something gotta give.

[0] https://news.ycombinator.com/item?id=31205265

[1] There, I tied this response to the OP!

pgib|2 years ago

This is where Chef got it right over Puppet, but of which were written in Ruby. But Chef recipes are just Ruby files, and they make use of the Ruby language to do the same thing because it's perfectly capable of describing things that way.

pyrolistical|2 years ago

This is mainly a complaint about over abstraction and intrinsic complexity.

Tools like terraform offer simple modules to make your devops life easy.

But simple looking modules abstract a complex thing by hiding details. Details which are critical once your infrastructure reaches a critical complexity threshold.

At this point the tool is a burden. It is actively getting in your way to understand and get at the the actual infrastructure you are maintaining.

This is why imo alternative like CDK got popular. It doesn’t try to over abstract for you. It just gives you an api you write custom code over. The complexity of your code goes up with the intrinsic complex of the infrastructure.

jauntywundrkind|2 years ago

The AWS cdk is a pretty good example of how nice it is to have actual code doing the things. People know JS and know how to use it & it's imminently flexible.

By compare every dsl requires learning some new language. The languages seem to grow and grow. I know plenty of people with a little bit of Terraform experience, but almost no one with extensive knowledge. It's great that surfing along the top works as well as it does, and having such a confined language keeps a normativeness, but in general I so strongly feel it's just better to use available known well supported tools.

computerfriend|2 years ago

> Understanding how to handle complex data structures in say, Python is something which might help you fix bug’s in application code, you can’t throw a DSL at that.

True, but it's not an either/or situation. Maybe it's not optimal, but a lot of people do both. I consider myself a Python and Terraform expert and I'd say I reached that stage in Terraform in less than 10% of the time it took for Python.

TheGRS|2 years ago

I feel like I get the author's points pretty well. I had in fact chosen Terraform when it was newer as a greenfield project to deploy our infrastructure more quickly at another company. And I was happy to find out my current company had built all their infrastructure with Terraform, since by that point I knew it really well. But I still struggle with interacting with it, expanding it, and trying to get it to sing to me.

The example given is pretty good at demonstrating how Terraform itself has some unique problems that they themselves created: using counts for enabling/disabling resources, using locals as proxies for data comprehension, writing long-ass resource descriptions, often with built-in functions and ternaries to get it to do what you want in various scenarios. Trying to be DRY in Terraform can often be a chore. I think Terraform's MO is actually that some duplicate code isn't the worst thing, so you end up with piles of duplicate lines that are extremely difficult to read, and where writing a function would be super helpful. We had an engineer do a bunch of Terragrunt work for a project and I found that code nigh-incomprehensible.

So, I get it as well, I get where they're coming from.

I also think working with DSLs isn't a huge waste of time, since many of the things we work on are abstractions of abstractions. It seems like everything I'm doing today is probably going to go away in due time, but I know how to program, read docs, and pivot quickly. I do feel like as long as you're gaining an understanding of the underlying elements, your time spent in a DSL (assuming you're getting paid or you end up using it for several years), is still well spent.

They mention Puppet, and I remember getting a job offer once because I was able to read the Puppet documentation and write out a little script that could do the ask in Puppet, even though I had never used it in a professional capacity before. It was easy to pick up and I would've happily worked in it if I accepted the offer. The knowledge I gain around deploying to AWS or other cloud providers is often transferrable in that manner too.

The clouds themselves are a sort of DSL often, but I can't say that my time spent with Azure was a waste just because I'm working in AWS now. No, we delivered stuff on that platform, I learned its pros and cons, I gained some wider understanding of what cloud platforms could do, and I got paid along the way :)

turtleyacht|2 years ago

Why don't we have a tool that lets us associate monetary budgets to concrete hardware specs, and then generates a cross-cloud (or cloud-agnostic) configuration?

  budget: $23000
  pricing: cheapest
  cpu:
    preferred: xeon
    cores: 8
    mem: 64gb
  disk:
    preferred: ssd
And some --import-usage flag to specify a folder of historical CPU and memory usage from Grafana.

imtringued|2 years ago

This is backwards. What you want is to specify resource limits and then have the maximum possible bill calculated for you.

If you want services to turn off if they exceed a threshold then you will need some sort of priority scheme.

sgt|2 years ago

Found a great option for you at $23000. Amazingly we managed to accommodate your budget. /s

SonOfLilit|2 years ago

Author is arguing that parsed DSLs are worse than embedded DSLs, and he's not wrong pe se - if you have a choice, you should choose parsod DSLs 99% of the time.

However, this is not at all an argument against DSLs. Using a "real" language to specify the cloud infrastructure, you'd still want your API to be declarative and ergonomic, i.e. you'd want a DSL.

AtlasBarfed|2 years ago

Any api is kind of a dsl in the sense you need to figure out how to converse with/invoke it, but at least you can descend into the code to figure out what is happening.

A lot of DSLs are a wall to understanding what each "figure of speech" actually does. You need to navigate a parser before you get to the underlying execution of the language

ec109685|2 years ago

Hyperbolic blog posts are so annoying.

Really, if OpenTF happens, you’ll be back to square one?

“ When the maintainers of OpenTF inevitably decide that they want to add enhancements that require language changes, you as the end user end up in a situation where you’re effectively back to square 1, learning (potentially) a new DSL.”

manojlds|2 years ago

The post is from 2021

mvaliente2001|2 years ago

The alternative, using general programming languages, is a terrible idea. The last thing I want to do when dealing with a domain specific configuration is trying to figure the meaning out of hundreds of poorly written, badly abstracted, totally undocumented, lines of code.

_Algernon_|2 years ago

Read the first couple of paragraphs, realized I have no idea what DSLs are or why I should care about them.

Define your abbreviations, people, especially when its not the first hit when googling it. It's not that hard and makes your writing much more accessible.

yegle|2 years ago

My favorite example of Terraform being a terrible DSL for infrastructure: code to find ipv6 addresses in a list of v4/v6 addresses

  [for x in x.addresses: x if length(regexall(".*[:].*", x))>0]

thrashh|2 years ago

The problems with DSLs is usually poor ass documentation.

Throwing a full programming language in place of a DSL means now you deal with everyone and their mom inventing their own way of doing things.

julienfr112|2 years ago

People, just try pyinfra. Pure python for infrastructure as code. Ansible, terraform, salt, never more.

specialist|2 years ago

OC is arguing that Terraform is a suboptimal abstraction for infrastructure-as-code.

I have no dog in this fight. But I do have opinions about DSLs.

The declarative vs imperative, or some hybrid, debate is ongoing with build systems.

James Duncan Davidson, author of Ant build system for Java, famously wrote a post-mortem. Mostly wrt to choice of XML for Ant's syntax and semantics. TLDR: Wheels fall off a declarative model once imperative logic is added.

FWIW, Here's how I think about declarative DSLs. Such as a scenegraph.

You have an exquisite mental model for a scene. It's probably hierarchical.

You attempt to capture that mental model in code. The representation is probably a grove data structure. aka Directed Acyclic Graph where nodes can have key/value pairs for metadata.

You need to serialize that grove. So you pick a suitable syntax. Hopefully something that looks like VRML-97. Basically s-expressions (JSON without the syntactic vinegar), with some way to represent object prototyping (define/use), and don't forget identifiers ("id" field). Bonus points if you include path expressions in your syntax.

That (human readable) serialized grove is the declarative DSL.

In an future perfect world, your mental model, runtime representation, serialization format, AND the real world will be isomorphic.

Not isomorphic? Of course they're isomorphic. Why even mention it?

Funny you should ask.

In the Java world, dom4j for representing XML documents, and most of its progeny, is not isomorphic. Only JDOM2's class hierarchy design actually matches the serialization format. (As of the last time I checked, a few years ago.)

dom4j's mismatch, leaky abstraction, poor design, what have you, begat untold additional labor and heartache. Which is all completely mooted by JDOM2's correct design.

Ensuring correct isomorphism avoids errors in the same way that strong typing and garbage collection do.

To wrap this up...

In my experience, isomorphism is the exception.

I have no idea if Terraform is a good declarative DSL. But I do know that it should be isomorphic with the runtime representation AND the real world. And that should be settled before weaving in imperative functionality.