Naked JavaScript

Taking the DOM off JavaScript 

Going evented with Node.js

One of the most exciting presentations to come out of JSConf.eu was Ryan Dahl's presentation of his incredible Node.js project. Ironically we had just covered it at last week's NOVALANG session. I decided it would be a great article for Naked JavaScript in order to provide an nice introduction to Node.js and the broader topic of CommonJS as well. By the end of this article you will have a functional Node.js installation and built several interesting applications. Enjoy!

What is Node.js

Node.js is an evented I/O framework built on top of Google's V8 JavaScript engine. It's goal is to provide an incredibly powerful I/O system through which you can build highly efficient and s calable applications without any knowledge of "advanced topics" such as threading, processes, etc.. It does this by using an event-based programming model similar to Python's Twisted framework or Ruby's EventMachine. In the event-based model, you registered what should happen, commonly referred to as a callback, when an specific event happens. You do not worry about the capturing, execution, or closing of the event. This is distinct from threaded programming which requires the developer to identify the "event", create the thread, execute the processing, and clean up the thread, all of which is complex and littered with hard-to-debug issue. The easiest way to describe the event model, especially to people coming from browser-based JavaScript, is that it is exactly how you program interactivity in the browser. Take the following example which shows evented programming using AJAX requests in Dojo, jQuery, and Prototype.

What is going on in each of these AJAX requests is that we describe a function on what to do upon a successful GET request to the specific url, in this case "/dragons", and that function takes whatever data happens. In standard procedural programming, one would think that the process would wait for the request to be made and then continue about processing the rest of the program. In event-based programming, the function is identified and stored until the specified event (in this case successful response from the GET request). The processing of the program continues on, it does not stop or "block" waiting for the rest of the operation, in this case make and receive the GET request, to finish out. Once the request and response are executed, then the event is triggered and the stored function is called with the data passed into it. I am focusing on this because it is vastly different than the normal mode of programming, so its critical to get it right for both Node.js and general event based programming. 

Installing Node.js

At the time of this writing, Node.js is only installabled by source, due mainly because it is a constantly evolving project. To get started open up a terminal in our previous established javascript directory and issue the following commands. They will checkout the current Node.js branch from Github, configure, make both V8 and Node.js, and install it to /usr/local/bin. This should work perfectly fine on Mac OS X and Linux, Windows is not currently supported by Node.js.

Once this completes, it will install two Node.js specific executables, node and node-repl. The first one, node, is used to execute Node.js files, like the ones we will create during this article. The other, node-repl, is a Read-Eval-Print-Loop which will allow you to quick try out bits of c ode in Node.js without creating a file. This can be a lot of fun to start with if you want to just verify your installation. You can run any standard JavaScript code in node-repl directly. 

Building HTTP

The event-based programming is fundamental to proper JavaScript programming and Node.js programming and allows for elegant programs that handle massively concurrent systems with little code, memory, and processing power. The best example of this is the "build a web server" example on the homepage of the Node.js website, re-posted below. In this non-trivial example, we are setting up a highly scalable, web server bound to port 8000 that simply serves up a "hello world" web page after 2 seconds have past (have to make it feel real after all). 

The code is pure JavaScript so it should be relatively easy to understand. Briefly though, the application is doing the following:

  1. Include the standard libraries system and HTTP AND set the to contextually appropriate variable names.
  2. Create an HTTP server listening on port 8000 and attach the following function to handle any incoming calls.
  3. Within the function (req, res) {...} body is where our web action happens, which in this case just sets the response headers, sends the body "Hello World", and finishes the request. It does this only after 2 seconds (2000) have elapsed.

The interesting thing of note here is the way in which the server processing is handled. The function(req, res) {...} that we create here is actually registered to an event (in this case an incoming HTTP request on port 8000). When the event happens, the code is then execute with the provided parameters of request object and response object. This makes great little network server because when nothing is happening (IE no traffic) then nothing is happening (IE no processing). The code after the registration event happens immediately since the listen and processing is done not at the point of interpretation, but at event trigger. 

Nom, Nom, Nom

Now that we have created a server, lets create a brand new client to consume the data from that (or any server). Take a look at the following code and see if it makes sense to you, there are some tricky components of this so take your time. 

