The One Addition That Would Make HTML5 Great
Written by David Conrad   
Friday, 13 January 2012
Article Index
The One Addition That Would Make HTML5 Great
Can it be done?

 

Complications

There are some problems, however. In particular, you may have notice that there is small difficulty with how to use HTML to instantiate a JavaScript object. After all, JavaScript doesn't do classes. The easy option is to insist that any HTML instantiatable object has to have a constructor function of the same name.

So when you use a tag <MyObject> what happens is that the instantiator calls MyObject() and when you use:

<MyObject id="MyName">

the instantiator does:

var MyName=MyObject();

You can work out the other details, like how properties are intialized and so on.

What about the difficulty of having access to the JavaScript that creates objects before the page is loaded?

Another easy one to answer - simply add an option to load a JavaScript file as the first act in loading a page. Either the page could be specified as MyPage.jsp, which would load the initial JavaScript before the HTML, or you could simply have a new tag something like:

<Script Intial>

which loads the JavaScript needed before the page is constructed.

html5logo

The benefits of .jsp

Personally I prefer the option of loading a .jsp page because it makes it so much easier to do away with markup altogether for any programmer wanting to work in code. After all if HTML is just an object instantiation language then the same job can be done in code and the markup isn't necessary if you don't want to use it.

At this point you might be fuming and saying that HTML is a pure semantic markup language. Don't worry it still can be for those who want to think that this is what it is. There is no reason the CSS shouldn't continue to work in exactly the same way as it does now and in fact for those who want to ignore the changes nothing has changed.

 

xaml

 

There is another reason you might be fuming. There is a clear case that I have just stolen all of this from XAML and other instantiation languages. True, I admit it;  this is not a particularly original idea. What I am trying to point out is that we can make the change to HTML to make it an object-instantiation language with virtually no impact on the way it is used now and with every impact on the way it is used in the future.

It seems to me that it is all win and if we make this one change HTML will be a fit tool for constructing apps without damaging its layout abilities or its theoretical purity.

 

w3c

 

So let's start lobbying WhatWG and W3C and ...

Let's try and make HTML and the web a better place for programmers.

Further Reading

2011 - The Year HTML5 Won

HTML - is it really going to hack it?

Semantic HTML5?

HTML5 - I've seen it. It's rubbish.

WinRT JavaScript - WinControls

 

espbook

 

Comments




or email your comment to: comments@i-programmer.info


 

To be informed about new articles on I Programmer, subscribe to the RSS feed, follow us on Google+, Twitter, Linkedin or Facebook or sign up for our weekly newsletter.

 

Banner



Last Updated ( Friday, 13 January 2012 )