|
The more I play around with Swearjure (I've now been able to create a fully working quicksort), the more I appreciate certain kinds of programming constructs we today take for granted. However, I also realize that most of what we would believe is essential for ANY programming language to be turing complete may not be needed if we take another set of programming constructs instead. Take conditionals as an example of what something people consider to be critical to make a working programming language, yet really isn't if we introduce another programming construct. What does programming look like if we do away with conditional branching?
|
|
|
|
|
Terrence Dorsey wrote: What does programming look like if we do away with conditional branching?
I loathe if-then-else statements.
Marc
|
|
|
|
|
If he can implement a Turing Machine that way then it is Turing Complete.
Personally, I don't care much for recursion -- Fibonacci and Factorials are particularly poor targets for recursion.
|
|
|
|
|
PIEBALDconsult wrote: Fibonacci and Factorials are particularly poor targets for recursion
That depends a lot on your language. In Haskell, for example, which employs lazy evaluation, they work just fine.
In a procedural language, factorials only really work well in the presence of tail call optimization, and fibs not at all, without some form of Memoization[^] going on.
|
|
|
|
|
I find hiding the branch in the expression
res[n<2]</pre> to be kinda cheating.<br />
<div class="signature"><small><a href="http://www.codeproject.com/Articles/453077/Generating-Keys-for-a-Custom-Sort-Order"><code>ORDER BY what user wants
|
|
|
|
|
It looks like a pain in ***whatever really hurts here***
Seulement, dans certains cas, n'est-ce pas, on n'entend guère que ce qu'on désire entendre et ce qui vous arrange le mieux... [^]
|
|
|
|
|
This isn't a new idea. I first came across this type of programming back in the 90s when we had to integrate one of our systems into a language called ObjectStar (formerly Huron). I remember the O* devs as being real zealots - they worked for a company called Amdahl that was heavily involved in pushing it.
|
|
|
|
|
Objectstar did have conditionals, it just wasn't with if-then-else, do while, etc. You put in an evaluation and if it was true or false executed certain lines of code. It took a while to wrap your head around but was pretty simple once you had the "a-ha" moment.
|
|
|
|
|
Ahh. That wasn't what the Amdahl devs were telling us. They tried to keep it all mysterious and mystical. We had a visit from a guy called something like Dara Yuvari (who'd invented the language IIRC), and you'd have thought it was the second coming of the messiah.
|
|
|
|
|
No, no second coming. I did 6 years of O* programming with a VB front end. I liked it and they had plenty of great ideas but it was a closed system. Objectstar was the DB, the programming language and the problem reporting system all rolled into one. It allowed you to rewrite ANY of the programming language as well, gave you the option to fix anything. The programming environment was done in a 3270 terminal emulator so the coding window was small. if I remember correctly you were limited to 5 conditions, 40 lines of code and upon saveing the code you were obliged to add a comment to explain what it did.
Looked something like this.
variable1 > 3 | Y N
variable2 > 5 | Y Y N
---------------------------------
some code to execute | 1 1
more code to exectue | 2
still more code... | 2
still more code... | 1
call another chunk of code| 3 3 3
----------------------------------
|
|
|
|