We’ve talked before about how JavaScript can be used to enhance your marketing platform as well as how you shouldnever use JavaScript in email campaigns. Today I wanted to go ahead and break things down as to why JavaScript is absolutely the best language for the web as we know it today.
#10. JavaScript is Easy to Learn
In years past JavaScript was often seen as a clumsy language most closely associated with annoying internet popups and browser incompatibility issues. Some people still shudder at the very mention of “JavaScript”.
In the last decade, this has changed dramatically. Now JavaScript is easy to pick up because of the very flexible nature of the language, is widely standardized across common browsers and is far more useful than ever before! Because JavaScript is not a compiled language, things like memory management are not a big concern. You won’t find yourself having to worry about loading and unloading content, compiling, or setting primitive data types because most of the heavy lifting is handled by the browser. Code Academy is an incredible resource for learning JavaScript for free in an interactive environment that you can take at your own pace. Here is a quicker bird’s eye view reference of JavaScript syntax and key structural elements.
#9. JavaScript is Easy to Edit
JavaScript is very easy to get started with because you don’t need much to do so. JavaScript is a scripting programming language so the code you write does not need to be compiled and as such does not require a compiler or any other expensive software to write. That’s right, JavaScript is just plain text, so all you need to write it is notepad or any other plain text editor. Personally, I recommend notepad++, as it has all the bells and whistles you want (syntax highlighting, advanced search features, tabs) without any of the overhead of larger programs like Adobe’s Dream Weaver and most importantly without a price tag since it’s completely free.
#8. JavaScript is a Prototyping Language
In a prototyping language every object is an instance of a class. What that means is that objects can be defined and developed on the fly to suit a particular use, rather than having to build out specific classes to handle a specific need. This opens the door for very rapid and flexible development as well as a wide array of possible design patterns that would not be possible in more structured languages. The ability to prototype also allows seamless extension of existing classes, even built in ones.
Let’s say you wanted to extend the built in array class to feature a method/function that will only keep the unique values in an array. We take the built in array class and extend it with a prototype function called “getUnique”.
Array.prototype.getUnique = function(){
var u = {}, a = [];
for(var i = 0, l = this.length; i < l; ++i){
if(u.hasOwnProperty(this[i])) {
continue;
}
a.push(this[i]);
u[this[i]] = 1;
}
return a;
}
Here we are actually extending the functionality of the Array class in order to allow it to remove non-unique elements. For example:
["Mary", "Joseph", "Jim", "Bob", "Mary", "Bob", "Leonard"].getUnique();
will return only the unique array:
["Mary", "Joseph", "Jim", "Bob", "Leonard"]
We have effectively changed the array class to do things it was never originally designed to. This is the power of prototyping!
#7. There are Lots of Available Tools
JavaScript is interpreted by the browser and over time (most) browsers have adapted to giving power users enough freedom to look under the hood and see or even change the JavaScript that’s running behind your favorite sites. Pressing F12 on most browsers will open the console which can let you talk directly to the JavaScript and explore it from a top down perspective. In addition to this, many talented developers have created their own publicly available and free tools that make working with JavaScript even easier.
Easily the top two I would recommend are FireBug and the Web Developer Toolbar. No serious web developer should be without these extremely helpful tools. Firebug is a suite of tools that includes a console, DOM browser, tools for monitoring load times on pages and many many more. It’s a fantastic utility in which to test JavaScript without having to worry about saving, uploading, versioning or anything other than the things you are working on. The Web Developer Toolbar is basically a web developer’s toolbox. It can do it all, from editing CSS on the fly to displaying a ruler on the screen for easy measuring. While this isn’t specifically a tool for JavaScript, it goes hand in hand with most things you’re likely to be using JavaScript for.
#6. JavaScript is Easy to Debug
Using these tools makes it very easy to debug your JavaScript too. Any error you run into can be traced back to the exact place it occurred in the browser console or in FireBug. You can place breakpoints in the page code in order to debug the code using traditional methodologies, or simply unit test the bits in the console until the part that isn’t working becomes happily apparent.
#5. JavaScript Allows for object oriented design
While JavaScript is probably not the first language that comes to mind when talking about O.O.P. (object oriented programming), it is absolutely able to make use of Object Oriented Design Patterns and principles.
Using JavaScript you can easily create objects and use special OOP design patterns. Unlike more structured languages, however, JavaScript does not force you to use OOP, which can be advantageous for smaller projects.
#4. JavaScript is Easily Extensible (jQuery, Prototype, Dojo)
JavaScript alone is a very fast and powerful language. It can do extremely complex things behind the scenes or manipulate aesthetics on web pages in ways you wouldn’t believe. Still, some of these manipulations are difficult to design and construct. They require a lot of code and time to develop. To this end, developers have written several very good libraries to support the language and allow it to easily manipulate web pages with just a few lines of code.
Perhaps the most noteworthy of these is jQuery, which can be added simply by including the following line:
ScriptsSrc.net is also a great resource for quickly getting the library code you need.
#3. AJAX
For a long time the web was a very static place. The best we could offer was animated GIFs until Macromedia’s Flash came along and changed that. Still, for the most part, if something needed to change on a web page, the page had to be reloaded. Reloading a page is never pretty, either aesthetically or from a data management standpoint, so it was with open arms that the web development community welcomed the inclusion of
XMLHttpRequest
in browsers around the turn of the century.
AJAX (Asynchronous JavaScript and XML) was born from
XMLHttpRequest
‘s ability to ask the server for information without leaving the page. Now you can see this in action everywhere on the web. If you’ve ever seen a loading spinner while you’re waiting for some data to pop up on the screen, that’s AJAX hard at work.#2. JavaScript is a Natural fit for the Web
JavaScript may have had humble beginnings, but has grown astronomically over the last decade in scope and application. It is fully supported by all modern browsers and works seamlessly with HTML/DHTML, CSS3 and background services via AJAX. Take a look at its growing popularity compared to other popular languages.
What’s more, the web is now changing from a place dominated by load heavy Flash apps, to light weight and flexible HTML5 canvas constructs. Since HTML5′s introduction in early 2011, the web has started to move away from relying on Adobe’s Flash to give users and interactive experience. HTML5 does not require a plug in to view or expensive software to develop. The canvas element works by code that is also written as plain text and best of all it’s code that is fundamentally based on JavaScript and can interface with existing JavaScript code seamlessly (unlike Flash, which requires some workarounds).
#1. Node.js
Perhaps the most limiting thing about JavaScript is that it only works on the front end. That is, it’s perfect for manipulating web pages, creating User Interfaces and fetching data from the server via AJAX, but in order to fetch that data it still has to rely on other technologies such as PHP or .Net to run on the server and serve that information up. With Node.js this is slowly starting to change. Node.js is built on Google Chrome’s JavaScript Runtime engine called V8. When Google was writing the code for their now well known browser Chrome, they had to rethink how JavaScript would be evaluated and what the best and and most efficient way of handling modern JavaScript would be. Unlike Internet Explorer or even Firefox, Google had the advantage of starting fresh while already being aware of some of the pitfalls in developing a browser.
The result is the V8 JavaScript runtime engine. This engine was then tossed around between some of the best and brightest developers in the industry and an interesting thing was discovered. V8 could be used to handle the role of a server side language as well, with one main advantage: JavaScript is asynchronous. What this means is that while a normal server side language has to process everything sequentially, JavaScript does not have that limitation. It can start task A, move on to task B, processing both (or as many instances as needed) at once. This makes the ability of a server to serve up web pages unimaginably more powerful and makes things like DOS (Denial of Service) attacks a thing of the past (in theory).
In short, JavaScript is quickly becoming not just the ideal language for the web, but indeed a big composition of the web itself. The future of the web looks bright, and perhaps more importantly free for developers everywhere.
thumbs up :)
ReplyDelete