Processing.js for Processing Devs: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
(Created page with "= Processing.js Quick Start - Processing Developer Edition = ==Introduction== This quick start guide is written from the standpoint of a Processing developer. No HTML or JavaS...")
 
Line 7: Line 7:
==Why Processing.js?==
==Why Processing.js?==


The Processing language was created at much the same time that the web was starting.  At this time the choice of the Java language, and Java Runtime, as implementation targets for Processing made a lot of sense.  In the mid-1990s, Java was poised to become the language of the web, with Applets and other Java technologies being used broadly on the client-side.  Even Netscape, who created the language which would eventually become the lingua franca of the web with JavaScript, named their language so as to align themselves with the growing hype around Java.
===The Web: from Java to JavaScript===


In the end, Java became an important server side technology, receding from the client-side and browserToday, most web browsers still support Java Applets, by means of a binary pluginHowever, few web developers deploy Java-based web apps now, due to load times and difficulties relying on Java (or compatible Java versions) being installedThis trend is not isolated to Java, but is happening to all browser plugins (e.g., Flash), which are becoming less popular as issues of security, installation, deployment, etc. make them inconvenient or risky.
Processing is built using Java.  It was created at much the same time that the web was startingAt this time the choice of the Java language, and Java Runtime, as implementation targets for Processing made a lot of senseIn the mid-1990s, Java was poised to become the language of the web, with Applets and other Java technologies being used broadly on the client-sideEven Netscape, who created the language which would eventually become the ''lingua franca'' of the web with JavaScript, named their language so as to align themselves with the growing hype around Java.


Another reason that plugins like Java and Flash have fallen out of favour is that recent advances in standard web technologies, specifically HTML5 and JavaScript, have made it possible to do things that previously depended on native (i.e., faster) code.  Companies like Google, with GMail and Google Docs, or Scribd (see http://www.scribd.com/doc/30964170/Scribd-in-HTML5) have shown that HTML, CSS, and JavaScript are enough to build fast, full featured web applications.
In the end, Java became an important server side technology, receding from the client-side and browser.  Today, most web browsers still support Java Applets, by means of a binary plugin.  However, few web developers deploy Java-based web applications now, due to long load and startup times and difficulties relying on Java (or compatible Java versions) being installed.  This trend is not isolated to Java, but is happening to all browser plugins (e.g., Flash), which are becoming less popular as issues of security, installation, deployment, etc. make them inconvenient or risky.
 
Another reason that plugins like Java and Flash have fallen out of favour is that recent advances in standard web technologies, specifically HTML5 and JavaScript, have made it possible to do things that previously depended on native (i.e., faster, compiled) code.  Companies like Google, with GMail and Google Docs, or Scribd (see http://www.scribd.com/doc/30964170/Scribd-in-HTML5) have shown that HTML, CSS, and JavaScript alone are enough to build fast, full featured web applications.
 
===Processing.js uses Modern Web Standards===
 
Processing.js is built using JavaScript and HTML5.  Processing.js is really two things: a Processing-to-JavaScript translator; and an implementation of the Processing API (e.g., functions like line(), stroke(), etc.) written in JavaScript instead of Java.  It might seem odd at first to imagine your Processing sketches running in a browser, usually without modification.  But this is exactly what Processing.js enables.
 
Processing.js automatically converts your Processing code to JavaScript.  This means that you don't have to learn JavaScript in order to run your code in a browser.  You can, quite literally, write your code using the Processing IDE like you always have, and follow the steps below to get it running on the web.  There's nothing new to learn, beyond getting a simple web page created.
 
Under the hood, Processing.js uses the new HTML5 canvas element to create your sketch's graphics.  The canvas element is a new feature of the web, and is either implemented or will be implemented by all major web browsers.  All Processing drawing features have been reimplemented in Processing.js to use canvas, so any browser that supports canvas will also support Processing.js.
 
Here's a sample of a Processing.js sketch running in the browser.  If you can see it working, your browser supports everything you need already, and you can move on to instructions below.
 
'''Create simple sketch here'''

Revision as of 17:46, 13 September 2010

Processing.js Quick Start - Processing Developer Edition

Introduction

This quick start guide is written from the standpoint of a Processing developer. No HTML or JavaScript knowledge is assumed, and only basic Processing knowledge is necessary.

Why Processing.js?

The Web: from Java to JavaScript

Processing is built using Java. It was created at much the same time that the web was starting. At this time the choice of the Java language, and Java Runtime, as implementation targets for Processing made a lot of sense. In the mid-1990s, Java was poised to become the language of the web, with Applets and other Java technologies being used broadly on the client-side. Even Netscape, who created the language which would eventually become the lingua franca of the web with JavaScript, named their language so as to align themselves with the growing hype around Java.

In the end, Java became an important server side technology, receding from the client-side and browser. Today, most web browsers still support Java Applets, by means of a binary plugin. However, few web developers deploy Java-based web applications now, due to long load and startup times and difficulties relying on Java (or compatible Java versions) being installed. This trend is not isolated to Java, but is happening to all browser plugins (e.g., Flash), which are becoming less popular as issues of security, installation, deployment, etc. make them inconvenient or risky.

Another reason that plugins like Java and Flash have fallen out of favour is that recent advances in standard web technologies, specifically HTML5 and JavaScript, have made it possible to do things that previously depended on native (i.e., faster, compiled) code. Companies like Google, with GMail and Google Docs, or Scribd (see http://www.scribd.com/doc/30964170/Scribd-in-HTML5) have shown that HTML, CSS, and JavaScript alone are enough to build fast, full featured web applications.

Processing.js uses Modern Web Standards

Processing.js is built using JavaScript and HTML5. Processing.js is really two things: a Processing-to-JavaScript translator; and an implementation of the Processing API (e.g., functions like line(), stroke(), etc.) written in JavaScript instead of Java. It might seem odd at first to imagine your Processing sketches running in a browser, usually without modification. But this is exactly what Processing.js enables.

Processing.js automatically converts your Processing code to JavaScript. This means that you don't have to learn JavaScript in order to run your code in a browser. You can, quite literally, write your code using the Processing IDE like you always have, and follow the steps below to get it running on the web. There's nothing new to learn, beyond getting a simple web page created.

Under the hood, Processing.js uses the new HTML5 canvas element to create your sketch's graphics. The canvas element is a new feature of the web, and is either implemented or will be implemented by all major web browsers. All Processing drawing features have been reimplemented in Processing.js to use canvas, so any browser that supports canvas will also support Processing.js.

Here's a sample of a Processing.js sketch running in the browser. If you can see it working, your browser supports everything you need already, and you can move on to instructions below.

Create simple sketch here