<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Gerrit&#039;s work in progress &#187; javascript</title>
	<atom:link href="http://blog.wessendorf.org/tag/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.wessendorf.org</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Thu, 09 Jun 2011 01:57:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Reminiscing About Javascript</title>
		<link>http://blog.wessendorf.org/2008/06/reminiscing-about-javascript/</link>
		<comments>http://blog.wessendorf.org/2008/06/reminiscing-about-javascript/#comments</comments>
		<pubDate>Wed, 11 Jun 2008 16:14:58 +0000</pubDate>
		<dc:creator>gerrit</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[thoughts]]></category>
		<category><![CDATA[games]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://blog.wessendorf.org/?p=256</guid>
		<description><![CDATA[Oh, Javascript has really come a long way&#8230; When I first started playing with Javascript in the 90s I used it almost exclusively for onMouseOver and onMouseOut events for a clickable pseudo-3d button or image on my first webpages. I also used Javascript with image-maps, onClick events, or to validate input before a form was [...]]]></description>
			<content:encoded><![CDATA[<p>Oh, Javascript has really come a long way&#8230;</p>
<p><span class="drop w">W</span>hen I first started playing with Javascript in the 90s I used it almost exclusively for onMouseOver and onMouseOut events for a clickable pseudo-3d button or image on my first webpages. I also used Javascript with image-maps, onClick events, or to validate input before a form was submitted. But that was about it. In the end I had a small collection of functions, but most of the time, the Javascript code was really just embedded inside the HTML markup, far from any structure or being readable or reusable.</p>
<p>Eventually I began to use Javascript for more extensive tasks. The inline Javascript disappeared and instead of replacing images I now worked with stylesheets and the document object model. I also organized Javascript code in dedicated Javascript files and attempted to make the code as reusable as possible. Some examples included a tree-menu that was populated with values from a database. That was actually before Ajax became a buzz-word and common practice. I had to use several tricks to transport data. On the server side I created a function that initialized a few data exchange variables&#8230;somewhat resembling <a href="http://www.json.org/">JSON</a>. With other tricks I managed to load more data dynamically, just in time, as you expanded the tree-menu. At that time it was quite an undertaking because Internet Explorer and Netscape/Mozilla had much more issues with each other than today. Although Internet Explorer still doesn&#8217;t behave as it should, web development has become much easier nowadays.<br />
<span id="more-256"></span><br />
Impressed by what could be done with Javascript I once wrote a client-/server chess-game in I think late 1999, using Javascript, PHP and HTML. The Javascript functions would validate a move before it was sent to the server. The exchange of moves as well as (semi-)instant messages between the two players were handled by an invisible frame that was refreshed automatically in a certain interval. This chess program was nothing but a challenge to see if I could do that with nothing but Javascript, PHP and HTML. It all worked well and looked nice, but it really still was nothing but a bunch of Javascript functions.</p>
<p>In the beginning of the new millenium I found that you could actually create much more complex applications with Javascript. By sticking to some conventions and using the concept of <a href="http://en.wikipedia.org/wiki/Prototype-based_programming" target="_blank">prototypes</a> you were able to use Javascript almost like other object-oriented languages. Instead of collecting a bunch of functions that would float around in a text file, you could organize and use them as real objects with real properties and methods. When I discovered this I couldn&#8217;t believe that I never used Javascript that way before.</p>
<p>I immediately had that vision to create a framework of reusable components and plugins that follow the same conventions on both the server-side with PHP (at that time it was still PHP4) and the client-side with Javascript. That was the my era of making Javascript go &#8220;Enterprise&#8221; :) The support of Javascript in IE vs Mozilla was not so much an issue anymore, and I could make the code work on both platforms without tearing my hair out. Not only could I create a neat software architecture in Javascript, but also take advantage of all the events available including key-strokes without getting a problem with code becoming impossible to read or maintain.</p>
<p>I worked many months&#8211;in fact closer to two years&#8211;on this idea and framework, but I wasn&#8217;t the only one. Other companies were faster and published a series of new technologies that were much better and more powerful than my silly unfinished solution. A good part of my own code became somewhat obsolete after learning about <a href="http://www.json.org/" target="_blank">JSON</a> and libraries like <a href="http://www.prototypejs.org/" target="_blank">Prototype</a> and <a href="http://script.aculo.us/" target="_blank">Script.aculo.us</a>. With the new PHP5 release many of my semi-object-oriented workarounds became obsolete. There also was Microsoft who brought their .Net platform onto the market. And Google who began to offer rich and excellent web-applications like Gmail or Google Maps, and released packages like the <a href="http://code.google.com/webtoolkit/" target="_blank">Google Web Toolkit</a> for developers. I figured it wouldn&#8217;t make sense to continue to work with an idea that soon would become completely obsolete with the new wave of technologies. So I dropped the idea of the Javascript/PHP &#8220;Enterprise&#8221; framework and worked on some smaller Javascript files to explore the power of Javascript as a &#8220;real&#8221; programming language instead.</p>
<p>I tried to take some of the old game and demo source codes in C and C++ and rewrite them in Javascript. I thought it would be fun to have some nice animations in two or three dimensions. By adding some interaction there was the potential to create some nice Javascript based games. I moved forward well, but the output became a problem. I tried to simulate a virtual &#8220;Javascript-screen&#8221; and render pixels found in a Javascript screen buffer, but it was way, way too slow. It worked for a static image, but you couldn&#8217;t use that for animations at all. Eventually I gave up and focused on Ajax and Java instead&#8230; and then I had to put more time into paid graphic design jobs than programming, which I always found much more interesting and fun, but didn&#8217;t pay the bills.</p>
<p>A few months ago I discovered how Lee Semel solved the display problem with his version of the old first-person shooter <a href="http://www.wolf5k.com/" target="_blank">Wolfenstein</a> in Javascript. Size: only 5K! As a &#8220;display&#8221; he creates <a href="http://en.wikipedia.org/wiki/XBM" target="_blank">XBM images</a>, a monochrome image format that unlike other binary image formats is actually a C-style ASCII text format that can dynamically created with Javascript. I found this solution very impressive, and especially its small size. Unfortunately, this format is not supported by IE or Windows anymore.</p>
<p>But wait, it gets even better. Just recently I discovered <a href="http://blog.nihilogic.dk/" target="_blank">Nihilogic</a>, a blog with a focus on Javascript. There you can find Javascript versions of <a href="http://blog.nihilogic.dk/2008/05/javascript-super-mario-kart.html" target="_blank">Super Mario Kart</a> (11K), <a href="http://blog.nihilogic.dk/2008/04/javascript-wolfenstein-3d.html" target="_blank">Wolfenstein 3D</a>, <a href="http://blog.nihilogic.dk/2008/04/3d-javascript-chess-wip.html" target="_blank">3D Chess</a>, <a href="http://blog.nihilogic.dk/2008/04/super-mario-in-14kb-javascript.html" target="_blank">Super Mario</a> (14k) in color! He has a <a href="http://blog.nihilogic.dk/2008/03/canvas-3d-renderer.html" target="_blank">3D-renderer</a>, a <a href="http://blog.nihilogic.dk/2008/04/3d-javascript-particle-generator.html" target="_blank">3D Particle Generator</a> or tools to <a href="http://blog.nihilogic.dk/2008/03/jsimagefx-javascript-image-effects.html" target="_blank">manipulate images</a> in Javascript. This is just amazing, far beyond anything I dreamed of in my Javascript days.</p>
<p>Instead of XBM images he uses the <em>canvas</em> element that is part of HTML5 and supported by both Opera and Mozilla. Not surprisingly, IE doesn&#8217;t support canvas (it doesn&#8217;t even support SVG), but there are solutions like <a href="http://sourceforge.net/projects/excanvas/" target="_blank">ExplorerCanvas</a> to bring the same functionality to IE.</p>
<p>I&#8217;m truly impressed by what can be done with a scripting language that essentially started as a simple onMouseOver event. I think I should take some time and play with the possibilities of the new canvas element. Of course SVG and Flash/ActionScript, and Java are good and valid candidates for user interfaces still&#8230; but Javascript presents a fun challenge, and it doesn&#8217;t require any large frameworks or third party plugins. </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.wessendorf.org/2008/06/reminiscing-about-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

