Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Re: OT: Mathematics for programming (again)

by Jenda (Abbot)
on Sep 10, 2008 at 23:20 UTC ( #710487=note: print w/replies, xml ) Need Help??

in reply to OT: Mathematics for programming (again)

No, we can't do loops in all programming languages. And there is quite a few languages that have nothing in common with von Neumann at all. (Heck ... where's von Neumann in SQL?) And actually it's most often easier to reason about programs in those languages.

  • Comment on Re: OT: Mathematics for programming (again)

Replies are listed 'Best First'.
Re^2: OT: Mathematics for programming (again)
by mpeg4codec (Pilgrim) on Sep 11, 2008 at 07:04 UTC
    I imagine w-ber is only considering Turing-complete programming languages in this discussion (of which SQL is not one). Since all Turing-complete languages can simulate one another, and since at least one Turing-complete language has loops (Perl, for instance), then all Turing-complete languages must have some equivalent to looping. It may have to be simulated, and that simulation may not be efficient, but it's there nonetheless from a mathematical standpoint.

      Equivalent to looping, I buy that. But equivalent_to_X ne X.

      The fact that I can move and use legs for that doesn't mean that since a car can move as well it's got to have legs.

        More specifically, any language that has goto, conditional jumps, or continuations can be used to implement loops if they don't have native loops. Any language which can build and walk a tree or list can be used to implement a loop, too. Any language in which one can attach arbitrary actions to an iterator has a basic looping construct. Any language that can both increment or decrement an integer value and evaluate data as code can be used to implement loops.

        Things equivalent to loops in one situation or another include recursion, vector operators, iterators, and repetition operators. Tail recursion or mutual recursion between two subroutines can be converted into a looping construct. Vector operators are made up of loops unless they are using special explicitly parallel hardware. Iterators can both be the basis of a loop and can be implemented using a loop or some loop equivalent. Repetition operators are usually implemented as loops, but could be implemented using recursion, conditional jumps, lists, set manipulations, vector ops, or continuations. Any language in which you can construct, transform, and test arbitrary sets in arbitrary ways can be used as an equivalent to loops, too.

        SQL is a declarative set specification and transformation language. Where the loops in SQL are is obvious if you look at the issue sideways: they are implicit. SELECT, UPDATE, and DELETE are vector operators and WHERE confines the members of the vector to some subset of the master set. INSERT is a vector operator which adds to the master set. Each SQL statement (barring special functions) is a subset specification, set growth or shrinkage operation, or transformation on (sub)set members. There generally is an iterative or recursive program in charge of getting you the proper results for your requested set. You're just not writing it. It's the product of translation and happens inside the database software's planning and execution engines. Still, since SQL can store, transform, and test arbitrary sets in arbitrary ways, it can be used equivalently to a language with explicit loops in regards to those sets.

        That's a bit backwards: HOW it gets there is unimportant. That it can accomplish the task eventually is what really matters.

        If the Car and the Person were both Touring [sic] complete, and it is known that the Person can Tour France (using feet) then the implication is that the Car can Tour France as well. How it accomplishes that (with wheels) and how long it takes is unimportant. It can simulate the Human's route and make the Tour because it is, by definition, Touring complete.

        • Making a Tour = Loops
        • Touring France = Looping over all elements in a list of cities
        • Using Feet = "for" statement
        • Using Wheels = "JMP" statement

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://710487]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2018-06-18 21:54 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (111 votes). Check out past polls.