Forgoing the parts we have already covered, notice the first function we create called read. It takes a parameter callback which we execute and pass the data to once we have obtained it from the HTTP service. Within read, we create a HTTP client with the http.createClient(port, domain); syntax, this just sets up the necessary structure for the connection. Then we assign a get request of "/index" to the connection which returns a request object. This is not actually make the request yet. It waits until it is at least provided the finish command so that you can assign HTTP headers or do other processing. In the request.finish() function we pass an anonymous function that processes the response object, in here things get a little crazy.

Within the anonymous function (starting at line 6) we create an empty string called responseBody and then set the response encoding to UTF-8. We then attach a listener for the event "body" with another anonymous function that appends chunks of data to our responseBody string. This is the way to pull information from the service and is done in this way to facilitate chunked data delivery, you are actually pulling each chunk of data off the wire and into your string. This is great for large data chunks because you could start processing the data even while downloading the data. After one or many "body" events, there will be a "complete" event fired which indicates that the HTTP response has completed. In the "complete" event anonymous function we simply execute the callback parameter function and pass it the data. For this example, the call back function only outputs to the console, so nothing special, but in just a small number of lines, you have created a very powerful HTTP consuming application. 

Twitter Client

With what we have done so far we can actually create a full and meaningful application consuming an external service instead of our own hello world. The following code is just a simple modification of the localhost calling HTTP client we just wrote, but this time it is calling Twitter's search API to find any tweets about JSConf. This will automatically query the API every minute and pull the newest items and display in bottom posting order. You can just leave this terminal window open and watch all the tweets fly by while using very little processor time and memory space, 0.1% CPU and 30MB on my laptop. Perfect for netbooks and other battery constrained devices and best of all its only JavaScript!

Other Frivalities

While showing off the HTTP capabilities of Node.js are incredibly sexy and most likely the very future of web application development, it can do so much more. Take for instance this bit of code from the Node.js API documentation, which opens a raw TCP socket on port 7000 of the loopback interface. What is incredibly striking about this is that it is so fundamentally similar to the aforementioned HTTP client and HTTP server we created. In the same fashion as client side JavaScript libraries, Node.js callbacks are uniform regardless of what the event is that is being tracked. You do not worry about opening the TCP socket, threading, mutexes, or any of that complexity that in any other language would be an initial requirement.

You can have fun with this code using a simple telnet command of:

telnet localhost 7000

Also you apply the evented model to standard system execution as shown in the following code segment which executes a "ls" directory listing command and attaches a callback that will be executed upon the return of the system command execution. The Node.js execution does not stop or block waiting for the directory listing to occur, instead it continues to execute the next commands. 

Conclusion

Node.js is a revolutionary technology built on top of another powerful revolutionary technology, V8. It is gathering a lot of attention within the technology community, mainly driven by Ryan's riveting presentation at JSConf.eu. What we have covered is just scratching the surface of the power in this incredibly platform and you owe it to yourself to try your own hand at coding in Node.js, you mind find that you actually enjoy CommonJS programming more than client-side JavaScript!

More Power From The People

For interesting libraries on top of Node.js check out the libraries page on the Node.js Github wiki available at: https://www.wiki.github.com/ry/node There are some amazing projects out there that will allow you to combine the power of Node.js with other cutting edge technologies.

Loading mentions Retweet

Comments [21]

JavaScript From The Start: Basic Syntax

Overview

Before we go too far into the realm of cutting edge JavaScript technology, it  is critical that we are familiar with the proper syntax and concepts of JavaScript. Writing JavaScript is easy, many people do it every day, but writing good JavaScript is surprisingly a lot harder. This is in part do to the rushed creation of JavaScript as a scripting language for the DOM and also due to the variety of implementations of JavaScript interpreters, each with their own 'oddities', by the major browser vendors over the years. In terms of syntax, JavaScript is visually similar to the C/C++ and Java programming languages, but in terms of function it is actually closer related to the Self and Scheme programming languages. Unfortunately, the visual similarity of the language to the wider known languages of C/C++ and Java make JavaScript programming highly suspectible to confusion and error. The goal of this section is to provide an overview of the JavaScript programming language as if it were the first language that you are learning. That said, it is strongly recommended that you carefully read this section, because JavaScript, even in its most trivial format, is vastly different from the aforementioned programming languages. 

