You take great care when you're buying an app. to make sure it's good and it's not
going to ruin your machine and does exactly what you want. HTML
is the ultimate example of what troubles you get into if you are
promiscuous, right [laughs]? And you are promiscuous why? Because part of what HTML does is you have to
visit other people's Web sites. And you have to execute - not your code that you wrote
- other people's code.
HTML it's an interpreted system. The customers want instant gratification and you've got to
get cracking. Speed is of the essence. I think the nub of what we're trying to
get at is this: HTML seems to be able to tolerate your mistakes. But for those of
you who know a programming language -- Basic, C or whatever, you know they will
NOT tolerate your mistakes. They won't interpret for you, they won't compile a
program for you, unless it's correct. So how does this difference come about? If HTML
is a language - it's getting executed - what is it about it that makes it easy to be
tolerant? And on the face of it, yes, it's wonderful - it seems to put my errors
right! Perhaps we could start off with our good old friend the paragraph
And I'm going to just put a piece of text in here which says "Hello Sean". And even
though I absolutely don't have to do it nevertheless I want to do it - I want to close off
the paragraph. And then I'm going to open up another one, straightaway afterwards,
"Goodbye Dave". Once again we close off with a . You'll all understand that this is
a classic use of paragraphs. You put them in sequence you have first paragraph, second paragraph, third paragraph. All that kind of
thing. Does it mean anything and does it look any different and does
it do any different if I start messing about and saying: "I'm not going to sequence
them, I'm going to fit the second paragraph inside the first so it's nested, as we
say. It forms a hierarchy. It's a para within a para. You can see the difference
I've opened up a paragraph and I've said "Hello Sean". I've then opened up another paragraph
and I've said "This is a nest" just to hammer it home that the inner one really
is sitting inside the outer one. And then I dutifully closed them both off. You might
think: "Oh! I know what it will do. I might get 'Hello Sean' and then the phrase "This is a
nest" will be tabbed in and indented. Maybe that's what it does. So I've tried this
out in my own
Firefox browser. And, believe you me, it doesn't crash; it it just treats it
exactly as if it was sequential paragraphs. There's no sign of nesting or
anything. So if we develop these a little bit further now, we could say "OK do the
'Hello Sean' do another 'Goodbye Dave' >> Sean: So you're omitting the closing bit is
that right? >> DFB: I'm ommitting the closing of the paragraphs. Is that acceptable to HTML?
Yes it is. Nothing was gonna to fault you for missing out . And that, if you type that in,
will look the same as that. It wants to put the end-tags in and obviously, in some
sense, it does. But what's its rule and, here we go,
it probably won't do what you want to do. It does what it finds convenient and what
it finds convenient is the following rule: It says "I am going to assume, if you give me a
second and I'm already inside the first one I'll just close the first one off".
How would the browser cope if I sometimes put my in and sometimes didn't?
And the answer is that it will always, as far as I know, assume that you want a sequence
and that is what it will impose on you. What it comes down to is a sort of informal theorem,
something like the following. If you're trying to be very clever and mend
somebody's incorrect program then the problem is that if you have a structure
that can be 'a sequence of', or it can be 'a nest of, 'or it can be any any combination
you could have 'a sequence of nests' or a 'nest of sequences'. But if you once
start saying they can both co-exist -- nesting, sequencing -- then you must put
your end-tags in, if you want to be unambiguous. Otherwise how can it be repaired? So in
other words if both possibilities are possible then you
can't have smart behaviour because it cannot know how to repair it correctly. And what
HTML is doing is -- it's not solving the insoluble -- it's saying I have one view
of the world and I'm going to impose it on you and I am NOT going to
try and be clever. Now that, of course, is a luxury that HTML has. It basically says "I keep things
simple. I like things to be more or less sequential with the minimum of this embedding,
y' know and all that -- and that's why I can get away with murder. Now for those of
you that have written a program and know that you compile it, or even you
interpret it - Oh! boy -- it's not going to try and mend your bad program for you!
Why is it that things are so much more complicated/
Well, the answer is you can do more with these languages and you will want to do more.
Let me just invent a little piece of pseudo-code and I'll let you fill
this in, in either Basic, or C, or Java or whatever turns you on: printf("Hello Sean\n")
C programmers will know that if you want a new line at the end of that, which
you do - you'd better put a \n at the end. We're going round the stuff inside this block,
which is a very simple block -- it's just got a single print statement in it -- so what
we'll get is "Hello Sean", "Hello Sean", "Hello Sean", "Hello Sean".
ten times. Then I do another loop that goes around 10 times: "Goodbye Dave\n";
Let's hope this really would compile ! You can all
see what's going to happen when you execute this. I'm goingto get "Hello Sean" "Hello Sean" ten times
and "Goodbye Dave", "Goodbye Dave", "Goodbye Dave", Goodbye Dave" ten times. So that is what happens when you have a
sequence of blocks. But by comparison with "paragraph" in HTML can you,
in programming languages, have nested blocks? You bet you can! Now I'm going to say: loop
around 10 times on the following: printf("Hello Sean\n") but now look at what I'm going to
do I'm now not going to close off that block. I'm going to nest another loop block
inside it: "Goodbye Dave". Now let's make sure our brackets match. I've opened up one, I've opened
up two. I've closed this one, I must close that one. I hope you can all see and
understand what I'm trying to do here. I'm trying to do a loop within a loop
They are nested like sort of Russian dolls, one inside the other, but the effect of
this is completely different to the one I did previously. Here what's going to
happen is the outermost one goes around 10 times and every time it goes around it
does a "Hello Sean". But every time it does a "Hello Sean" it then goes into a nested inner
loop that does ten "Goodbye Dave"s. So for every one "Hello Sean" I print out, I'm now getting
ten "Goodbye Dave"s. Net result; I will end up with a hundred "Goodbye Dave"s
interleaved between ten "Hello Sean"s whereas, in the earlier case, I
had 20 print outs. I had ten "Hello Sean"s followed by ten "Goodbye Dave"s. Lots of students have
said to me over the years: "The C compiler is so clever, why can't it put my programs right for me?"
And the answer is if you omit your end-tags, how can it know whether you want
this one, or this one? They're both equally valid. This, then, is the absolute
fundamental conundrum: can you unambiguously put back the close curly
braces if users omit them? No you can't because you've got to work out: do they
want a sequence, a nest, a nest of sequences? There's all sorts of places to
put back the brackets and they have all sorts of different effects. And that is
why C, Java
Basic, whatever, have to be 'theological' and start laying down the law to you
"Brackets mismatch" or whatever, whenever you miss them out. The reason -- let's say it again --
why HTML can be so tolerant is because it's so much simpler than C. It is a
programming language; it is an execution environment, but it's not been built to
support deeply-nested hierarchical structures. So although it seems to be
tolerant, and although it seems to be correcting your program, you've got to
remember it isn't really doing the impossible. It's imposing a model on you
and hoping that the visual effect of what it does is so stunning that you won't
notice that it's not quite done what you hoped it would do.