9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: rog@vitanuova.com
To: 9fans@cse.psu.edu
Subject: Re: [9fans] Limbo Tk FAQ?
Date: Fri, 25 May 2001 10:59:48 +0100	[thread overview]
Message-ID: <20010525095153.BFB8D19A4F@mail.cse.psu.edu> (raw)

> > graphics programming still
> > reminds me of assembler programming: way too much attention
> > to way too much irrelevant detail.
>
> I'm pleased to discover I am not alone in this, although I couldn't
> have phrased it as succintly or as accurately as you did.  And I
> enjoy assembly programming, but I find graphics programming far
> too tedious.

i think that's because you've got multi-dimensional inputs, often with
associated state, which are much harder to deal with than the
unidimensional, stateless input stream of a command-line program, for
example.

at least with limbo/tk, the language is decently multi-threaded, so
it's often possible to carve a program into logically independent
threads, each of which is quite simple, rather than the age old "one
big state machine" paradigm which is the only way of doing things in
many GUI programming interfaces. despite its superficial simplicity,
i'll bet that Visual Basic falls into that category too.

where GUI programming is inevitably tedious is when you're dealing with
input forms (buttons, entry widgets, sliders, tickboxes, etc, etc), as
there are so many possible states to think about and deal with in the
program. i think that this is going to be the case regardless of
language. the key is probably to minimise (eliminate?) instances of
this kind of interface.

i've found limbo/tk to be a very productive environment, compared to
others i've used (principally the NeXTStep interface (now MacOS X),
which i believe is well regarded).  the first-class strings in limbo
sit very well with the string-based nature of tk. strings nicely
represent a generic tk object.

for instance, the following code animates an arbitrary object smoothly
across a tk canvas at constant velocity. it doesn't matter what the
object is (it might be a composite of many); and there can be any
number of animations happening concurrently.

animproc(a: ref Animation)
{
	SPEED: con 1.5;			# animation speed in pixels/millisec
	dstpt := a.dst.pos.add(a.dst.delta.mul(a.index));
	srcpt := a.srcpt;
	d := dstpt.sub(srcpt);
	if (!d.eq((0, 0))) {
		mag := math->sqrt(real(d.x * d.x + d.y * d.y));
		(vx, vy) := (real d.x / mag, real d.y / mag);
		currpt := a.srcpt;		# current position of object
		t0 := sys->millisec();
		dt := int (mag / SPEED);
		t := 0;
		tk->cmd(win, ".c raise " + a.tag);
		while (t < dt) {
			s := real t * SPEED;
			p := Point(srcpt.x + int (s * vx), srcpt.y + int (s * vy));
			dp := p.sub(currpt);
			tk->cmd(win, ".c move " + a.tag + " " + string dp.x + " " + string dp.y + ";update");
			currpt = p;
			yield();
			t = sys->millisec() - t0;
		}
	}
	a.waitch <-= a;
}

i wouldn't like to do this sort of stuff in tcl.  limbo just makes it
so simple.

that said, i think there is room for some sort of expandability in
limbo/tk, not via tcl, i think but perhaps via some sort of
channel/module/device interface.

i'm sorry, i'm off topic.

  rog.



             reply	other threads:[~2001-05-25  9:59 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-05-25  9:59 rog [this message]
2001-05-25 10:45 ` Lucio De Re
2001-05-25 14:26 ` Re[2]: " Matt H
  -- strict thread matches above, loose matches on Subject: below --
2001-05-25 12:10 rog
2001-05-25 12:42 ` Lucio De Re
2001-05-24 19:04 geoff
2001-05-24 18:50 geoff
2001-05-25  4:58 ` Lucio De Re
2001-05-25  7:44   ` Re[2]: " Matt H
2001-05-25  8:45     ` Lucio De Re
2001-05-25 12:44   ` Boyd Roberts
2001-05-25 13:28     ` Lucio De Re
2001-05-25 13:31     ` splite
2001-05-25 13:50       ` Boyd Roberts
2001-05-25 14:16   ` Douglas A. Gwyn
2001-05-29  9:16   ` Randolph Fritz
2001-06-08 10:16   ` Barry Kelly
2001-05-24 18:17 forsyth
2001-05-24 12:29 forsyth
2001-05-24 13:04 ` Lucio De Re
2001-05-26 17:25   ` Berry Kercheval
2001-05-24 12:13 nigel
2001-05-24 12:08 Laura Creighton
2001-05-24  9:20 Richard Elberger
2001-05-24 11:09 ` suspect

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=20010525095153.BFB8D19A4F@mail.cse.psu.edu \
    --to=rog@vitanuova.com \
    --cc=9fans@cse.psu.edu \
    /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).