Basic Syntax - the var keyword and scope

JavaScript shares a similar syntax to that of C/C++ and Java in its most general form. Variable assignments are done using the equals sign with the variable name on the lefthand side and the value, either direct or through the evaluation of an expression, on the righthand side. The following will take two numbers add them together and store the resulting value, in this case 5, as a named variable of val.

var val = 2+3;

Even with this most trivial of examples, there are many key facets of the JavaScript programming language that we need to discuss and ensure a proper base of knowledge. Notice how the code sample begins with the var keyword which means variable. This keyword identifies the initialization of a new variable within its current scope. The var keyword is not explicitly required by the language for identifying a variable, but it is strongly recommended as a convention of proper JavaScript. When you use the var keyword, it creates a new variable in the current scope, which means that the variable is only available and accessible to to other operations in the same scope or scopes created within the current scope. Before we get too deep, the term "scope" in this context is just a way of describing the lifetime of a variable. In JavaScript, a variable assigned without the var keyword will use either a pre-defined variable with the same name that is accessible by the current scope OR if no such variable is defined, it will set the variable in the global namespace.

NAKEDNOTE: JavaScript Types

Unlike C/C++ and Java, there is no need to declare a type for the variable. This is due to the fact that JavaScript is a dynamic and weakly typed language, which means that the language supports implicit typing and that the type is associated with the value and not the variable. As such, specific enumeration of the type (e.g. integer, string, object, array, etc.) is not required and determined at runtime. This form of typing is present in various other scripting languages including Ruby, Python, Lua, a nd PHP and has various widely debated benefits and downfalls. It is left to the reader to further investigate those benefits and downfalls, if so desired, but for our purposes just know that JavaScript is a dynamic, weakly typed language.

A variable in the global namespace means that any code segment, anywhere in the execution environment can change the value of the variable without you knowing it. Use of the global namespace, while not at all prohibited should be avoided as much as possible because it introduces a large amount of non-deterministic confusion to your code that would otherwise seem to be impossible, especially since it looks similar to other languages. The relationship of variables to their scope is one of the most mystifying and complex elements of JavaScript so it is highly important to get it right at this early stage. Look at this example for a "bad scope" that is not only allowable but an unfortunately all too often occurrence in JavaScript code:

In this code we introduce the print() function which takes any value and attempts to output to the console. If you are testing this in a browser, be sure to use console.log() for the same effect, print() in the browser will print to a printer. The first line attempts to print the global variable empty, which at the time is undefined, hence the error message. The next line looks foreboding, but all it is really doing is creating a function that sets a variable empty to the value of 4 and executes it immediately. The final line runs the exact same code as the first line, but the value has been updated to 4 so it now prints the value of 4. If you are coming from nearly any other language your expectation is that the curly brackets begin and end the lifetime of any variables defined within it, which is known as Block Scoping. Unfortunately, pure JavaScript does not provide for block scoping, hence the reason why the variable empty is set even though it is inside a function. This is because without the var keyword, it will assign it in the highest scope that it either finds an existing variable with the provided name OR the aforementioned global namespace. To see the difference, adding the var keyword to the previous example yields the following expected output:


NAKEDNOTE: JavaScript 1.7 and the let keyword

The JavaScript 1.7 specification, as implemented in the current versions of SpiderMonkey and TraceMonkey, provides a new keyword of let() that provides for more familiar block scoping of a variable. We will investigate the newest version of JavaScript later in this series, but if you want to learn more about the let keyword be sure to review the Mozilla Developer Center regarding what is New in JavaScript 1.7.


 

Loading mentions Retweet

Comments [0]

Installing v8 on Mac OS X and Linux

