Hacker News new | past | comments | ask | show | jobs | submit login

Declarative isn't important. I wish people would stop talking about it. It's not even useful to think about most of the time because of how many ways it can be interpreted. It's a thereotical categorization, not a functional design principle.

Just make the program do useful things for the user. Make the computer work for the human rather than the other way around.




This is almost too devoid of content (opinion is not that) to usefully reply, and I suspect you're gesturing at some more specific point I might agree with, or at least understand.

Declaration is absolutely a coherent and functional design principle. A declarative system is one in which the outcome is specified and the process is not.

This has big payoffs in domains where it's natural. A good example being grammars. It also has hazards, a good example being the performance of algorithms to parse grammars.

We can see where a declarative build system might be a mixed bag, because the process itself is imperative: make is an early attempt to reconcile imperative build processes with a declaration of what circumstances require their triggering. Basically every build system since make has improved on make, but they all do more-or-less what make does.

The design, in short, is proven, as well as declarative but not purely so.

And the ability to reason about the degree to which make is declarative shows that 'declarative' is in fact a coherent idea. But you can't declare software into existence, you must compile it.


I dunno, the "declarative-ness" of `make` is a pretty important component of its usefulness. In particular, the property of `make`, wherein the structure/details of the computation is implicit in the provided configuration and invoked command rather than being explicitly written down somewhere, is central to its utility, since the alternative of just writing a shell script is anecdotally a much less popular option. If you want to propose a more appropriate word to describe such a property which is less buzzwordy, feel free, but in the context of "why does `make` have such enduring popularity", I think the article's author is being quite reasonable in bringing it up.


You could replace the word "declarative-ness" with "automation" and it'd mean the same thing. And literally all configuration of functionality implies the structure and details of computation - that's the point of configuration, to tell an already assembled program that already has structure and computational details what to do with it. There's no overt distinction between "declarative programming" and "configure a function with value X".

Makefiles are simply configuration files that use whitespace and a couple characters to create the configuration, and what Make's inbuilt functions do with that determine the extent to which the result becomes "more intelligent". Yes they are used to build a graph and execute it, but so is Dotfile notation, and software package configuration files. But we don't call those declarative programming. Many of those configuration files create multiple levels of instructions and require several passes to execute properly. But we just call them "config files" because we don't feel they are intellectually superior enough to be called a form of programming. And on the other hand, we don't call declarative programming "configuration", but they're often the same thing.

Nobody says they "imperatively configure" some software, but they do consider themselves "declaratively configuring" it. Because they've overloaded the word "declare" as if it means something other than "write down a thing I want a computer to eventually do with some automation". People bring up the declarative thing because they want to imagine there's some intellectual value to considering it, but there isn't. You're basically saying "I want to configure a program rather than write one". Which is fine. But just say that and stop pretending that's going to immediately lead to a better result.


Configuration doesn't have to be declarative, for example see https://lukeplant.me.uk/blog/posts/less-powerful-languages/, in particular the section about python configuration, where an imperative configuration language is discussed. How imperative? Very. It's a line-oriented language, where the program reads a line and changes something in an internal data structure accordingly then continue reading the file. This is imperative, the person writing the configuration file has to think about state and time while writing the file, not just abstract goal states and facts.

Declarative vs. Imperative is a spectrum. For instance, there is a declarative language hiding inside most imperative languages : Infix Math. 1+2*3/71**7 is declarative because it under-specifies the order of operation, only the data flow dependencies implied by operator precedence needs to be respected. In the precedence hierarchy I had in mind when I wrote it, You can do 2*3 first or 71**7 first, it's unspecified and irrelevant. I only ask that you do both before you perform the division of their results, and that the addition is the last operation. Meanwhile, in Forth, math is imperative, you have to unroll the expression tree into an exact sequence.

Declarative is any language that under-specifies the task being described. Therefore, every language worth using is declarative to some degree or the other. After all, that is the very purpose of a high level language : to under-specify a task by describing only the most essential of details, all the abstracted details are taken care of by either inference (compiler figures it out, possibly according to rules that you need to be aware of) or exhaustive checking (compiler generates all possible cases and code to select among them at runtime, or very generic code that can handle all cases uniformly). If, like Alan Perlis says, "A low level language is that which requires attention to the irrelevant", then every good language is already declarative in some sense, you omit things and they get taken care of automatically, that's what Decorative means.

You can say you hate buzzwords, I empathize. You can just say that make is bad software (trivially true, or we wouldn't have needed software to generate makefiles, effectively making them a machine code that isn't meant to be written by humans) and that being declarative doesn't make it any less bad. Declarative vs. Imperative are just names for design decisions, they guide a language designer but don't have the power to make a language good single-handedly.


The builder pattern is imperative configuration.


> Make the computer work for the human rather than the other way around.

Ironically is a very concise definition of `declarative`.


Which is doubly ironic as tools and languages described as "declarative" often require the human to jump through many kinds of hoops just to finally make what they've written do what they actually wanted.


You're completely right. SQL query hacking can be ridiculous for example. Still, it's a lot better than the alternative.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: