News for hackers. Stuff that matters.
Re:Do notation considered harmful by felixyz on Wednesday April 29, 2020 @03:35AM (#23016451)
I think you're right that imperative semantics are natural for people in some contexts, but far from all the time. For someone who has worked hard day after day for years to fit all kinds of problems into an imperative mould, it will of course appear more "natural" than for others.

Cooking recipes are good examples of imperative "scripts", and for the most part it would be silly to try to write them in a declarative style. But note that they too often contain declarative formulas, like "if the pancakes stick to the pan, use more butter". It's the most natural thing in the world to add such regulative rules. There is no mention of exactly when this rule should be applied, in the sense of where it fits into a sequence, and trying to formulate it that way would be cumbersome.

It's a big drawback for the industry languages you allude to (and for the software industry as a whole) that there is no simple way to integrate such rules into programs. (I suppose aspect oriented programming is/was an attempt at that.)

You can also read through the rules for any board game. They typically consist of a mix of imperative, sequential instructions, regulative rules, and constraints. Why? Because that is the most natural thing.

Re:Do notation considered harmful by spindle on Wednesday April 29, 2020 @04:00AM (#23016621)
I agree. System configuration is a good example of something that's not naturally imperative - hence the success of NixOS and other declarative configuration tools. ("Success" in the sense that they work really well. I realise they haven't taken over the world.)
Re:Do notation considered harmful by tetha on Wednesday April 29, 2020 @06:41AM (#23017625)
Monitoring feels like that as well.

You usually end up with a more imperative part to execute a check or to pull data and push it to a monitoring system. "Call this API / read this file. For each line / json key, mangle into monitoring format. Add in missing metadata. Push all resulting lines to monitoring ingress host".

Beyond that, our icinga has a very declarative config file. "This is host foo.local, it runs a tomcat with application X and a mysql and backups". The system then goes ahead and figures out what kind of checks might be necessary for an application X, or backups.

Re:Do notation considered harmful by declnz on Wednesday April 29, 2020 @07:09AM (#23017808)
Cooking recipes are interesting - I often note how un-imperative (or at least, implicitly parallelised) they can be throughout, e.g.

- Wash the rice - Boil the rice gently for 20 mins - Whilst the rice is cooking, sauté the finely diced onions.. - Before they've turned brown...

Re:Do notation considered harmful by kqr on Wednesday April 29, 2020 @07:19AM (#23017862)
And this only increases with the experience of the chefs involved. When an experienced chef discusses a dish with another experienced chef, they will talk in common high-level abstractions like roux and emulsifier without going into detail in how to first make those components.

And then at the next level up is complete base recipes, like "this is essentially a bearnaise except with _____" or "you start with a ______ but instead of _____ you _____". So the recipes are expressed with combinators over modifiers and existing recipes.

Re:Do notation considered harmful by felixyz on Wednesday April 29, 2020 @10:17AM (#23019525)
Love it.
Re:Do notation considered harmful by rossng on Wednesday April 29, 2020 @09:07AM (#23018629)
This reminds me of a website called Cooking For Engineers[1] which uses diagrams to represent the parallel and sequential parts of a recipe (e.g. [2]).

[1] http://www.cookingforengineers.com/

[2] http://www.cookingforengineers.com/recipe/172/Pan-Pizza/trn