Google's v8 JavaScript Interpreter made a huge splash and to many was the indication of the browser war of the modern era. The effects of Google's entrance into the browser world are not yet fully known and expands with nearly every action by Google. V8 is written in C++ and is the fundamental differentiator of Google Chrome from Apple's Safari web browser. When v8 came out it nearly doubled the speed of the competition, all of which have returned to the neck and neck speed levels. Google has made a strong bet on JavaScript as a fundamental factor for the future of not only the web, but their company as a whole with the announcement of a "Web OS" in Google Chrome OS. In terms of disruptive technologies that have long reaching ramifications, there is a general consensus within the JavaScript community that v8 is a prime leader for both client side AND server side JavaScript.

Installing v8 is relatively trivial thanks to its main dependency, the SCons build system. SCons is a build system built in Python and designed around more modern programming systems. Its a great improvement over previous build systems like make, but we are not going to get crafty about the install of SCons at this point because we have already relied on the available package managers for each system. You will also need Subversion installed in order to checkout the latest version of v8. If you already have installed Subversion prior to this article, then just exclude "subversion" from the following command.

To install SCons and Subversion on Mac OS X, issue the following command:

sudo port install scons subversion

To install SCons and Subversion on Linux, issue the following command:

sudo apt-get install zip scons subversion

Note: If you are running Linux in a x64 environment, you will have to ensure that you install the multilib packages using the following command, which if you want you can append the packages to the end of the previous command:

sudo apt-get install g++-multilib gcc-multilib

If you are asked about dependencies during this install process, you can positively accept them as they will be necessary for full functionality. 

Once you have all of the necessary dependencies installed, be sure you are in the "javascript" directory we created in the Getting Started process. Issue the following commands while in that directory in order to download and build the v8 engine (vroom, vroom), these commands work regardless of your operating system,

Notice the sample=shell, this is what tells the SCons build system to configure and compile V8 with an executable shell or Read-Eval-Print-Loop (REPL) script so that we can play with as easily as we have the other JavaScript engines. This process will take a fairly long time, as you have most likely come to expect in building the previous JavaScript interpreters. Once it is complete, you will have a new file located in that directory called shell that is by default executable. Since "shell" is not very specific to what we are doing I recommend that you symbolically link this file into a path accessible directory. If you have /usr/local/bin available in your path it is a simple as the executing the following command in the terminal:

sudo ln -s ~/javascript/v8/shell /usr/local/bin/v8

This will create a symbolic link of v8 to the shell command so that you will only need to type "v8" in the terminal and it will begin execution. This works quite well especially when you update the code, which can be done in the following way:

Now we have the last of our JavaScript interpreters installed and ready, we can now being to learn the ways of Naked JavaScript.

Loading mentions Retweet

Comments [4]

Installing TraceMonkey on Mac OS X and Linux

TraceMonkey is the massively improved JavaScript engine in Firefox 3.5 which employs a trace based compiler to provide blindingly fast JavaScript interpretation. The trace tree code base, named NanoJIT, evolved from a paper published by the Computer Science department of the University of California, Irvine entitled "Making the Compilation 'Pipeline' Explicit: Dynamic Compilation Using Trace Tree Serialization". NanoJIT is a C++ based library from Mozilla that is used in both the Tamarin and TraceMonkey projects that provides a low level abstraction for "near-metal", native compilation of code segments that repetitively occur. Despite all this "geekery", what you need to know is that NanoJIT was a massive improvement to SpiderMonkey that allowed Mozilla to yield high performance JavaScript from their existing libraries.

To begin, you will need Mercurial installed in order to pull down the latest source tree from Mozilla. Mercurial is a source control management system that is designed to efficiently and effectively handle large distributed projects. Luckily installing Mercurial is relatively painless for both target platforms. You will also need autoconf version 2.13. It has to be autoconf version 2.13 otherwise things will go awry; trust me, just use autoconf 2.13. This is not always the default autoconf on either Mac OS X or Linux, but is available for both Mac OS X and Linux by way of package managers, just like Mercurial. We will install both at the same time. 

To install Mercurial on Mac OS X, use MacPorts with the following command:

 sudo port install mercurial autoconf213 

To install Mercurial on Debian/Ubuntu Linux, use apt-get with the following command:

 sudo apt-get install zip mercurial autoconf2.13 

