Top down Python

John Allsup pydev at allsup.co
Wed Feb 12 12:05:40 EST 2014


Hi,

Current software development methods make things way more complex than
they need to be.  I am trying to get an idea for how simple things can
be from final product down to low level implementation, hoping to
recover the code density miracles that the old school Forthers turned
out ages ago.  They outlined a philosophy that I wish to bring back to
life.  This is the beginning of my first attempt, and I wish to do this
in the full gaze of fellow Pythoners so that any mistakes I make can be
seen by others, and any lessons learned passed on as cheaply and
efficiently (in terms of real world work and energy) as possible.

Hope this starts to clarify the picture I have in my head.

All the best,

John

On 12/02/2014 07:42, Chris Angelico wrote:
> On Wed, Feb 12, 2014 at 6:05 PM, John Allsup <pydev at allsup.co> wrote:
>>      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).
>
> #!/bin/sh
> xfce4-terminal --geometry=64x20 -x python3
>
> There you are, two lines. :)
>
> Seriously though, what you're asking is deceptively simple yet
> incredibly difficult. You're trying to recreate the entire structure
> of a terminal emulator or telnet client. I can show you the code for a
> MUD client, which does a lot of what you're looking for; in fact, this
> one has a REPL inbuilt (not Python or Ruby though):
>
> https://github.com/Rosuav/Gypsum/
>
> That's roughly how much code it takes to make a reasonably usable
> replicant of a terminal window. (Some of that is specific to
> networking and MUDding, but at very least, window.pike is basically
> all about the visuals.) You'll do far better to make use of someone
> else's terminal renderer, and just put a desktop background to make
> your fancy image. Otherwise, you have to recreate everything - console
> output (complete with color, presumably), scrolling, input history
> (you can get most of your editing keys easily enough, but you will
> need command history), clipboard operations, and somewhere along the
> way, performance. Save yourself a whole mess of trouble and just use
> your OS-provided terminal program :)
>
> Actually, for what you're looking at, IDLE is probably close to what
> you want. You could have a look at how much code it takes to power
> IDLE, and/or just use it as is. It's pretty handy; I use it as my
> primary interactive Python on Windows.
>
> ChrisA
>






More information about the Python-list mailing list