4 ms·
This is so true, I have seen it happen with so many projects. It always starts with a cute declarative DSL, and inevitably imperative / flow control structures
by Galanwe 10mo ago
This is so true, I have seen it happen with so many projects. It always starts with a cute declarative DSL, and inevitably imperative / flow control structures emerge, at which point you wonder why they didn't use a real programming language in the first place and save you the hassle or learning a half baked imperative DSL.
- Puppet
- CMake
- Terraform
- ...
All these started with pure declarative DSL then incrementally created a nightmarish imperative monstrosity.
- Derbasti 10mo ago- Visual Studio project files are XML files that are interpreted line by line, and can contain variables, branches, and loops. Hell on earth.
- Xelbair 10mo agowhat's even worse that schema uses extremely generic types with attributes denoting actual type. Makes reading it even harder, and any possible constraints due to type safety go out of the window, so we get worst of both worlds.
- spooky_deep 10mo agoHorrible. Would’ve been much nicer if they’d reached for Scheme.
- debugnik 10mo agoYou say that, but people in OCaml keep bemoaning the use of mostly declarative s-expressions in the Dune build system. Imagine the reaction if MSBuild used an actual Scheme.
- spooky_deep 10mo agoThey don’t know how good they really have it :)
- jimbokun 10mo agoWhy doesn't the OCaml build system use OCaml?
- spooky_deep 10mo agoYou don’t want a language with non-determinism, arbitrary IO, impure functions etc. for build configuration ideally. I guess the answer to your question is OCaml has unmanaged side effects.
- pjmlp 10mo agoThey are badly copied Ant build files. Ant came first, then when Microsoft redid the VS project format, they created MSBuild. As incredible as it may sound, Ant is still easier to deal with than MSBuild.
- giamma 10mo agoAnt did not include IF THEN ELSE, unless you added the contrib package. If you understood the paradigm, you could write branches in Ant files simply using properties and guards on properties ("unless"). Using IF in Ant was basically admission of not having understood Ant. This said, I used Ant for a very limited amount of time.
- pjmlp 10mo agoIt sure did, you use conditions, no need for contrib. https://ant.apache.org/manual/Tasks/condition.html https://ant.apache.org/manual/Tasks/condition.html The else part is easily done by repeating and negating the condition. Two other advantages of Ant that MSBuild lacks in a sane way to this day, are macros, and proper documentation.
- bokchoi 10mo agoAs of Ant 1.9.1, you can use 'if' and 'unless' attributes on any task or element in a target. I stopped using Ant a long time ago, but this was a pleasant discovery when I had to pick up an old Ant based project recently. https://ant.apache.org/manual/ifunless.html https://ant.apache.org/manual/ifunless.html
- pjmlp 10mo agoNice, I was basing my answer on what was there initially. I always liked Ant, as I don't suffer from XML allergy.
- giamma 10mo agoI agree, that is what I meant: there were people who installed Contrib to have <if> element, but in reality you did not need that you could just use Ant's built-in features like you said. In my opinion installing Contrib to use <if> was a demonstration of not having understood how Ant works.
- shevy-java 10mo agoWesnoth the game also has that via WML. Looks very ugly and obfuscated.
- spooky_deep 10mo agoCMake was never declarative AFAIK? CMake today is effectively an eso-lang / Turing tarpit with some “modern” declarative conventions that people try to push.
- ahartmetz 10mo ago"Modern CMake" is more about scoping all properties to the targets that they belong to (including stuff like what you also need to link against if you link against target foo) than about language features. The CMake language hasn't changed much except correcting some early weirdness about "if" and the addition of generator expressions, which are fortunately not often needed.
- embedding-shape 10mo ago> All these started with pure declarative DSL then incrementally created a nightmarish imperative monstrosity. "Huh?" I asked myself when you mentioned that Terraform is now imperative somehow. Took a look at the website again, and seems to still be HCL, and still be declarative. Am I missing something? How exactly is Terraform today a "imperative monstrosity"?
- zaphar 10mo agoTerraform has modules which are an elaborate method of doing function calls. HCL 2 has loops and conditionals. It is most definitely imperative. This is not necessarily a problem except that they had to live in the original HCL v1 landscape which makes them awkward syntactically.
- embedding-shape 10mo ago> Terraform has modules which are an elaborate method of doing function calls ... What? How is modules a function call? It's just a hierarchy, everything about/with modules is still declarative. > HCL 2 has loops and conditionals. It is most definitely imperative. So what? Just because there is loops and conditionals doesn't mean it's suddenly imperative. How exactly you do loops in HCL? Last time I used it, you still used declarative configuration for that, and use `for_each` as an declared option, you don't "call for_each which returns config", all that happens inside of HCL/TF, because it is declarative. Did something change like yesterday or are people even here on HN so ignorant about what declarative vs imperative actually means?
- zaphar 10mo agoYou "call" a module with arguments. You can call them multiple times. In every way that matters they are just like a function call. I don't understand why there is a distinction between for each in a standard language vs for_each in HCL2. They are both do something by iterating over something else at runtime. The syntax isn't what matters here. I think maybe you are mistaken in your own distinction between declarative and imperative.
- shevy-java 10mo agoI think cmake kind of needs conditional checks though.
- speed_spread 10mo agoPeople love to hate on Maven's XML but at least it's been mostly the same since 2006. There are conditionals in profile activation expressions but they are very limited by design. Declarative done right, IMO
- butlike 10mo agoWhat's the old adage? Software expands until it can send email?
- psychoslave 10mo agoOne reason I still love Ruby so much. It gives ability to easily define a DSL within a larger robust fully fledged language, and you can always tap on the larger ecosystem if needs evolve. This is a sharp contrast with starting something small from scratch (which might seems fine at the start), and later be on your own to scale things up as needs grow.