The Null Device

Posts matching tags 'javascript'

2013/10/18

Toy of the day: PuzzleScript is an online (browser-based) game development environment capable of making a wide variety of turn-based puzzle games, ranging from Sokoban (of which the Hello World-esque example one starts with is a variant) to more sophisticated and/or eccentric games.

Games are written in a functional/declarative notation, consisting of rules; for example, the Sokoban rule allowing the player to push a crate is written as:

[ > Player | Crate ] -> [ > Player | > Crate ]

Graphics are deliberately kept simple, with elements being 5x5 blocks of coloured pixels, giving the game a vaguely Atari 2600-esque aesthetic.

There is a gallery of games made by users, each with an animated GIF representing the game's play. Some examples:

Games were originally turn-based (in that nothing happened except when the player moved), but there is an experimental real-time feature. Somebody has already coded a (semi-functional and not particularly exciting) Pac-Man clone.

The latest in the ever-onward march of awesome: Scripted Amiga Emulator, which emulates a classic Amiga (of configurable specifications, though including video and audio hardware) entirely in JavaScript. Unlike the various JavaScript PC and Linux emulators, emulating the Amiga's various coprocessors probably will cause your machine to break a sweat. Running Turrican 2 on it was slow, and had the interestingly hauntological aesthetic effect of the music speeding up and slowing down, like on those battery-operated chip-tune Walkmans that everyone had in the 19A0s.

Today in Extreme JavaScript:
An original IBM PC, simulated in the browser. It has a CGA adapter and two simulated floppy drives, into which one can load a number of pre-supplied images, including several versions of MS-DOS PC-DOS, as well as VisiCalc and Microsoft Adventure. Not only that, but, if left to its own devices, it will run an order of magnitude faster than an original IBM-PC.

Anyway, the simulation is fully functional on all modern browsers (that I've tested). It's booting the original IBM PC Model 5150 ROM BIOS (no modifications), and it's loading the original MDA/CGA fonts. This configuration gives you more control, allowing you to toggle any of the SW1/SW2 settings to change the memory configuration, the installed video card (MDA or CGA), and the number of diskette drives. There's also a built-in debugger with lots of DEBUG-like commands, only better. And you can create your own configuration by tweaking the underlying XML file. I'll eventually do a write-up explaining how to embed it on your own web page and what options are available. The process is very similar to embedding the C1Pjs simulation that I wrote earlier this year--the XML is just a little different.

The author, a chap named @jeffpar, is now looking to add more features to his emulator, bumping up the display to EGA graphics, upgrading the CPU to a 286 and adding a serial mouse.

This is not the first PC emulator to be written in JavaScript; some two years ago, a chap named Fabrice Bellard wrote a JavaScript-based PC emulator capable of booting Linux on a JavaScript-emulated Pentium box. Bellard's emulator, though more powerful than a 1981 IBM PC, was purely text-based.

Also on doing cool things with JavaScript: Stuart Memo (who was in the 1990s Glaswegian punk/electropop band Bis) is now writing music tools in JavaScript, using the Web Audio API. He has a few demos here, and recently gave a talk at JSConf in Berlin titled JavaScript is the new Punk Rock, where he envisioned an open browser-based music-making platform.

BBC Four recently aired a fascinating documentary titled The Joy Of Easy Listening, charting the history of easy-listening/light music from the 1950s onward. It's viewable on YouTube here.

Digital artist Joshua Nimoy worked on some of the visuals for Disney's Tron Legacy film, and describes how they were done, from the physics of fireworks simulations and the algorithms behind various clusters of digital-looking lines to authentic-looking UNIX command-line shots for a hacking scene. (The fact that we've gone from "UPLOAD VIRUS Y/N" screens and random equations/6502 machine code/cyber-Japanese glyphs to nmap(1) being seen as too much of a hacking-scene cliché suggests that computer literacy in the movie-viewing public has increased dramatically over the past few years.)

The age of vector graphics on the web is drawing closer; Raphaël is a JavaScript library which gives you a portable way of drawing vector graphics, not only on all modern browsers but, amazingly enough, on Internet Explorer from version 6 upwards. (It uses SVG on modern browsers and VML on Microsoft's ones.) Anyway, Raphaël code looks like:

It also handles images, text, and paths (using the SVG path notation). And here is a set of free icons, all implemented as path strings for use in Raphaël; they look fairly neat and modern, though, being single path objects, are monochrome. Being paths, though, they scale seamlessly.

So how soon can you use this in your web sites? Well, it runs with most of the web browsers in use these days, though needs a 55Kb (20Kb gzipped) JavaScript file. You'll probably need to host this file yourself, neither Google nor Yahoo! seem to have added it to their public CDN systems yet (though perhaps it's only a matter of time).