This will install a variety of dependencies mainly all for Mercurial so its better just to let a proper package manager handle all of the complexities for you. If you prefer, there are also pre-built binaries for Mercurial available here and if you really want to install it from source, I recommend reviewing the documents provided on the Mercurial site.

To obtain the source code for TraceMonkey, first make sure you are in the "javascript" directory we created in the Getting Started process. We will be cloning the TraceMonkey repository locally so that we can compile it. This will also allow us to maintain an up-to-date copy by issuing the following command without the quotes, from within the tracemonkey directory we will be creating next.

 hg pull && hg update 

But before we do that, we need to actually get the source code. If you are on Mac OS X, enter the following commands from within the aforementioned "javascript" directory, without the quotes.

 

 If you are on Linux, enter the following commands from within the aforementioned "javascript" directory, without the quotes.

 

This may will take a fair bit of time, especially the clone process of Mercurial, so I recommend entering the commands and then grabbing an adult beverage, I find that helps the process a lot more than coffee. This will configure and build ONLY the JavaScript stack of TraceMonkey, but unfortunately you have to download the entire code base which includes a lot of unnecessary things. Once this process completes, there will be a fresh binary named js in the js/src directory, when you execute it you will notice that it is a world faster than the previously installed Rhino shell both in terms of shell loading and code execution. This why TraceMonkey and its predecessor, SpiderMonkey, have been the default JavaScript interpreter engine for Firefox, it is just incredibly fast in almost every way over Rhino. The only way that Rhino bests the *-Monkey suite is that through Rhino you access the entire JVM stack and all of its libraries. It is up to the reader to determine the value and virtue of each interpreter and use them based on the requirements and needs of the task.

When you execute the standard 

./js

it will run the standard JavaScript shell and in this sense TraceMonkey is only the extension and improvement of the SpiderMonkey interpreter. For the aforementioned NanoJIT functionality to be loaded and used, you must start the shell with the '-j', without quotes. You can verify this with a simple test of running the following line of code:

for(i=0;i<10000;i++) { print(i); }

When you run it without the '-j' option that code will execute the same every time, with the '-j' option it will compile the process to native code and run the native code, so you will notice an incredible speedboost almost magically as you are running through the process. You now have one of the three fastest JavaScript interpreters available, we will install the other two next.

Loading mentions Retweet

Comments [7]

Installing Rhino on Mac OS X or Linux

Rhino from Mozilla is entirely written in Java, which has made it an ideal platform for JavaScript development of many server and client side applications. By being built in Java, Rhino actually has access to every built-in function and library within the Java ecosystem. This is a huge benefit especially for people that are familiar with Java development or are looking to integrate JavaScript into an existing project. In contrast to the other engines we will be installing, installing and using Rhino is relativlely trivial.

To begin, you will need the Java SDK installed. For Mac OS X this is installed by default, but for versions of Linux this may not be the case. If you are running Linux, issue the following command to ensure that you have a proper installation of the Java runtime.


which java


If this returns nothing, it will mean that you have to install Java on your Linux computer. For Debian/Ubuntu versions of Linux you simply need to enter the following command:


sudo apt-get install sun-java6-bin sun-java6-jre


For directions on how to accomplish this with other versions of Linux, review this wikihow article.

Once you have verified and, if necessary, installed Java, you are ready to being the process of obtaining Rhino. While in the aforementioned "javascript" directory issue the following commands to obtain and unpack the Rhino package.

At this point, you have everything you need to execute a working, DOM-less JavaScript  environment. While you are in the "rhino1_7R2" directory, enter the following command into the terminal in order to start your first JavaScript REPL (Read-Eval-Print-Loop) shell:


java -jar js.jar


You should see a prompt that is similar to the below

Rhino 1.7 release 2 2009 03 22
js>

At this point you have a working and fully functional JavaScript shell, to verify this you can do the proverbial verification test:


print("Hello New World");


Which will of course output "Hello New World" and provide you with a new prompt "js>" and with little effort you have installed your first JavaScrpt engine and executed your first bit of Naked JavaScript.

 

NOTE: To quit the shell, simply type


quit()


if you type just "quit" without the parenthesis, you will be returning the function to the printer instead of executing the function. It will look something like this:

