Prime
Prime Real Estate[edit | edit source]
This demo page http://www.whatwg.org/demos/workers/primes/page.html from the Web Hypertext Application Technology Working Group shows prime numbers. What I found interesting is that initially, it takes a few moments to find prime numbers; meaning that they are "far apart" as you examine every number up to say 1,000,000. But suddenly the demo application is spitting out prime numbers faster than you can read. So, apparently there are a lot of prime numbers once you get into the larger numbers. But this isn't actually true. If you look at the distribution of primes, there are "more" smaller primes than larger primes (X < 200) [1]. Hmm.
<!DOCTYPE HTML>
<html>
<head>
<title>Worker example: One-core computation</title>
</head>
<body>
<p>The highest prime number discovered so far is: <output id="result"></output></p>
<script>
var worker = new Worker('worker.js');
worker.onmessage = function (event) {
document.getElementById('result').textContent = event.data;
};
</script>
</body>
</html>
Concurrency[edit | edit source]
Aside from that, this demo illustrates how HTML5 brings multi-threaded execution or concurrency to your web application.
With "workers" you can perform a computationally expensive task without interrupting the user interface.
In this example, the main document spawns a worker to (naively) compute prime numbers, and progressively displays the most recently found prime number.
Word of the Day[edit | edit source]
pul-chri-tu-di-nous; adj. Very pleasing or delightful to look at - Characterized by, or having great physical beauty and appeal.