10.7. JavaScript and Dashboard

Netscape originally created JavaScript as a scripting language to make dynamic content for the Web. JavaScript code is usually found embedded in HTML and gets run in a web browser. By giving you access to all the elements of an HTML page via the so-called document object model (DOM), JavaScript allows you to take static HTML web content and change it as time passes.

JavaScript looks quite a bit like the Java programming language, but that is where the comparison ends. JavaScript is not Java, nor is it a subset of Java. JavaScript is a simple interpreted language that runs in web browsers, and Java is an extensive compiled language that can be used for a wide variety of different purposes—from developing websites to creating desktop applications.

Java is a compiled language, but it is a compiled language with a difference. The Java compiler converts Java source code into something called byte code, rather than the machine code that runs on the CPU. The byte code is platform independent; when you run a Java application, a program called the Java virtual machine (JVM) reads the byte code and generates machine executable code, which is what is sent to the CPU. In short, the JVM is a bit like an interpreter. As you can see, the distinction between a compiled language and an interpreted language is not that clear when it comes to Java.

10.7.1. Dashboard

Quite aside from its important place in web development, JavaScript has an added attraction for Mac ...

Get Beginning Mac OS® X Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.