Top down Python

J

John Allsup

What is needed for proper learning is near-absolute simplicity.
Even one toy too many to play with is an intolerable distraction,
but one too few massively hampers learning and induces boredom.

I want to be able to say:
1. Put a nice picture on the background.
2. Put a terminal window with, say, 64x20 lines, dead centre.
3. Run a simple REPL program written in Python or Ruby within it.
I do not really want to write any more lines of code than I need to.
Why do we not have langauges and libraries that can do the above
with only five lines of code (line 0 == setup, line 4 == cleanup).

Programming should be that efficient if we learn to make things
beautiful and not tolerate wastes of lines and characters, on
a global scale as well as locally to our projects.

Consider
====
#!/usr/bin/env python3

from myappfw import app
from myapp1 import repl
app.background = "Moutains1"
t = app.terminal.open(title="Typing commands One Oh One",position="centre",
width="80%",height="72%",rows="20",columns="64")
exit(t.run(repl))
====

What Python would I need to write, as concise but readable as
practically possible, so that the above program works as desired (for
any repl that obeys the basic input-process-output behaviour of a repl)?

This is top-down design done right IMO (as described in Thinking Forth,
by the way).
 
J

John Gordon

In said:
I want to be able to say:
1. Put a nice picture on the background.
2. Put a terminal window with, say, 64x20 lines, dead centre.
3. Run a simple REPL program written in Python or Ruby within it.
I do not really want to write any more lines of code than I need to.
Why do we not have langauges and libraries that can do the above
with only five lines of code (line 0 == setup, line 4 == cleanup).

You're asking for prepackaged libraries with extremely specific behavior.
Forgive me for making an analogy on the Internet, but your request is akin
to asking for a hammer that will automatically pound six-penny nails
through half-inch drywall, while facing south, on Tuesdays.

Such a hammer is great if those are your specific requirements, but
worthless otherwise. It's much better to sell a generic hammer. Sure,
it's a little more work for the user, but it will pound any type of nail
though a variety of surfaces. I.e., it's reusable.
 
C

Chris Angelico

You're asking for prepackaged libraries with extremely specific behavior.
Forgive me for making an analogy on the Internet, but your request is akin
to asking for a hammer that will automatically pound six-penny nails
through half-inch drywall, while facing south, on Tuesdays.

Such a hammer is great if those are your specific requirements, but
worthless otherwise. It's much better to sell a generic hammer. Sure,
it's a little more work for the user, but it will pound any type of nail
though a variety of surfaces. I.e., it's reusable.

There is a reusable component to this: a "terminal window" GUI object.
If one existed, then this would be a matter of:

1) Create window
2) Put picture as background
3) Create terminal window with size 64x20 (which, IMO, is tiny)
4) Call on subprocess to handle REPL

Depending on how compact the code is, it might take 6-10 lines rather
than five, but it would be fairly short. However, it depends on being
able to simply "create terminal window" the way you "create button" or
"create entry field". As far as I know, this doesn't exist *anywhere*,
which is why I've written a number of MUD clients whose primary
purpose is to do exactly that.

ChrisA
 
C

Chris Angelico

Maybe ....

64 characters x 20 lines

Yes, but still tiny. Normal minimum would be 80x25 (maybe 80x24). I
like to go a lot larger. When I'm compiling code, I generally maximize
the window - on today's system, that's 190x51 - and for MUDding, I'll
usually go for roughly 90x∞, because I can. :) My current MUD window
is 89x32 visible, 89x∞ stored. 64x20 means everything's going to wrap,
and it won't take much to push text off the "screen".

ChrisA
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,989
Messages
2,570,207
Members
46,783
Latest member
RickeyDort

Latest Threads

Top