[UPHPU] OT: programming vs. markup languages

Mac Newbold mac at macnewbold.com
Mon Jun 6 11:58:28 MDT 2005


Friday at 12:56pm, Daniel C. said:

>> Your designers don't know how to program? I thought that they were
>> coding your display structure in XHTML and coding your display logic
>> in SMARTY. Are you not considering XHTML and SMARTY as a programming
>> languages?
>
> The language that Smarty gives you is not, actually, (I believe)
> Turing equivalent.  You can add more functions to make it Turing
> equivalent, but out of the box (again, I believe) it's not.  Does this
> mean that it doesn't qualify as a programming language?

Um, I couldn't resist adding something here. Whether or not a language is 
turing equivalent or not is not something that can be changed by adding 
more functions, unless they're written in another (turing equivalent) 
language. If the language _could_ be extended to be turing equivalent, 
including by embedding some other language in it, then it already _is_ 
turing equivalent. Any syntax or "language" of any type that can be a part 
of another (i.e. by embedding) is a valid part of the language to begin 
with, whether or not you actually are the embedding.

If the only way you can get real Turing equivalence is by extending the 
base system, then it obviously isn't as useful as one that is turing 
equivalent without such an extension, but as far as their computational 
power or expressivity go, they're already equivalent. The one would just 
be harder to use to express the same idea.

For non-programmers who didn't read the linked articles, Turing 
equivalence is simply a way of expressing the kinds of programs you can 
write with it. It's based on Turing's idea of a "Turing machine," which is 
a conceptual machine more than an actual mechanical artifact. It basically 
is a simple approximation of a general-purpose computer. It can perform 
comparisons, make decisions, and read and write "memory" positions 
arbitrarily (e.g. RAM). Other similar conceptual machines are things like 
state machines ("finite automata") that read a string of input, and 
"push-down" machines that read input and have a stack for memory.

The comparison to Turing's machine is because it can compute anything that 
can be computed. (Computability is another fun topic.)

A language that _is_ Turing equivalent can also be used to compute 
anything computable. A language that isn't is in essence crippled, and can 
only be used for a subset of those things. That's okay in certain cases.

With a thing like smarty, if it couldn't use PHP at all, it wouldn't be 
Turing equivalent, and as you might imagine, couldn't do a whole lot of 
things that you can do in PHP.

Note that all of this is mostly irrelevant to what particular langauge 
features a language has. For instance, C can't do classes, methods, and 
objects, like C++ or Java can. But they're both turing equivalent, and 
therefore, can compute all the same things. Same thing with PHP and almost 
every other general-purpose programming language out there you know of.

Mac

--
Mac Newbold		MNE - Mac Newbold Enterprises, LLC
mac at macnewbold.com	http://www.macnewbold.com/



More information about the UPHPU mailing list