function quit() {     [native code, arity=1] }

This is actually the first peek into the functional programming side of JavaScript. As you can see it is the actual function definition, which uses native code to stop the executing shell. If this was a user-space function, you would actually see the full function definition, but more on these sorts of things later.

Loading mentions Retweet

Comments [3]

Getting Started

Before beginning, we should make sure that we are all here for the right reasons. JavaScript is commonly only thought of as a scripting language confined the browser space and riddled with "landmines". Both statements, as we shall see throughout this series, are completely false descriptions of the language and its the intention of these posts to change your view. So that is our goal, to learn the wonders, beauty, and a little bit of magic that you can accomplish with a language that you will use or at least could be using in nearly every project with little effort. 

I could go on to laud about how elegant and beautiful JavaScript is, but that really doesn't help anyone. At this point I am going to assume you have some degree of interest in the language and have been exposed to at least one other programming language. A final "clarification", in order to expedite these posts to you, I am going to limit the operating system environment to Mac OS X and Linux. If you are a reader using a Windows machine, all of the examples after installation should work perfectly. Please leave a comment with any notes on how to accomplish the same installation results in Windows if there are any differences and we will add them as part of procedures.

Without further ado, lets get JavaScripting.

Getting JavaScript

Unlike other programming texts you might be familiar with, the "configuration step" before we get to "Hello World" is going to be rather long. The length of this post is mainly because we are going to set up the full spectrum of JavaScript interpreters. For the first examples we will be going through, you will not need all of the JavaScript interpreters, so if you want to "Quick Start", just follow the instructions for Rhino. We will be using all of these interpreters as part of the series, mainly because the projects that use them take advantage of specific features each offers. I recommend pulling down all of them and playing around with each, it will be quite exciting. Each post will begin with an identifier of which JavaScript engine can be used for that particular example as well as a link to install that engine, so if you want you can install the engine only when needed.

The following are the interpreters we will be installing and using as part of this series:

  • Rhino - A Java based JavaScript engine from Mozilla this is probably the most widely deployed and used non-browser JavaScript interpreter available. As such it is also the easiest to begin playing with Naked JavaScript in and the most robust base implementation. That said, the newer implementations mentioned below are pushing the envelope in terms of what JavaScript can do. They provide new features (Web Workers, etc.) that Rhino has yet to implement. If you are looking for the quickest, most risk-free start, Rhino is your best bet.
  • SpiderMonkey - A C based JavaScript engine from Mozilla. This interpreter is the main JavaScript engine that has been used in Mozilla products, including Firefox, up until version 3.5 which will include a revised interpreter named TraceMonkey.
  • TraceMonkey - A massive extension of SpiderMonkey that leverages the power of Trace Trees for Just In Time (JIT) native code compilation process which in turn drastically improves performance on the order of 3 to 30 times. TraceMonkey includes various improvements to the overall processing and handling of JavaScript as well as integrating the newest features including better garbage collection and various integrations from the Tamarin project, an open source ActionScript Virtual Machine built as a collaboration between Mozilla and Adobe.
  • V8 - A C++ based JavaScript engine built by Google as part of the Google Chrome web browser. Google's team openly focuses on making V8 a high performance engine by applying deep virtual machine technology to the entire workflow of JavaScript interpretation and processing. Google developed V8 for a variety of reasons, but mainly because of a firm belief that high performance JavaScript engines are critical for future innovations
  • SquirrelFish Extreme - Also known as JavaScriptCore, WebKit's JavaScript engine which was one of the first "performance" contender's to Mozilla's general dominance. Apple uses WebKit and JavaScriptCore to produce Safari, their lightning fast web browser for both desktop and mobile web browsing. Mobile Safari for the iPhone brought full featured mobile web browsing to the general public and was the first time that a vender recommended the creation of pure HTML, CSS, and JavaScript for application development. Palm went a step further with WebKit as part of building the Palm Pre by using HTML, CSS, and JavaScript throughout the entire Operating System stack and their Mojo SDK.

