TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

DSLs are a waste of time

95 pointsby jaxxstormalmost 2 years ago

41 comments

eductionalmost 2 years ago
We stop calling the useful ones “DSLs” so this is a truism.<p>Is SQL a “waste of time?” Regular expressions, HTML, Makefiles, CSS (and CSS selectors aka jquery selectors)?<p>It’s the bad ones that are a waste of time. The ones still called “dsl” instead of just “language, “format,” or “syntax.”
评论 #37383483 未加载
评论 #37383373 未加载
评论 #37383068 未加载
评论 #37383015 未加载
评论 #37383174 未加载
评论 #37387412 未加载
评论 #37382867 未加载
评论 #37383264 未加载
chubotalmost 2 years ago
FWIW this wiki page I started may help frame discussions like this:<p><i>Survey of Config Languages</i> - <a href="https:&#x2F;&#x2F;github.com&#x2F;oilshell&#x2F;oil&#x2F;wiki&#x2F;Survey-of-Config-Languages">https:&#x2F;&#x2F;github.com&#x2F;oilshell&#x2F;oil&#x2F;wiki&#x2F;Survey-of-Config-Langua...</a><p>It puts a bunch of languages in 5 cateogires.<p>Terraform is at least not a YAML DSL, a very common pattern which I don&#x27;t understand the appeal of. I guess the main appeal is that you can copy and paste, and pretend it&#x27;s data in simple cases.<p>But even Terraform suffers from the problem of &quot;external&quot; DSLs -- you end up needing a general purpose language. And yes this pattern has repeated itself so many times.<p>Awk and Make both grew into general purpose languages, and in Make&#x27;s case it&#x27;s particularly bad.<p>Most SQL dialects have also grown a pretty bad stored procedure language.<p>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&#x2F;config language, but it&#x27;s missing a few things for that, and gets awkward pretty quickly.<p>Ruby does a bit better, but it&#x27;s not perfect either. It&#x27;s fairly big and heavy if you just want a config file.
评论 #37383200 未加载
评论 #37383242 未加载
marcosdumayalmost 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)...<p>Yes, platform specification languages are a mess. Making them without the &quot;language&quot; part keeps all of the mess (the language is absolutely not the source of it). There are people trying to fix this, although I&#x27;m not sure if I&#x27;d place Pulumi on that group.<p>And DSLs are still a great software architecture technique with all kinds of applications.
评论 #37383406 未加载
joshmarinaccialmost 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.<p>They always start simple and easy, but they <i>always</i> eventually grow so complex that using a real language would be preferable.<p>I’ve never seen a system remain at the same level of complexity (or much less shrink) over a multi year timeline.
评论 #37383033 未加载
fishnchipsalmost 2 years ago
Marcin here, one of OpenTF folks.<p>I think the redeeming factor of Terraform is not the language itself, though I really like the fact that it&#x27;s <i>not</i> 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).<p>Here&#x27;s an analogy. Most folks I know are at least skeptical about Java. The same folks would then praise Kotlin, Scala or Clojure as &quot;good&quot; JVM languages. The relative success of these languages owes much to the Java ecosystem and the JVM interop.<p>That&#x27;s the reason I find Terraform worth saving. It&#x27;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.
waffletoweralmost 2 years ago
This is a great takeaway from the article-- &quot;programming languages are the better authoring model for cloud infrastructure&quot;. I was surprised by the simplicity of the &quot;complex&quot; 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 &quot;Terraform(ing) is a Waste of Time&quot;
评论 #37382913 未加载
评论 #37382655 未加载
OJFordalmost 2 years ago
I think calling terraform a DSL in comparison to general purpose programming languages misses the point. If it used a <i>declarative</i> GPPL instead of HCL I wouldn&#x27;t care, but imperative alternatives general purpose or not are &#x27;a waste of time&#x27; &amp; not fit for the domain, IMO.
评论 #37382412 未加载
评论 #37382484 未加载
denton-scratchalmost 2 years ago
&gt; I was left with an expertise and knowledge of a language that was now, effectively useless.<p>VB did that to me; the lesson I learned is to avoid[0] languages with just a single implementation. As a consequence, I&#x27;m not very interested in languages like Ruby, Go and Rust. In the old days, every language had a train of compilers&#x2F;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.<p>[0] Learning is hard; I jumped from VB to PHP.
评论 #37383714 未加载
评论 #37385607 未加载
spionalmost 2 years ago
The frontend ecosystem realized (at the time of React) that the (template) DSL isn&#x27;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.<p>TypeScript is a great fit to model the unwieldy yaml &#x2F; 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.<p>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&#x2F;or yaml.
cogman10almost 2 years ago
This push and pull on &quot;programming language vs DSL&quot; will be with us forever. Some people love maven because it&#x27;s a concise DSL, easy to understand if you understand maven. Some people like gradle because it&#x27;s a DSL with a major escape hatch in that it&#x27;s also just the groovy programming language with all that entails.<p>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&#x27;s use grunt. Actually we hate grunt so let&#x27;s use gulp, actually gulp is just wrong lets get declarative with webpack. Actually that&#x27;s too inflexible and weedy let&#x27;s just use a framework (like react-scripts) which just runs our code and gets out of the way.<p>After 10+ years of programming, it seems like we are on an endless loop of &quot;let the framework do everything&quot; to &quot;let&#x27;s enable maximum flexibility with a full programming language&quot;. (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 &quot;describing the problem is hard, and messing up that description makes everything more complex to maintain&quot;. The lack of flexibility feels nice because there&#x27;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&#x27;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)
评论 #37383124 未加载
gumbyalmost 2 years ago
Ultimately, what is an API but a domain-specific language? This article could well have been written about that.<p>People often talk about Lisp as a language in which people specify DSLs, but that acronym was something I only encountered <i>outside</i> the Lisp community. The way it always felt to me was that I &quot;simply&quot; 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&#x27;t that the essence of programming in any language?
评论 #37383256 未加载
phendrenad2almost 2 years ago
Yes DSLs have been a terrible failure in the infrastructure space. But that&#x27;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&#x27;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.
评论 #37383421 未加载
OhMeadhbhalmost 2 years ago
DSLs aren&#x27;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.
fnordpigletalmost 2 years ago
The title is overly broad. They mean a very specific set of infrastructure automation related DSL<p>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)<p>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
raffraffraffalmost 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&#x27;d still prefer to use a DSL for configuration management (because that&#x27;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 &#x27;create_resources&#x27;, which is the equivalent of &quot;for each&quot; 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&#x27;ve looked at pulumi and I just don&#x27;t like it. Terraform has it&#x27;s quirks and limitations but I still prefer it.<p>Maybe DSLs are a waste of <i>Lee&#x27;s</i> time because he knows they&#x27;ll be &quot;dead languages&quot; when the next major evolution of systems takes place. But meh, I&#x27;ll learn the next DSL, and maybe even hook hiera up to it too.
dunk010almost 2 years ago
Steve Yegge made this same point ~20 years ago:<p>&gt; The whole nasty &quot;configuration&quot; 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&#x27;s because they&#x27;re using languages that simply can&#x27;t do a good job of representing data as code. But it&#x27;s what you really want, or all the creepy half-languages wouldn&#x27;t all evolve towards being Turing-complete, would they?<p>Via: <a href="https:&#x2F;&#x2F;sites.google.com&#x2F;site&#x2F;steveyegge2&#x2F;the-emacs-problem" rel="nofollow noreferrer">https:&#x2F;&#x2F;sites.google.com&#x2F;site&#x2F;steveyegge2&#x2F;the-emacs-problem</a>
评论 #37384872 未加载
tremonalmost 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.<p>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&#x27;t need to write your own domain-specific parsers and syntax highlighters to deal with a problem of your own making.<p>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&#x27;t get cute and try to invent your own language, just provide a good API on top.
jesseryoungalmost 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&#x27;t consider themselves &quot;programmers&quot; and they don&#x27;t want to be thought of as &quot;programmers&quot;.<p>As somebody who identifies as a &quot;programmer&quot; 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&#x27;s nothing wrong with that people will still flock to these tools.
评论 #37383567 未加载
jamesblondealmost 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&#x2F;SQL.<p>In this case, DSLs may have a short-term wow factor, that you don&#x27;t have to build an maintain feature pipelines, but you&#x27;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?
intrasightalmost 2 years ago
DSLs are more succinct. The are declarative. They are closer to English.<p>Perhaps if no relational database existed before today, the standard grammar would just be javascript - but I think not.
评论 #37382380 未加载
kwhitefootalmost 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.<p>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 &#x27;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.<p>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.
stevenallyalmost 2 years ago
Oops, there goes the first 10 years of my career, where I used DSLs almost exclusively.
aranchelkalmost 2 years ago
Ultimately learning a DSL is learning a syntax, a vocabulary, a model of execution, and the underlying domain.<p>The syntax shouldn’t take you terribly long unless it was badly made.<p>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.<p>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.<p>That leaves the vocabulary which you’ll either need to learn or develop.<p>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.<p>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.
skywhopperalmost 2 years ago
Nothing new or interesting in this article. I find the idea that a general purpose programming language is better for infra&#x2F;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.<p>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).<p>In fact, CDK&#x2F;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.<p>Could Terraform’s language be improved? Yes. But replacing it with JavaScript or Python is not the answer.
zamalekalmost 2 years ago
Buildah, specifically after struggling with containerfiles&#x2F;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 <i>not</i> 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.<p>I mean, sure, you don&#x27;t get that automagic in-between later reuse - but I&#x27;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.
olvy0almost 2 years ago
I agree. I wrote a long rant against DSLs here [0]. I won&#x27;t repeat it here. This isn&#x27;t an infrastructure DSL though, just a private DSL for our product.<p>Since then the situation hasn&#x27;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&#x27;t allow pass-by-reference). I&#x27;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&#x27;t a &quot;real&quot; programming language. Our &quot;standard library&quot; is very very lacking, for example there&#x27;s no I&#x2F;O.<p>We just added FFI 2 months ago. My team lead who was supposed to do this years ago didn&#x27;t, and in fact effectively stopped developing it 2 years ago, feeling overwhelmed, and ended up leaving a couple of months ago.<p>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&#x27;m partial to it.<p>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 &quot;real&quot; 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 <i>most</i> 5-6 people. From 2 different organizational groups, but still. My users aren&#x27;t developers per se, and have a more or less support role.<p>I&#x27;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.<p>[0] <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=31205265">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=31205265</a><p>[1] There, I tied this response to the OP!
pgibalmost 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&#x27;s perfectly capable of describing things that way.
pyrolisticalalmost 2 years ago
This is mainly a complaint about over abstraction and intrinsic complexity.<p>Tools like terraform offer simple modules to make your devops life easy.<p>But simple looking modules abstract a complex thing by hiding details. Details which are critical once your infrastructure reaches a critical complexity threshold.<p>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.<p>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.
jauntywundrkindalmost 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 &amp; it&#x27;s imminently flexible.<p>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&#x27;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&#x27;s just better to use available known well supported tools.
computerfriendalmost 2 years ago
&gt; 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.<p>True, but it&#x27;s not an either&#x2F;or situation. Maybe it&#x27;s not optimal, but a lot of people do both. I consider myself a Python and Terraform expert and I&#x27;d say I reached that stage in Terraform in less than 10% of the time it took for Python.
TheGRSalmost 2 years ago
I feel like I get the author&#x27;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.<p>The example given is pretty good at demonstrating how Terraform itself has some unique problems that they themselves created: using counts for enabling&#x2F;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&#x27;s MO is actually that some duplicate code isn&#x27;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.<p>So, I get it as well, I get where they&#x27;re coming from.<p>I also think working with DSLs isn&#x27;t a huge waste of time, since many of the things we work on are abstractions of abstractions. It seems like everything I&#x27;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&#x27;re gaining an understanding of the underlying elements, your time spent in a DSL (assuming you&#x27;re getting paid or you end up using it for several years), is still well spent.<p>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&#x27;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.<p>The clouds themselves are a sort of DSL often, but I can&#x27;t say that my time spent with Azure was a waste just because I&#x27;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 :)
turtleyachtalmost 2 years ago
Why don&#x27;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?<p><pre><code> budget: $23000 pricing: cheapest cpu: preferred: xeon cores: 8 mem: 64gb disk: preferred: ssd </code></pre> And some --import-usage flag to specify a folder of historical CPU and memory usage from Grafana.
评论 #37382596 未加载
评论 #37382501 未加载
SonOfLilitalmost 2 years ago
Author is arguing that parsed DSLs are worse than embedded DSLs, and he&#x27;s not wrong pe se - if you have a choice, you should choose parsod DSLs 99% of the time.<p>However, this is not at all an argument against DSLs. Using a &quot;real&quot; language to specify the cloud infrastructure, you&#x27;d still want your API to be declarative and ergonomic, i.e. you&#x27;d want a DSL.
AtlasBarfedalmost 2 years ago
Any api is kind of a dsl in the sense you need to figure out how to converse with&#x2F;invoke it, but at least you can descend into the code to figure out what is happening.<p>A lot of DSLs are a wall to understanding what each &quot;figure of speech&quot; actually does. You need to navigate a parser before you get to the underlying execution of the language
ec109685almost 2 years ago
Hyperbolic blog posts are so annoying.<p>Really, if OpenTF happens, you’ll be back to square one?<p>“ 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.”
评论 #37383247 未加载
mvaliente2001almost 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_almost 2 years ago
Read the first couple of paragraphs, realized I have no idea what DSLs are or why I should care about them.<p>Define your abbreviations, people, especially when its not the first hit when googling it. It&#x27;s not that hard and makes your writing much more accessible.
yeglealmost 2 years ago
My favorite example of Terraform being a terrible DSL for infrastructure: code to find ipv6 addresses in a list of v4&#x2F;v6 addresses<p><pre><code> [for x in x.addresses: x if length(regexall(&quot;.*[:].*&quot;, x))&gt;0]</code></pre>
thrashhalmost 2 years ago
The problems with DSLs is usually poor ass documentation.<p>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.
julienfr112almost 2 years ago
People, just try pyinfra. Pure python for infrastructure as code. Ansible, terraform, salt, never more.
specialistalmost 2 years ago
OC is arguing that Terraform is a suboptimal <i>abstraction</i> for infrastructure-as-code.<p>I have no dog in this fight. But I do have opinions about DSLs.<p>The declarative vs imperative, or some hybrid, debate is ongoing with build systems.<p>James Duncan Davidson, author of Ant build system for Java, famously wrote a post-mortem. Mostly wrt to choice of XML for Ant&#x27;s syntax and semantics. TLDR: Wheels fall off a declarative model once imperative logic is added.<p>FWIW, Here&#x27;s how I think about <i>declarative</i> DSLs. Such as a scenegraph.<p>You have an exquisite mental model for a scene. It&#x27;s probably hierarchical.<p>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&#x2F;value pairs for metadata.<p>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&#x2F;use), and don&#x27;t forget identifiers (&quot;id&quot; field). Bonus points if you include path expressions in your syntax.<p>That (human readable) serialized grove is the declarative DSL.<p>In an future perfect world, your mental model, runtime representation, serialization format, AND the real world will be isomorphic.<p>Not isomorphic? Of course they&#x27;re isomorphic. Why even mention it?<p>Funny you should ask.<p>In the Java world, dom4j for representing XML documents, and most of its progeny, is not isomorphic. Only JDOM2&#x27;s class hierarchy design actually matches the serialization format. (As of the last time I checked, a few years ago.)<p>dom4j&#x27;s mismatch, leaky abstraction, poor design, what have you, begat untold additional labor and heartache. Which is all completely mooted by JDOM2&#x27;s correct design.<p>Ensuring correct isomorphism avoids errors in the same way that strong typing and garbage collection do.<p>To wrap this up...<p>In my experience, isomorphism is the exception.<p>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.