Sunday, September 12, 2010

HTML and Javascript: The assembly language for the web

What is programming? In a broad sense every device exposes an interface for tweaking its behavior. How many different things one can achieve using the device is determined by the number of permutations allowed by the interface. The interface can be complex or simple to program.

Now lets jump to the more familiar area of computer programming!

To provide a software based interface to computer hardware assembly languages were created which I surmise must have greatly relieved the people who had to write binary machine code to make their programs work. Similarly fortran provided respite to assembly programmers. Followed by C++, Java, Python and numerous other languages under the sun. Of course the ease with which programs could be written with these new interfaces allowed complex tasks to be achieved.

Now let us draw a parallel in the world of web programming. I am a dabbler at best when it comes to programming for the web. But still I will be able to share some thoughts. The early web browsers provided an HTML based interface for programming them. With the increasing number of users, this HTML became sophisticated as demand for better presentation arose. Thus this HTML interface. CSS allowed the programmers to modularize their presentation style across web pages. How well a programmer could apply Software Engineering concepts like reusability, modularity and cohesion to the design of web pages along with the aesthetic considerations determined how readable and managable the websites were.

But this HTML provides only presentation tags. The web browser would have to go through a full page reload for each new request. Presto ... Enter Javascript. This allowed custom control flow to program the browser.

But why did I call HTML+javascript to assembly language of the web. Well HTML+javascript is widely used but is too basic for feature rich web applications. Each browser has different behavior with respect to the html and js on the page. So programmers should be coding separately for each browser and they are expected to maintain the code as well.

So what is the solution. Well of late I encountered JSF which provides a MVC architecture which allows you to write business code in Java while offloading the HTML and JS tasks to the framework itself. There are other frameworks like django which are popular. The underlying idea is this, HTML and JS provide a rudimentary "interface" for coding. So a new High Level model is developed

With the new Chrome OS being rolled out, it will be the aim of most web apps to treat HTML + JS as the target "assembly language" to be generated by the compiler for their framework. The browser is the incarnation of the "hardware" for which the "assembly language" is generated.

Did I just overcomplicate a simple Idea?

1 comment:

  1. Fair enough, but if you probe deeper you'll find that javascript is or at least could have been a much more powerful language, had Microsoft not kept their implementation broken for the longest time. JS supports some very useful features like closures, mix-ins etc. which indicate a carefully designed language (ECMAscript, officially).
    Of course there are numerous frameworks (dojo, jquery, GWT...) with varied levels of abstraction but they were not born because js was lacking, rather that it's implementations were dramatically different and slow.
    HTML5 seems to indicate the browser wars will for the first time help the developers avoid having to learn ten different frameworks before making a decent website.

    ReplyDelete