There are other JavaScript engines out there, but for the sake of discussions in this series, these will be the main engines that we use. The next several posts will help you with install each engine. It is recommended that in order to keep them all straight you create a directory named "javascript", without the quotes. While you can put this directory anywhere, the examples will assume the directory is off of your home directory. To create this directory enter the following commands:

  mkdir ~/javascript && cd ~/javascript 

And you are off to installing.

Loading mentions Retweet
Filed under  //   javascript   js   quickstart   rhino   squirrelfishextreme   tamarin   tracemonkey   v8   webkit  

Comments [3]

Preface

JavaScript is a multi-paradigm, prototype-based, functional scripting language or in short it is one of the most advanced languages that nearly every one knows, but very few know deeply. It combines the elegance of functional programming with the ease and rapid development capabilities of scripting languages. While it is most commonly thought of as a client side scripting language confined to the browser environment, JavaScript has far more to offer the world than just being the widest deployed language in the computer world. In the traditional model of JavaScript, the Document Object Model or DOM is often the focal scope or reason for working with the language in order to update elements within a web browser. This series is not going to deal with the DOM at all - I recommend reading JavaScript: The Good Parts by Douglas Crockford and JavaScript: The Definitive Guide by David Flanagan if you are interested in the DOM, well actually just read those books regardless. This series will introduce to some of the deep concepts touched on by those authors as well as introduce you to some of the most exciting and cutting edge concepts in JavaScript. We will go through how to install JavaScript and use it outside the browser, but you can also follow along directly in your browser if so inclined. This series is being done in blog posts in order to keep up with the rapidly changing world of JavaScript. 

Why Should I Learn JavaScript as a Language?

Consider that nearly every computer since the mid 1990s has come equipped with a some form of a JavaScript interpreter and that since that time period nearly every major technology vendor has heavily funded the further development of the language, both in terms of speed and functionality. That fact catches most people off-guard, because JavaScript is often thought of by developers as a necessary evil and by some as just plain evil. This misconception has evolved over the years from being burned by the wide variety of implementations, each with their own oddities, issues, and functionalities; much of which has been resolved, fixed, or handled for the developer by frameworks, libraries, or improvements in the interpreter. The JavaScript community has progressed towards a set of standard APIs and language definitions, most of which conforming to the ECMAScript ECMA-262, Edition 3 standard. At this point, the world of JavaScript is not only stable, it is also extending well beyond the browser and into the desktop, mobile, and server environments, each of which is stabilizing on appropriate APIs and domain specific definitions.

The best part about all of these advancements is that you most likely know enough JavaScript to start programming for all of these environments right now. JavaScript is one of the more approachable languages for both developers and non-developers alike and that is one of its strong suits. The language has evolved over many years; sometimes for the better, sometimes less so; hopefully we will journey through the JavaScript language with ease and grace while learning many amazing things that will hopefully positively re-enforce or change your view of this advanced language.

By working through the concepts and examples in this series, you will learn a wide variety of techniques and programming practices for JavaScript, may of which will be applicable in other programming languages. Even if you never use JavaScript outside the browser, the concepts that you will be exposed to as part of this series will help you with in-browser JavaScript programming. If you do any programming for the web, you are most likely going to be using JavaScript somewhere, somehow.

Why Naked?

JavaScript without the DOM is a beautiful thing. This has been said by some of the most influential JavaScript developers, but has until now been kept as a deep secret. With the increased interest around JavaScript technologies fueled by products from Adobe, Apache, Apple, Google, Microsoft, Mozilla, and Palm that do everything from browser scripting to full mobile OS development to server and database programming; there is a strong trending toward this language as more than just a browser scripting language. By learning JavaScript stripped of its DOM clothing, you can easily get to the best and most overlooked parts of the language. Also the world outside the browser is rapidly expanding and growing, which makes it rather hard to keep tabs on all the newest and most exciting updates while trying to code in-browser JavaScript (or other languages).

A Note

This series may not always "flow" from one idea to a similar idea and that is on purpose since new technologies, products, or concepts come to light in the JavaScript world all the time. We may have guest writers that can dive deep about new concepts or provide preview details about technologies, or just bounce around from technology to technology - either way it will be a fun ride. 

Enjoy

Loading mentions Retweet
Filed under  //   javascript   js  

Comments [0]