9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: John Floren <slawmaster@gmail.com>
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
Subject: Re: [9fans] The first annual "Hello, World" challenge
Date: Tue, 18 Aug 2009 10:53:39 -0700	[thread overview]
Message-ID: <7d3530220908181053o7cae7f92yd0a4491db7eeef73@mail.gmail.com> (raw)
In-Reply-To: <13426df10908181026m1d977938k8c678b69878fb001@mail.gmail.com>

In rc:
% window 'echo hello world; sleep 5'

It's probably against the spirit, but hey, it fits on a Hollerith
card! Technically.

In C, the quickest thing I came up with using draw is:
#include <u.h>
#include <libc.h>
#include <draw.h>

void
main(void)
{
	initdraw(0, 0, "hello");

	string(screen, addpt(Pt(40,40), screen->r.min), display->black, ZP,
display->defaultfont, "hello world");
	flushimage(display, 1);
	sleep(5000);
}

If you throw in libpanel, it's only a little bigger (mostly libpanel
maintenance things) plus you get a button to quit:

#include <u.h>
#include <libc.h>
#include <draw.h>
#include <event.h>
#include <panel.h>

Panel *root;

void
done(Panel *p, int buttons) {
	USED(p, buttons);
	exits(0);
}

void eresized(int new)
{
	Rectangle r;

	if(new && getwindow(display, Refnone) == -1) {
		fprint(2, "getwindow: %r\n");
		exits("getwindow");
	}
	r = screen->r;
	plpack(root, r);
	draw(screen, r, display->white, 0, ZP);
	pldraw(root, screen);
}

void
main(void)
{
	Event e;

	initdraw(0, 0, "hello");
	einit(Emouse);
	plinit(screen->depth);
	root=plframe(0, EXPAND);
		pllabel(root, PACKN|FILLX, "Hello world!");
		plbutton(root, PACKN, "Done", done);

	eresized(0);

	for (;;) {
		switch(event(&e)){
		case Emouse:
			plmouse(root, e.mouse);
			break;
		}
	}
}




On Tue, Aug 18, 2009 at 10:26 AM, ron minnich<rminnich@gmail.com> wrote:
> See this: http://www.wxwidgets.org/docs/tutorials/hworld2.txt
>
> Well, they just seem to keep getting longer.
>
> Your goal: hello, world in one line. Language of your choice. Linking
> in a 512 MB library is a violation of the spirit of this contest.
>
> Additional rules:
> - line length is not defined but let's be reasonable
> - if you can fit it in a standard Hollerith card format (72 chars plus
> 8 chars of comment) that's a plus
>
> Redirection of stdout is allowed.
>
> ron
> ron
>
>



--
"Object-oriented design is the roman numerals of computing" -- Rob Pike



  reply	other threads:[~2009-08-18 17:53 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-18 17:26 ron minnich
2009-08-18 17:53 ` John Floren [this message]
2009-08-18 18:53   ` andrey mirtchovski
2009-08-18 23:18     ` James Tomaschke
2009-08-19 10:32     ` Uriel
2009-08-19 13:52       ` andrey mirtchovski
2009-08-18 17:54 ` erik quanstrom
2009-08-19  0:25 ` Abhishek Kulkarni
2009-08-19  2:06   ` LiteStar numnums

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7d3530220908181053o7cae7f92yd0a4491db7eeef73@mail.gmail.com \
    --to=slawmaster@gmail.com \
    --cc=9fans@9fans.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).