Apple have just released the specifications for the iTunes LP format, a way of encoding extra content to wrap around music albums, and it looks very elegant. As mentioned before, an iTunes LP is a directory containing the original media and graphic files, as well as XML metadata, HTML/CSS for presentation, and code in JavaScript for the navigation. The JavaScript code uses a framework named TuneKit, which, in characteristic Apple fashion, is elegantly Model-View-Controller; rather than littering DOM objects with event handlers, an author defines controller classes which deal with the relevant events.

Apple say that they will start accepting automated submissions of iTunes LP content to the iTunes Store in the first quarter of 2010. Of course, as the format is open, there is nothing preventing people from rolling their own and selling them from other sites.

I wonder how long until there are open-source iTunes LP players for platforms such as Linux.

This is pretty awesome: a browser-based SNES NES emulator written entirely in JavaScript. Let me repeat that: someone wrote code in JavaScript (not in Flash or Java or anything faster) for emulating a Super Nintendo almost in its entirety*, from the 6502 CPU to the graphics and I/O hardware, and got away with it (it gets a respectable 33 frames per second in Chromium, though crawls along painfully in Firefox). The source code is all there in the page, unobfuscated, and the author has released the code (which is fairly elegantly laid out and comprehensible) under the GPL. Which means that it's probably only a matter of time until someone uses it to build a DHTML-based Commodore 64 or something.

Google are apparently working on a new web browser. Named Chrome, the browser is designed more like an operating system which happens to be based on web technologies like DOM and JavaScript than a traditional browser; different pages are separate processes (and about time, too) and privileges are compartmentalised to fortify security. Meanwhile, the web rendering implementation is based on WebKit (the Apple/KDE open-source web engine), with a JIT-compiling JavaScript engine optimised for application from a Danish company named V8 (I wonder how it compares to Apple's Squirrelfish and Mozilla's new engine). Alas, there's no code available (and the URL given returns a 404); instead, Google have given us a beautifully drawn 38-page comic by Scott McCloud, illuminating the technical innovations and the reasons for them, in great detail and with no small amount of humour:

That's all the detail that seems to exist so far. There is a possibility that it's just an elaborate feint; Google could, in theory, have paid McCloud some huge sum to draw a comic to specification, peppered with technical versimilitude, purely in order to send Microsoft/Apple/Yahoo!/whoever's development teams on a wild goose chase. Though I suspect that there is an actual product there. For one, Google are known to use WebKit on Android.
More importantly, though, a browser designed as a web application operating system (with the expectations of performance and stability that implies), rather than an information viewer with programmability grafted on as an afterthought (as is the case with current browsers), would line up rather nicely with Google's strategy to make the web into a first-class application platform.

There are no details on what platforms Chrome will run; it is open-source (and other projects, or those willing to fork those, will probably have a field day with this), and the comic does mention Windows in one place, so presumably a Windows version is planned. I'm guessing that Google aren't doing this to help Microsoft sell Windows licences, though, so presumably this is not the only version planned. A Linux desktop version, running on top of X, is probably likely. Another possibility is it running over something lighter than the average Linux desktop, making a robust web-browsing appliance on which the browser meets the conventional definitions of an operating system; either Android or some other lightweight OS.

The other option, of course, is that this is an elaborate hoax, akin to the Photoshopped "spy photos" of new Apple Mac tablets and other fantastic gear that are a regular feature of gadget blogs. The fact that Google's Chrome page doesn't yet exist (at time of writing) does suggest this possibility. Though this would imply that the hoaxers had an enormous amount of time on their hands, excellent comic drawing skills and an uncanny mastery of the drawing style of Scott McCloud.

Update:Google have confirmed Chrome. It's initially a Windows product (presumably to win market share before IE8 comes along and shuts off Google's oxygen with its advertising cookie blocker), though Mac and Linux versions are in the works. The Windows version will apparently be out tomorrow.

Someone has written a JavaScript-based 6502 assembler and emulator. The system compiles 6502 assembly language into JavaScript, includes a (low-resolution) emulated video display, and is powerful enough to play simple games like Pong (included in the examples).

That is, as long as you're not concerned about your code working on non-Mozilla web browsers. (I wonder whether Microsoft, who still have well over 80% of the browser market, will adopt these new features.)

Firefox extension of the day: NoScript, which allows you to enable JavaScript selectively only for specific trusted sites, disabling it for everyone else. Which, in the age of sneakyphishing attacks (not to mention sites which obnoxiously maximise their windows, disable the right mouse button or do similarly annoying things), it could be quite useful.

