Search code examples
programming-languagessyntaxlogic

Why are there not more control structures in most programming languages?


Why do most languages seem to only exhibit fairly basic control structures from a logic point of view? Stuff like If ... then, Else..., loops, For each, switch statement, etc. The standard list seems fairly basic from a logic point of view.

Why is there not much more in the way of logic syntactical sugar? Perhaps something like a proposition engine, where you could feed an array of premises or functions that return complicated self referential interdependent functions and results. Something where you could chain together a complex array of conditions, but represented in a way that was easy and clear to read in the code.

Premise 1

Premise 2 if and only if Premise 1

Premise 3

Premise 4 if Premise 2 and Premise 3

Premise 5 if and only if Premise 4

etc...

Conclusion

I realize that this kind of logic this can be constructed in functions and/or nested conditional statements. But why are there not generally more syntax options for structuring these kind of logical propositions without resulting in hairy looking conditional statements that can be hard to read and debug?

Is there an explanation for the kinds of control structures we typically see in mainstream programming languages? Are there specific control structures you would like to see directly supported by a language's syntax? Does this just add unnecessary complexity to the language?


Solution

  • Have you looked a Prolog? A Prolog program is basically a set of rules that is turned into one big evaluation engine.

    From my personal experience Prolog is a bit too weird and I actually prefer ifs, whiles and so on but YMMV.