View Full Version : Must a programming language have while or if-then-else?
walfin
06-15-2008, 12:06 PM
When you show me how to do a while loop or an if-then-else statement in HTML, I'll believe you.
Dear INTJ and other posters,
I was given this challenge by AutisticCuckoo when I tried to say that HTML could be considered a programming language.
I believe it is not necessary for a language to have if-then-else or while/for to be considered a programming language. Such features are merely features necessary in imperative programming languages. Declarative languages like prolog do not necessarily have a "while loop" per se, though they have mechanisms to simulate them using recursion or other techniques.
What are your views?
AutisticCuckoo
06-15-2008, 04:08 PM
I think a programming language has to have some sort of flow control. Otherwise you can only create a simple sequence of statements, possibly influenced by user input, but not to a very large degree.
It doesn't have to be if-then-else or while loops, explicitly. Like you say, there are languages like Prolog that approach things from a different angle. They still provide flow control, though. (Which HTML doesn't.)
HackerX
06-15-2008, 08:06 PM
AutisticCuckoo wins this one :)
HTML is a markup language, not an programming language. It describes content.
Monte314
06-15-2008, 08:28 PM
For languages that implement what we would term "algorithms" (and this includes all finite length procedures that terminate), the answer is no. Neither of these flow control constructs is essential. They exist for the convenience of the developer.
rahdam
06-16-2008, 01:02 AM
AutisticCuckoo wins this one :)
HTML is a markup language, not an programming language. It describes content.
my thoughts exactly after reading the OP. I second this.
You dont need these constructs. SQL for example is results based and you dont not need flow control. Rule based inference engines do not need it either.
I went with "yes", but I should mention that a language merely needs a method of branching that allows for the implementation of these concepts. HTML does not provide this; it has not, and never will be, a programming language. It is merely for document structuring and vague layout.
SQL is not a programming language, either.
AutisticCuckoo
06-16-2008, 10:26 AM
You dont need these constructs. SQL for example is results based and you dont not need flow control. Rule based inference engines do not need it either.
SQL is not a programming language. PL/SQL is (or was?) a programming language, and it's got the flow control that is necessary for writing programs. Why would you need PL/SQL if SQL were a programming language? :)
SQL is not a programming language. PL/SQL is (or was?) a programming language, and it's got the flow control that is necessary for writing programs. Why would you need PL/SQL if SQL were a programming language? :)
I tend to group PL/SQL into the "scripting language" category.
There are some odd more recent languages that seriously blur the lines between scripting and programming languages, though. Python is a prime example of this...
AutisticCuckoo
06-16-2008, 02:08 PM
What is your definition of a 'scripting language' vs a 'programming language'?
For me, a scripting language is a subset of programming languages. I think of scripting languages as ones where the source code is interpreted at runtime, as opposed to compiled languages where you have object code that is immediately executable, or byte code that is run by a middle layer.
Of course, some scripting languages are actually compiled on-the-fly, like PHP. For me, the distinction is that with a scripting language you 'run' the source code without having to compile anything yourself. With that definition Java is not a scripting language, but JavaScript is.
Caramel
06-16-2008, 02:45 PM
Yes, for a language to be considered a programming language, it must have the while, for, if and else statements.
HTML is a markup language and SQL is a data definition language.
The difference between scripting languages and real programming languages has been blurry for years now (PHP, Python, Perl.. started as the first, ended as the latter.)
I think the difference between scripts and programs is that script contain just a bunch of commands and function calls with some parameters to generate some output from given input, where a program has its own classes and fuctions that the programmer coded in him/herself.
HackerX
06-16-2008, 08:35 PM
Yes, for a language to be considered a programming language, it must have the while, for, if and else statements.
Nah, walfin was correct in saying (and as others have mentioned) that a programming doesn't need to have these constructs to be considered. There are plenty of functional languages that don't have constructs like that, in comparision to a procedural language.
Contrast:
To view links or images in this forum your post count must be 2 or greater. You currently have 0 posts.
to
To view links or images in this forum your post count must be 2 or greater. You currently have 0 posts.
Scripting Language:
ie. Anything that is processed "on the fly" rather than being precompiled.
Scripting Language:
ie. Anything that is processed "on the fly" rather than being precompiled.
What about those that can go either way?
walfin
06-17-2008, 11:40 AM
AutisticCuckoo wins this one
HTML is a markup language, not an programming language. It describes content.
my thoughts exactly after reading the OP. I second this.
Completely unsubstantiated, I wonder why. I would've liked to have seen, at least, some brief arguments. Why can't a markup language be considered a subset of programming languages, pray tell?
Anyway this is not for the sake of "winning". Why would that be necessary? This is not an election. It was more to gather your views on what should and should not be considered a "programming" language.
What about those that can go either way?
both? i would suppose that the sets "programming language" and "scripting language" aren't necessarily mutually exclusive? i'd further argue that the purpose that the language was created for is more of the essence in determining which category it fits into, rather than whether it has to be compiled manually or not. but that is beyond the scope of this thread.
Caramel
06-17-2008, 12:08 PM
Nah, walfin was correct in saying (and as others have mentioned) that a programming doesn't need to have these constructs to be considered. There are plenty of functional languages that don't have constructs like that, in comparision to a procedural language.
Contrast:
To view links or images in this forum your post count must be 2 or greater. You currently have 0 posts.
to
To view links or images in this forum your post count must be 2 or greater. You currently have 0 posts.
Err, what do you mean? *confused* Programming languages have logical operators (if, else, or, and), and can do 'math'. In short, you can manipulate data with them and code/implement algorithms in them. Markup languages are just used to order data with.
Is it a markup language a programming language?.... I guess it really depends what the meaning of the word is is. huh?
To answer the question is is and HTML is not a programming language. HTML (Hyper Text Markup Language) is a set of agreed upon standards used to display data.
A programming language is used to manipulate data.
Sometimes a programming language can both manipulate data and display it, HTML is not one of these cases.
szaxazs
06-17-2008, 02:01 PM
Yes, for a language to be considered a programming language, it must have the while, for, if and else statements.
While?
For?
Programming language?
GOTO?
I think a programming language has to have some sort of flow control.
AutisticCuckoo gave the answer. There HAS TO BE some sort of flow control. If there's nothing to control the flow of the program, then the final product will be something very limited. Now about the "what this flow control should be" part, the answer is anything. Anything as long as this anything is able to control the flow of the program.
If-then-else is something very basic.
While and for from the other hand, is structured programming.
You could as well as use GOTO.
[GOTO is a very funky statement, by the way. I actually kinda like it.]
Caramel
06-17-2008, 02:11 PM
Ah, so thats what you mean. Well, then we all agree. =)
AutisticCuckoo
06-17-2008, 04:07 PM
Why can't a markup language be considered a subset of programming languages, pray tell?
Why don't you show us how HTML can be used for programming?
I'll make it easier for you by not even requiring the program to accept user input. Just create an HTML program that computes 1+1 and displays the result. (Without using JavaScript, of course; pure HTML only. No cheating by using iframes, objects, embeds or other replaced elements either.) I'll even let you use a Transitional doctype. :)
Any programming language should let you create a simple program to compute 1+1, don't you think?
If that's an unreasonable request, then at least show us any HTML program.
HackerX
06-17-2008, 09:33 PM
What about those that can go either way?
Eh? Scripting languages are a subset. Never said otherwise. For those that can go either way, then it's just context. There are plenty of languages that have both run time script engines and compilers available.
Completely unsubstantiated, I wonder why. I would've liked to have seen, at least, some brief arguments. Why can't a markup language be considered a subset of programming languages, pray tell?
Anyway this is not for the sake of "winning". Why would that be necessary? This is not an election. It was more to gather your views on what should and should not be considered a "programming" language.
Cause you started this thread, based on a challenge from AutisticCuckoo. By every current definition of what HTML is, and what other programming languages are, AutisticCuckoo won the challenge.
Err, what do you mean? *confused* Programming languages have logical operators (if, else, or, and), and can do 'math'. In short, you can manipulate data with them and code/implement algorithms in them. Markup languages are just used to order data with.
Yes, but in some languages those constructs don't equate to the concepts of if, else, while wtc. They're constructs relevant to procedural languages, but not necessarily to functional languages. The same thing can be achieved (i.e. the algorithm part of your thoughts), but in very different ways.
Markup languages define and describe.
Programming languages process.
both? i would suppose that the sets "programming language" and "scripting language" aren't necessarily mutually exclusive? i'd further argue that the purpose that the language was created for is more of the essence in determining which category it fits into, rather than whether it has to be compiled manually or not. but that is beyond the scope of this thread.
That makes it even worse, since many historic programming languages have been transformed into languages that more closely resemble scripting languages at this point. Few write sorting algorithms by hand anymore, for instance.
pitseleh402
06-18-2008, 03:04 AM
For those who aren't into reading long posts: here's the gist. I'd say the theoretical underpinning of this argument should probably placed in To view links or images in this forum your post count must be 2 or greater. You currently have 0 posts. (Turing_completeness). With the presupposition that we agree on this as the "measure" to determine what is or isn't a programming language, we can say HTML isn't a programming language (in this sense). Outside of this, YMMV, i.e. people are bound to their opinions.
What I do object to, however, is rather simplistic argument that "anything that doesn't have while or if-then-else shouldn't be considered programming language". That's way too simplistic, if not downright wrong. You're clearly not seeing past what's in front of you, a screen with text drizzled all over about a foot away from your face. Programs texts don't "run". In one way or the other, they get compiled or interpreted down to a sequence of instructions. When you get to that level, none of those fancy high-level language construct exist. What we have are simple store/load/add/subst/mul and jmp.
And when you get down to that level, it becomes rather clear what is or isn't programming language. In this context, ask yourself, what is HTML?
P.S. walfin, when wolf said "both", yes he meant that the domain of "compiled languages" and the domain of "interpreted languages" aren't necessarily mutually exclusive. In fact, that intersection is one of the hottest fields these days, starting with Java.
walfin
06-19-2008, 12:47 AM
That makes it even worse, since many historic programming languages have been transformed into languages that more closely resemble scripting languages at this point. Few write sorting algorithms by hand anymore, for instance.
Still do write sorts for fun sometimes. Like, mayb in amd64 assembly? It was kind of a new experience, so many registers to play with :)
In any case, I think the key distinction is whether the language, even after decades of transformation, still retains the ability to perform the purpose for which it was originally created, or whether it has made such a major departure from its intended purpose that it should be placed into a different category now. For example, you can still do very low-level programming in C++ (though not a lot of people do that anymore except for embedded systems and device drivers since there are so many libraries out there), so i would suppose that C++ is not ever likely to become a scripting language, unless it loses its systems programming capabilities (that would be a sad day).
Why don't you show us how HTML can be used for programming?
I'll make it easier for you by not even requiring the program to accept user input. Just create an HTML program that computes 1+1 and displays the result. (Without using JavaScript, of course; pure HTML only. No cheating by using iframes, objects, embeds or other replaced elements either.) I'll even let you use a Transitional doctype.
To view links or images in this forum your post count must be 2 or greater. You currently have 0 posts.
Any programming language should let you create a simple program to compute 1+1, don't you think?
If that's an unreasonable request, then at least show us any HTML program.
This does up the ante by a bit :). No iframes, objects, embeds, hmm...gimme a while 2 think about this. Lol. :)
P.S. walfin, when wolf said "both", yes he meant that the domain of "compiled languages" and the domain of "interpreted languages" aren't necessarily mutually exclusive. In fact, that intersection is one of the hottest fields these days, starting with Java.
wolf did NOT, in fact, use the word "both" in any one of his posts in this thread. His post was: "What about those that can go either way?". Java is not a language that can "go either way". And of course it is obvious to most with some coding experience that the domains of interpreted and compiled languages are not mutually exclusive. We were talking about the domains of "programming" and "scripting" languages, and my view was that a language that can be either pre-compiled or processed-on-the-fly probably falls into the intersection of the sets "programming" and "scripting".
For clarity's sake, I shall now state that the purpose of this thread was neither to respond to AutisticCuckoo's challenge (the response is actually in the thread where his challenge was originally posted, where i "cheated"), nor to discuss whether HTML is a programming language or not (i might start one when i've found a solution to AutisticCuckoo's 1+1 question and proved HTML to be Turing complete :) ). Nobody "wins" or "loses", since, as you can see, the subject of this post is "Must a programming language have while or if-then-else?" and nobody challenged me to post something like that. The point of mentioning AutisticCuckoo's post was merely to provide some background info on my motivation for creating this thread. That's all. This thread is about programming languages IN GENERAL, not about HTML.
vBulletin® v3.7.1, Copyright ©2000-2009, Jelsoft Enterprises Ltd.