JS/UIX; a complete virtual UNIX machine that runs entirely in JavaScript using DHTML. Well, not entirely complete; the realistic-looking executable files in /bin, upon closer inspection, have sizes of 'n/a', and are basically façades for JavaScript pixie dust that does what they are meant to; also, the shell doesn't actually support any scripting commands. However, you can create and access files, and it even has a mostly usable implementation of vi.

A fairly informative dissection and analysis of Google Maps and how it does its magic. It's pretty interesting; unlike GMail (the other example of an impressive DHTML-based interface from Google), Maps doesn't use XMLRPC, but instead just fetches tiles in JavaScript and uses a hidden frame to communicate with the server, and the browser's inbuilt XSLT engine to parse the result. Which all makes for some very impressive hack value.

This is a UK-based classified advertising site, offering listings of real estate, items for sale, personals and so on. Which is all very well, except that some genius had the brilliant idea of not using ordinary web links for ads, but instead doing it all in Javascript. When you click on an ad, it executes a piece of javascript which changes the current window's location for you. This means that it is impossible to open an ad in a separate window or tab; you can only view Loot in one window at a time, linearly going from ad to ad and backtracking as need be.

I have no idea why anybody could have thought that sort of user-hostile web design is a good idea. It's not to encourage people to pay (paid users get the same interface), it doesn't give the site a slick, Gmail-like interface (it's just a normal web site, except that you can't easily view more than one thing at a time), or otherwise contribute to the user experience (unless, perhaps, the user is a submissive masochist), it doesn't even seem to aim for the holy grail of Protecting Valuable Intellectual Property. The only possibilities I can think of are: (a) that they were betting that, by slowing down user browsing of their site, they could eke more time-limited ad-viewing tokens out of their users, and that no competing website would steal their customers by offering a less annoying experience, or (b) that whoever designed it just wanted to show off their web kung fu ("Look mum, Javascript!")

I'm Wayne Kerr, and if there's one thing I hate... it's web sites which use Javascript to disable the right-button menu. It's the web equivalent of copy-protected CDs; it doesn't stop people from downloading their images/content or stealing their HTML design secrets (if your browser can download it, you can grab it), but does prevent honest users from opening a link in another window/tab, should they so desire.

Lemmings in DHTML/Javascript; a faithful reconstruction of the classic Amiga game, with no Flash/Java involved.
Still a work in progress, but impressive as fuck. See it before it's Slashdotted.
(via MeFi)

I'm Wayne Kerr, and if there's one thing I hate...
it's web sites which disable your browser's right mouse button, just to show
that it can be done/to assert control over your web browsing.
Like this one.
If I want to open a link in a Mozilla tab, instead of the menu I get a
pop-up message saying "function disabled".
Oooh, I stand in awe of your godlike JavaScript skills. Wanker.

Sick of pop-up ads and other nastiness? Well, if you use Mozilla, here's
how to
switch off JavaScript "features" on a site-by-site basis.
This is not in the UI yet, either because they haven't gotten around to doing
it, or because they've snuck it in under AOL's nose.

I'm Wayne Kerr, and if there's one thing I hate...
it's that stupid JavaScript scroller gimmick. You know, the one that
some pages have, scrolling a flickery message (typically something droolingly
inane like "Hi! Welcome to my web page!") through your browser's status bar. You can't stop
it (as you can GIF animations), you can't see any links you put the cursor
over, and it's irritating as hell. And no, it's not cool, or clever, and it
makes the designer of the web page (or the pointy-haired management type who
signed off on it) look like a cretin.
Unfortunately, the Ausway street directory
home page has succumbed to this particular lapse of taste.

A somewhat psychoceramic religious extremist group has seemingly not been too
happy with the heathens poking fun at them, and has decided to fight back.
The source of this
page on the evils of teen pop bands contains this interesting
JavaScript fragment:

I'm Wayne Kerr, and if there's one thing I hate...
it's web sites which require JavaScript to work, for no reason other
than custom pop-up windows looking cool. Sadly to say, the Fringe
Festival site is one example.

One year ago:

2014/2/26

The latest thing in Williamsburg, the ground zero of the modern Hipster subculture and its gentrification, is facial hair transplants , for men who lack the ability to grow a luxuriant urban-woodsman beard otherwise:
"I get

Two years ago:

2013/3/1

Berliners are protesting against the tearing down of what's left of the Berlin Wall, as a section decorated with murals and known as the East Side Gallery is demolished to make room for—wait for it—luxury apartments

Five years ago:

2010/3/2

Apparently,
London is experiencing somewhat of a coffee renaissance ,
with a number of good cafés having opened over the past two years or so,
many of them run by Australians or New Zealanders .