Why JavaScript?

Modern days software migrates massively to a web platform. But, while the trend is the same throughout the world, the Implementations vary greatly. On the server side, there are the most diverse frameworks and a couple of popular programming languages such as PHP, Java, .NET. On the client side, things are a bit simpler, with frameworks manipulating a similar DOM environment of the web browsers.
A web application relies on the browser GUI and on the browser engine to run its client part. These interactions have been standardized as Document Object Model (DOM) 2 or 3. For the implementation of the client part, one needs knowledge of the HTML markup language for the structure, of the CSS styling language for theming and, of the JavaScript language for the behavior of the client. But, while the knowledge of these three fields is mandatory for ensuring a complete user experience, the mechanics that lie behind all come from a single component model.

JavaScript – the language of DOM

Developers of browses adopted the concept of an event driven GUI from the previous work of the GUI operating systems. No wonder that also the implementation of the browser development shares some previous known programming concepts like OOP, COM, RPC, event queues, event pooling and so on. If we take for example, a generic web browser written in Java, the layout, the styling and the behavior engines address the same runtime GUI components written in OOP Java. That means that all three aspects of a component can be entirely controlled using the chosen development language (i.e. Java). But from the web developer point of view, we are constraint to use standardized markup, styling and behavior languages. Analogous to COM interfaces, these are different languages that access the same runtime components – the browser’s GUI. Taken separately, HTML, CSS and JavaScript have a limited access level to the runtime component and, it seems that all three are required to fully control the client part of a web application. But this is not true …
In the web apps world, HTML plays the role of a data structuring language like XML. It mostly describes the layout of the application components and, with a certain degree of success, their runtime properties. In the light of the previously presented browser development model, it acts as the “poor man’s” scripting language used to access the browser’s layout and rendering engines.
CSS is a global styling language with extended use outside the web platform. For web browsers, it accesses the layout and rendering engines with even less control than HTML, but is essential to ensure the enterprise model of the separation of concerns, where designer and programmer tasks are clearly separated.
While HTML and CSS can be regarded as scripting languages with a certain level of control over browser’s GUI, JavaScript is the closest scripting language to the GUI implementation language and plays a similar role to that of scripting languages for the COM interfaces. All three aspects of layout, styling and behavior can be controlled using JavaScript. That happens because JavaScript follows in the closest way the GUI event oriented model of the browsers implementation. With a closer look, an entire client application can be generated using JavaScript or with a higher level framework like GWT which in turn generates the required JavaScript.

JavaScript is power in brackets

Modern programming languages provide high abstraction level libraries like STL to use for structures, iterators, algorithms and so on. A common task is organizing and accessing collections of heterogeneous objects. This is generally done using named pairs of key-value collections called hashes. Even the classic members of the structures or of the class instances can be regarded as named properties that point to certain values. This field of hashes is a field where JavaScript excels at. The implementation is the simplest, every object can be regarded as a hash of its properties. In JavaScript, every non-local variable can be accessed using a root object (i.e. window) and a series of strings or integers.
Example:

// storing a configuration
window.myConfig = {
	title: 'Sample app',
	layout: {
		align: ['left', 'top'],
		coordinates: [0, 0, 500, 200],
		doubleFrame: true
	}
};
// accessing the forth coordinate using only the bracket notation
var nForth = window['myConfig']['layout']['coordinates'][3];
// this property can be stored to and read from a text file e.g.
// myConfig.layout.coordinates.3 = 200

This offers the language an immense power in generating and manipulating sequences of code from static data structures. For most cases of code generation, with the help of the bracket notation, the use of eval() function can be entirely avoided.
Also JavaScript has for .. in construct that iterates over named and unnamed properties like other languages iterators do. For the time JavaScript was developed, the language features were revolutionary. For present days, with a little care, JavaScript can go on pair with the modern OOP languages.

ECMA, release JavaScript!

Compared to modern OOP scripting languages like Python or PHP5, JavaScript lacks several features that make the development cycle enterprise ready. First known problem is the lack of a class inheritance model, addressed by ECMA drafts like Harmony, but surprisingly not yet standardized. Other maturity challenge is the implementation of standard algorithms and base libraries like e.g. PHP has. But we saw in the previous topic how the bracket notation makes it easy to do hashes and collection iteration. Other required feature in nowadays environment is an architecture independent compiled form of the language, like Java or .NET have. But JIT compilers for JavaScript are implemented in every mainstream browser and, it’s just a matter of political coordination until the browser development teams will submit a draft regarding this feature. Although, for security reasons, JavaScript source code should be made available to the web clients, a standard compiled form will bring JavaScript to the maturity of the preferred development languages in the software business. Current methods of compression and of obfuscation of the JavaScript source code are just a way of demanding this developer requested feature. A standard compiled form adds a superior level of copyright protection compared to simply signing raw source code and it will be much faster to download and to execute.
These are just a few requirements that make JavaScript to lag behind other development platforms. But the reason of the delay should be seeked out in the corporative interests of the major players in the development world. It is the voice of the united community that can go through the opacity of the standardization commission and eventually impose these popular demands. And, if ECMA cannot solve the problem, we can make the actual and useful standard in their place. Look only to the multitude of class systems implemented for this most useful prototypal language.

JavaScript can serve!

A modern web application has a solid server side part which ensures the stability and the security of the data processing. The most used platforms for the server side are PHP, Java and .NET. All are mature frameworks with an up-to-date programming language and a powerful library stack. Among all, PHP has gained its popularity due to its Swiss-knife integrated libraries which seem to be the recipe of success for a useful server stack.
Until recent years, JavaScript was limited to the client side world because of its absence as a useful stack on the server side. This is no longer a problem since the fast catch-up of Node.js which aims to bring the popularity of the PHP to the server side JavaScript. When this project succeeds, JavaScript can be used unitarily both for the client and for the server sides. The developers can concentrate on the business logic instead of learning different languages just to be able to complete an application.

Conclusion

JavaScript was invented as an evolutionary language with garbage collection, high level string and hash manipulation, regular expression engine and dozens of useful features not limited to web programming.
It is the context of big players that hindered its way as a global programming language, but their grasp on proprietary platforms cannot go on with the current age.
You should use JavaScript and support it as a free and universal programming language and the world will adhere to the evidence!

Digg ThisShare via emailShare on MyspaceSubmit to redditSubmit to StumbleUpon

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Copyright © 2012 - ZB The Zonebuilder
Frontier Theme