What is Nostr?
Leonard/Janis Robert König /
npub1uf6…774h
2024-03-09 11:52:02

Leonard/Janis Robert König on Nostr: The difference b/w imperative programming and declarative: # Imperative 1. Cook 6 ...

The difference b/w imperative programming and declarative:

# Imperative

1. Cook 6 tomatoes
2. Put them into ice water and wait until cooled
3. Peel and dice them
4. Finely chop 1-2 onions
5. Heat up some olive oil, and fry the onions until slightly transparernt
6. Add the tomatoes, some sugar, thyme, salt and pepper
7. Bring to boil and cook it until the desired thickness is reached

You now have a tomato sauce.

# Declarative

A tomato sauce is made by cooking 6 peeled and diced tomatoes with some added sugar, thyme, salt and pepper as well as 1-2 chopped onions slightly fried in olive oil.

While imperative programming is a step-by-step instruction what to do, declarative programming is a description what is. Think tutorial/recipe vs. encyclopedia entry. Thus, a declarative approach completely ignores time and sequencing: In theory, if you already have store-bought peeled tomatoes, you can just use them. If they're already diced, you can do that as well. If they come pre-seasoned with salt and pepper, that's okay as well.

In terms of programming: If an expression has already been evaluated, it can easily and trivially be re-used.
Author Public Key
npub1uf6cu9nwq4tvcrgeahfxf2mx9ppq4nxdldf22a0kmhtuk7dq2mjqmm774h