[Melbourne-pm] Hello World...

Sam Watkins sam at nipl.net
Mon Dec 7 06:28:14 PST 2009


On Mon, Dec 07, 2009 at 10:22:55PM +1100, Scott Penrose wrote:
> Here is a very fun yet silly idea :-)
> 
> 	http://hellowiki.org/
> 
> A wiki of hello world examples.

I didn't check it out yet due to my system being busy doing something else
right now.  I reckon it would be nice to extend it to have a "pleasing example"
for each language also, a small program (let's say under one 80x25 page) that
does something nice and interesting and shows off some nice features of the
language in question.  The standard Hello World is not a very exciting program
and typically shows almost nothing interesting about the language!  (Also there
is already a website with hello-world programs for every language under the
sun.)

For example for brace I might post this short mandelbrot set plotter (or maybe
something else, it's just an example):

#!/lang/b
use b

Main():
	num outside = 16, ox = -0.5, oy = 0, r = 1.5
	long i, max_i = 100, rb_i = 30
	space()
	uint32_t *px = pixel()  # CONFIGURE!
	num d = 2*r/h, x0 = ox-d*w_2, y0 = oy+d*h_2
	for(y, 0, h):
		cmplx c = x0 + (y0-d*y)*I
		repeat(w):
			cmplx w = c
			for i=0; i < max_i && cabs(w) < outside; ++i
				w = w*w + c
			*px++ = i < max_i ? rainbow(i*359 / rb_i % 360) : black
			c += d
	Paint()


Sam


More information about the Melbourne-pm mailing list