Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Is there a programming language that is combination of Python and Basic?

7 views
Skip to first unread message

baykus

unread,
Apr 17, 2009, 4:37:50 PM4/17/09
to
Hi

I am looking for one of those experimental languages that might be
combination of python+basic. Now thta sounds weird and awkward I know.
The reason I am asking is that I always liked how I could reference-
call certain line number back in the days. It would be interesting to
get similar functionality in Python.

Aahz

unread,
Apr 17, 2009, 4:52:18 PM4/17/09
to
In article <f222fcd3-56a4-4b2f...@e18g2000yqo.googlegroups.com>,

Why do you want to do that? Before you answer, make sure to read this:

http://www.u.arizona.edu/~rubinson/copyright_violations/Go_To_Considered_Harmful.html
--
Aahz (aa...@pythoncraft.com) <*> http://www.pythoncraft.com/

"If you think it's expensive to hire a professional to do the job, wait
until you hire an amateur." --Red Adair

Mensanator

unread,
Apr 17, 2009, 5:00:18 PM4/17/09
to
On Apr 17, 3:37 pm, baykus <baykusde...@gmail.com> wrote:
> Hi
>
> I am looking for one of those experimental languages that might be
> combination of python+basic. Now thta sounds weird and awkward I know.

That's a clue you won't find anyone seriously contemplating
such idiocy.

> The reason I am asking is that I always liked how I could reference-
> call certain line number back in the days.

A bad idea. If you really want to write bad code, learn C.

> It would be interesting to get similar functionality in Python.

Yeah, it would "interesting" just as a train wreck is "interesting",
as long as you're not the one who has to live through it.

I once translated a BASIC program to Pascal (hint: no goto allowed).
The original code had GOSUBs that never executed a REURN because
the programmer jumped away to line numbers on a whim. Biggest piece
of crap I ever had to misfortune to deal with.

No one has ever missed what you're pining for.

Leguia, Tony

unread,
Apr 17, 2009, 5:10:47 PM4/17/09
to baykus, pytho...@python.org
Though I don't know why you would want to reference lines numbers, I assume it's for goto statements or something similar.
With that said please read:
1) http://www.u.arizona.edu/~rubinson/copyright_violations/Go_To_Considered_Harmful.html

I would also like to put forth my opinion, shared by many in the community, that Basic is actually dangerous as an educational programming language, and that writing
large professional code in it is hard, and actually hampered by the language. I'm not trying to to start a flame war here but this post almost made me cry.

Also python is functional, it's so powerful. Grow and learn to take advantage of that. Why hold yourself back?

________________________________________
From: python-list-bounces+leguiato=grinne...@python.org [python-list-bounces+leguiato=grinne...@python.org] On Behalf Of baykus [bayku...@gmail.com]
Sent: Friday, April 17, 2009 3:37 PM
To: pytho...@python.org
Subject: Is there a programming language that is combination of Python and Basic?

Hi

--
http://mail.python.org/mailman/listinfo/python-list

baykus

unread,
Apr 17, 2009, 5:21:16 PM4/17/09
to
I guess I did not articulate myself well enough. I was just looking
for a toy to play around. I never suggested that Python+Basic would be
better than Python and everyone should use it. Python is Python and
Basic is Basic. I am not comparing them at all. I understand the
merits of Python but that does not mean I can play with ideas?

Arnaud Delobelle

unread,
Apr 17, 2009, 5:23:54 PM4/17/09
to
baykus <bayku...@gmail.com> writes:

I am currently working on such a "Python-Basic" programming language.
Here is the current implementation:

-------------- basic.py ----------------
class GotoLine(Exception): pass

def goto(newlno): raise GotoLine(newlno)

def run(program):
lno = 0
env = { 'goto': goto }
try:
while lno <= max(program):
try:
if lno in program:
exec program[lno] in env
lno += 1
except GotoLine, g:
lno, = g.args
except Exception:
print "? Syntax error in line", lno
print "OK."
----------------------------------------

Example of use
==============

marigold:junk arno$ python -i basic.py
>>> program = {
... 5: "# REM Python-Basic example program",
... 6: "# REM ----------------------------",
... 10: "i = 0",
... 20: "print 'Hello, world', i",
... 30: "i = i + 1",
... 40: "if i < 10: goto(20)",
... 50: "name = raw_input('What is your name? ')",
... 60: "print 'Welcome,', name",
... 70: "gosub(80)"
... }
>>> run(program)
Hello, world 0
Hello, world 1
Hello, world 2
Hello, world 3
Hello, world 4
Hello, world 5
Hello, world 6
Hello, world 7
Hello, world 8
Hello, world 9
What is your name? Arnaud
Welcome, Arnaud
? Syntax error in line 70
OK.
>>>

As you can see, I haven't implemented gosub() yet.

--
Arnaud

Michael Torrie

unread,
Apr 17, 2009, 6:01:29 PM4/17/09
to pytho...@python.org

*No one* in the BASIC world uses line numbers anymore. Why would you
want to?

If you just want basic, get freebasic from freebasic.net

Personally I can't see any reason to use any dialect of BASIC over
Python. If you pine for the bad old days of jumping to random line
numbers, maybe just create a list of function objects in python (a call
table) and call a random one.

Michael Torrie

unread,
Apr 17, 2009, 6:02:11 PM4/17/09
to pytho...@python.org
Mensanator wrote:
> I once translated a BASIC program to Pascal (hint: no goto allowed).
> The original code had GOSUBs that never executed a REURN because
> the programmer jumped away to line numbers on a whim. Biggest piece
> of crap I ever had to misfortune to deal with.

It's clear that you haven't done anything in BASIC since the 80s. And
probably the original poster hasn't either. So let's just clear the air
here.

I haven't seen a "GOTO" in BASIC code in probably almost 20 years, ever
since BASIC gained true structure. In fact as BASIC is used today, it's
really similar to Pascal, but a lot nicer to work with. BASIC is a very
structure language, and in VB, it's also object-oriented, although I'm
sure lots of crap is written in VB. You may shudder at the thought, but
BASIC is very much a modern language now. If you're bored, check out
freebasic.net. Not that I recommend you use FreeBASIC for anything (nor
do I recommend most languages but python!).

Spaghetti code can be written in *any* language. It's nothing inherent
to BASIC. I have seen spaghetti python, particularly projects that are
designed around the twisted framework. Tracing execution through
twisted is very painful.

That said, what the original poster is looking for is very silly.

Michael Torrie

unread,
Apr 17, 2009, 6:07:10 PM4/17/09
to pytho...@python.org
Aahz wrote:
> Why do you want to do that? Before you answer, make sure to read this:
>
http://www.u.arizona.edu/~rubinson/copyright_violations/Go_To_Considered_Harmful.html

Somebody better tell the Linux kernel developers about that! They
apparently haven't read that yet. Better tell CPU makers too. In
assembly it's all gotos.

baykus

unread,
Apr 17, 2009, 6:29:56 PM4/17/09
to
On Apr 17, 5:02 pm, Michael Torrie <torr...@gmail.com> wrote:

> Mensanator wrote:
>
> It's clear that you haven't done anything in BASIC since the 80s. And
> probably the original poster hasn't either. So let's just clear the air
> here.


Michael you are kind of rigtht, I did use basic in early 90s :) Thanks
for the more insightful comments, I understand the drawbacks and
backwardness of Basic, I am not here to defend it. I guess I have a
different perception when it comes to Basic. I think many people think
those "lines" as numbered steps or numbered bricks that are sitting on
eachother but I see them as timelines or like filmstrips. Anyways it
sounds like such a toy programming language does not exists except
Arnaud surprisingly efficient code. and I will search my dream
somewhere else :)

thanks for all the negative and positive comments :)


Scott David Daniels

unread,
Apr 17, 2009, 7:22:43 PM4/17/09
to
Michael Torrie wrote:
> baykus wrote:
>> I am looking for one of those experimental languages that might be
>> combination of python+basic. Now thta sounds weird and awkward I know.
>> The reason I am asking is that I always liked how I could reference-
>> call certain line number back in the days. It would be interesting to
>> get similar functionality in Python.
>
> *No one* in the BASIC world uses line numbers anymore. Why would you
> want to? ...

The problem I see is that Basic as you use it above is not a language,
but a family of languages. Different Basics share as much (and as
little) as different SQLs. For my money, Visual Basic 5.0 is a
language. THe different Microsoft Basics usually have a lot of language
change, rather than being library additions. A lot of very different
languages have been called Basic, with the attendant confusion as old
syntax or semantics are abandoned or changed. The changes to Python 3.x
is a language change, but Python has been _very_ conservative about
changing (as opposed to extending) the language.

There are only a few languages that might plausibly called "Basic",
and Dartmouth Basic has maybe the best claim to that name.

--Scott David Daniels
Scott....@Acm.Org

Leguia, Tony

unread,
Apr 17, 2009, 7:18:49 PM4/17/09
to Michael Torrie, pytho...@python.org
>Somebody better tell the Linux kernel developers about that! They
>apparently haven't read that yet. Better tell CPU makers too. In
>assembly it's all gotos.

There a very big difference between high level programming, and assembly programming.
Python is a high level language.
I shouldn't have to say anymore.
________________________________________
From: python-list-bounces+leguiato=grinne...@python.org [python-list-bounces+leguiato=grinne...@python.org] On Behalf Of Michael Torrie [tor...@gmail.com]
Sent: Friday, April 17, 2009 5:07 PM
Cc: pytho...@python.org
Subject: Re: Is there a programming language that is combination of Python and Basic?

Aahz wrote:
> Why do you want to do that? Before you answer, make sure to read this:
>
http://www.u.arizona.edu/~rubinson/copyright_violations/Go_To_Considered_Harmful.html

Somebody better tell the Linux kernel developers about that! They


apparently haven't read that yet. Better tell CPU makers too. In
assembly it's all gotos.

--
http://mail.python.org/mailman/listinfo/python-list

Mensanator

unread,
Apr 17, 2009, 7:40:39 PM4/17/09
to
On Apr 17, 5:02 pm, Michael Torrie <torr...@gmail.com> wrote:
> Mensanator wrote:
> > I once translated a BASIC program to Pascal (hint: no goto allowed).
> > The original code had GOSUBs that never executed a REURN because
> > the programmer jumped away to line numbers on a whim. Biggest piece
> > of crap I ever had to misfortune to deal with.
>
> It's clear that you haven't done anything in BASIC since the 80s.  

Not hardly, I use VBA every day in Excel & Access. The example
I mentioned WAS from the 80's.

> And
> probably the original poster hasn't either.  So let's just clear the air
> here.

I don't see any need. Of course, you're the one who's view is muddied.

>
> I haven't seen a "GOTO" in BASIC code in probably almost 20 years, ever
> since BASIC gained true structure.  

Try UBASIC. And I didn't say modern BASICs were like those of the
80's,
I questioned why anyone would want to return to such systems as
existed
in the 80's.

> In fact as BASIC is used today, it's
> really similar to Pascal, but a lot nicer to work with.  

And I wasn't refering to that, I was specifically criticizing
the jumping to random line numbers within the program. Can't do
that in a modern BASIC? Fine, but who's asking for that? The OP.

> BASIC is a very
> structure language, and in VB, it's also object-oriented, although I'm
> sure lots of crap is written in VB.  You may shudder at the thought, but
> BASIC is very much a modern language now.  

As I said, I use it (VBA) every day and have probably written
more BASIC programs than you've had hot dinners.

> If you're bored, check out freebasic.net.  

Thanks, but I'll give it a miss.

> Not that I recommend you use FreeBASIC for anything (nor
> do I recommend most languages but python!).
>
> Spaghetti code can be written in *any* language.  It's nothing inherent
> to BASIC.  I have seen spaghetti python, particularly projects that are
> designed around the twisted framework.  Tracing execution through
> twisted is very painful.

Of course, but why would the OP think that someone's trying to make
a language that makes spaghetti code easier?

>
> That said, what the original poster is looking for is very silly.

That was my point.

Tim Rowe

unread,
Apr 17, 2009, 7:56:14 PM4/17/09
to Michael Torrie, pytho...@python.org
2009/4/17 Michael Torrie <tor...@gmail.com>:

> Spaghetti code can be written in *any* language.

I challenge you to write spahgetti code in SPARK!

--
Tim Rowe

Martin P. Hellwig

unread,
Apr 17, 2009, 8:19:38 PM4/17/09
to

Well CPU's wouldn't work as well if they didn't had a way to jump to a
predefined instruction when certain conditions are met.
IMHO for people who are users, that is you are not writing machine code
or assembly, you should only use these 'goto's if you are capable of
writing machine code or assembly.

YMMV
--
mph

norseman

unread,
Apr 17, 2009, 8:32:39 PM4/17/09
to baykus, pytho...@python.org
> --
> http://mail.python.org/mailman/listinfo/python-list
>
=======================================
Yeah - after they took at look at Python:
Microsoft calls it VisualBasic

There are some that will enjoy the joke. :)

Steve

Steven D'Aprano

unread,
Apr 17, 2009, 10:43:25 PM4/17/09
to
On Fri, 17 Apr 2009 14:00:18 -0700, Mensanator wrote:

> On Apr 17, 3:37 pm, baykus <baykusde...@gmail.com> wrote:
>> Hi
>>
>> I am looking for one of those experimental languages that might be
>> combination of python+basic. Now thta sounds weird and awkward I know.
>
> That's a clue you won't find anyone seriously contemplating such idiocy.
>
>> The reason I am asking is that I always liked how I could reference-
>> call certain line number back in the days.
>
> A bad idea. If you really want to write bad code, learn C.
>
>> It would be interesting to get similar functionality in Python.
>
> Yeah, it would "interesting" just as a train wreck is "interesting", as
> long as you're not the one who has to live through it.

Nevertheless, somebody *has* implemented such functionality in Python.
Not just GOTO, but also COMEFROM.

http://entrian.com/goto/


> I once translated a BASIC program to Pascal (hint: no goto allowed).

Pascal has GOTOs. People rarely used them, because even in the 1970s and
80s they knew that unstructured gotos to arbitrary places was a terrible
idea.

GOTO in Pascal required that you defined a label in your code, then you
could jump to that label. You can't jump to arbitrary parts of the
program, only within the current procedure.

--
Steven

Mensanator

unread,
Apr 17, 2009, 11:45:30 PM4/17/09
to
On Apr 17, 9:43 pm, Steven D'Aprano <st...@REMOVE-THIS-

cybersource.com.au> wrote:
> On Fri, 17 Apr 2009 14:00:18 -0700, Mensanator wrote:
> > On Apr 17, 3:37 pm, baykus <baykusde...@gmail.com> wrote:
> >> Hi
>
> >> I am looking for one of those experimental languages that might be
> >> combination of python+basic. Now thta sounds weird and awkward I know.
>
> > That's a clue you won't find anyone seriously contemplating such idiocy.
>
> >> The reason I am asking is that I always liked how I could reference-
> >> call certain line number back in the days.
>
> > A bad idea. If you really want to write bad code, learn C.
>
> >> It would be interesting to get similar functionality in Python.
>
> > Yeah, it would "interesting" just as a train wreck is "interesting", as
> > long as you're not the one who has to live through it.
>
> Nevertheless, somebody *has* implemented such functionality in Python.
> Not just GOTO, but also COMEFROM.

Really? Well, _I_ for one, won't be beating a path to his door.

>
> http://entrian.com/goto/
>
> > I once translated a BASIC program to Pascal (hint: no goto allowed).
>
> Pascal has GOTOs.

I know. _I'm_ the one who didn't allow them. And the code ended up
pretty damn bulletproof.

> People rarely used them, because even in the 1970s and
> 80s they knew that unstructured gotos to arbitrary places was a terrible
> idea.

That was obvious from the BASIC code, enough to make you shake
your head in disbelief.

>
> GOTO in Pascal required that you defined a label in your code, then you
> could jump to that label. You can't jump to arbitrary parts of the
> program, only within the current procedure.

And I deliberately made no effort to learn how to use them. And I
never
had a situation I couldn't solve the "proper" way.

>
> --
> Steven

norseman

unread,
Apr 18, 2009, 1:26:32 AM4/18/09
to st...@cybersource.com.au, pytho...@python.org
Steven D'Aprano wrote:
> On Fri, 17 Apr 2009 14:00:18 -0700, Mensanator wrote:
>
...(snip)

> Pascal has GOTOs. People rarely used them, because even in the 1970s and
> 80s they knew that unstructured gotos to arbitrary places was a terrible
> idea.
>

Even in primarily assembly only days that was true.

> GOTO in Pascal required that you defined a label in your code, then you
> could jump to that label. You can't jump to arbitrary parts of the
> program, only within the current procedure.
>

===================================

"...only within the current procedure." That was one of the "why
Pascal didn't hang on" as long as it might have. Another was it's COBAL
structure in defining things. Just like today - the more typing the more
errors, the longer to 'in service'. Imitating Pascal's short jump only
was Intel's lack of actual popularity among the Pro's of the day. Zilog
had the better cpu, but Intel teamed with Gates, shoved interrupt only
on everyone and the rest is history. In fairness to Pascal, the
enforcement of no "goto" helped force the mass of new programmers
(desperately needed now that 'desktops' were here) to think about their
strategy. So did Ashton Tate's dBASE, which probably had more lines of
code world wide in the first two years of its existence than any other
(baring assembly) programming language in equal time. And no internet to
help it. Every one who speaks bad of assembly has never had the
satisfaction of truly feeling the power. ("'cause they got no proper
background" - says the old man) The power of assembly is simple - if
the machine can do it, it's allowed. No need to worry about "if the
compiler will allow" or "work around that compiler bug" or "Oops - they
changed the ...(compiler or interpreter) and now we start over". The
average programmer, who takes a moment to think it out, can out optimize
all but the best commercial compilers. The meticulous individual can
usually match or best the best commercials with fewer 'iterations' of
review when using assembly. Since one is already looking at the
registers and addresses, self optimization is simple.

I still have my Z80 pre-assembler. It allows Do, While, For and Loop
along with If..Then..Else (and/or Elseif) statements in assembly
programming. Z80 had both mandatory and full conditional call, jump,
return ... anywhere to/from in memory. Intel's conditional jump forward
was limited to 126 BYTES. Even with megabytes of memory. Worse than Pascal.
"full conditional" - On Zero, plus, minus, overflow, underflow and some
I don't remember. Most were 1byte commands. (Destination had to be
added, but not return - the microcode took care of that.)
Oh - and TRUE = 0, FALSE != 0 (Zero is good - no error)

VisualBasic IS Microsoft's blend of Python and Basic. IMHO a bad blend.
I am currently in the process of "converting" (re-writing is a better
term) the key VB programs to Python/Tkinter for the department. The
primary vendor finally got smart and told us VB wasn't going to be in
their next release. Python is in, VB is out.
Everybody jump up and shout HURRAH! :)

Steve

Steven D'Aprano

unread,
Apr 18, 2009, 3:37:08 AM4/18/09
to
On Fri, 17 Apr 2009 22:26:32 -0700, norseman wrote:

> The
> average programmer, who takes a moment to think it out,

"A moment"? As in, a second or less?

> can out optimize
> all but the best commercial compilers. The meticulous individual can
> usually match or best the best commercials with fewer 'iterations' of
> review when using assembly.

That might have been true in the 1970s and 80s, but it hasn't been true
for 10-20 years now. The best machine-optimized code is significantly
better than the best human beings can do today, and even free optimizing
compilers can do better than most people.

However, human programmers can, sometimes, hand-optimize the output of
the optimizing compiler in order to gain a slight upper-hand. To
paraphrase Charles Fiterman, the human should always win, because the
human can use the machine, but the machine can't use the human.

http://www.linux.com/base/ldp/howto/Assembly-HOWTO/howtonot.html


> Since one is already looking at the
> registers and addresses, self optimization is simple.

If only modern day programming was that simple. The interaction with
modern CPU makes optimization an order of magnitude harder than it was
back in the days of hand-tuned assembly. I quote from the above link:

"The biggest problems on modern architectures with fast processors are
due to delays from memory access, cache-misses, TLB-misses, and page-
faults; register optimization becomes useless, and you'll more profitably
re-think data structures and threading to achieve better locality in
memory access."


Toto-I-don't-think-we're-in-1975-anymore-ly y'rs,


--
Steven

Steven D'Aprano

unread,
Apr 18, 2009, 3:39:15 AM4/18/09
to
On Fri, 17 Apr 2009 20:45:30 -0700, Mensanator wrote:

>> Nevertheless, somebody *has* implemented such functionality in Python.
>> Not just GOTO, but also COMEFROM.
>
> Really? Well, _I_ for one, won't be beating a path to his door.

Well you should. It's very clever code, and the way he solved the
"problem" is intriguing. It was also a great April Fools joke.

For reference, here's that URL again: http://entrian.com/goto/


>> GOTO in Pascal required that you defined a label in your code, then you
>> could jump to that label. You can't jump to arbitrary parts of the
>> program, only within the current procedure.
>
> And I deliberately made no effort to learn how to use them. And I never
> had a situation I couldn't solve the "proper" way.

You need to distinguish between the use of unstructured jumps like Basic-
style GOTOs and COMEFROMs, which can jump anywhere, and the use of
structured GOTOs and jumps that have well-defined meanings. GOTO, after
all, is just a jump, and we use jumps in Python all the time:

raise Exception
break
continue
if... elif... else...
for... else...
etc.

Often -- well, sometimes -- you can write cleaner, simpler code with GOTO
than without. Fortunately, 95% of those cases can be dealt with a break
or continue in a loop. In a high level language, GOTO is never necessary
and rarely useful, but it is useful on occasion. Any time you find
yourself creating a flag variable just so you can skip a code block, or
enter a code block, then a structured GOTO *could* be a clean
replacement. But probably isn't. (This is not a call for Python to
develop a GOTO, just a defence that they aren't always the Wrong Thing.)

COMEFROM on the other hand is just the purest evil imaginable.

--
Steven

Hendrik van Rooyen

unread,
Apr 18, 2009, 5:44:41 AM4/18/09
to pytho...@python.org
"baykus" <b...rki@gmail.com> wrote:

Apparently this is not allowed by the CS thought police.

The reasoning is based on an Argument from Authority,
namely the Dijkstra link.

Now it looks to me when I read that article, that the jump
is deprecated because it leads to code that is difficult to
understand, which was based on the difficulty that Dijkstra
had to construct a "co-ordinate system" for storing the state
of a program at any given line of code. This was done
without giving any reason as to why this should be important,
or even desirable, except towards the end where he wanted to
define instances in time when a count could conceivably be
off by one, and he asserted without proof that having jumps
in the code makes this more difficult. Even if this assertion
were to be provably true, it does not really follow that jumps
should be banned, but merely that one runs such a risk if one
were to use them. Now to some minds, this "difficulty" may
not be a difficulty at all:

Processors and interrupt service routines are storing the state
of multiple programmes at arbitrary points in the code, even
as I type - and every one of those programmes include jumps.
It is a non - issue.

Mensanator had the same complaint based on difficulty
earlier in this thread, when he described how he struggled
to untangle some spaghetti code. He did not mention if
the spaghetti was actually doing it's job, bug free, which
IMO is the only rational test for the quality of a piece
of code, because it is the reason for its existence.
The aesthetics are, like all aesthetics, a matter of opinion.

I do not agree with the reasoning that effectively says:
"If it is difficult to comprehend, it must be wrong"

If this were to be a tenet, then using the pickle module
should be forbidden too, as it is a complex piece of
code that (to me at least) is not easily understood on a
first read-through.

So does that mean I must stop using pickles?

All Strength to Arnaud for his goto code!
I am looking forward to the gosub and return.
:-)

- Hendrik


Aaron Brady

unread,
Apr 18, 2009, 6:12:20 AM4/18/09
to
On Apr 18, 4:44 am, "Hendrik van Rooyen" <m...@microcorp.co.za> wrote:

> "baykus" <b......@gmail.com> wrote:
> > I guess I did not articulate myself well enough. I was just looking
> > for a toy to play around. I never suggested that Python+Basic would be
> > better than Python and everyone should use it. Python is Python and
> > Basic is Basic. I am not comparing them at all. I understand the
> > merits of Python but that does not mean I can play with ideas?
>
> Apparently this is not allowed by the CS thought police.
>
> The reasoning is based on an Argument from Authority,
> namely the Dijkstra link.

Boo, Appeal to Authority!

snip


> to untangle some spaghetti code.  He did not mention if
> the spaghetti was actually doing it's job, bug free, which
> IMO is the only rational test for the quality of a piece

I don't use 'rational' in the same way. Do you mean objective? Do
readability, brevity, simplicity, purity, etc. contribute to quality?
Is program quality equivalent (or identical) to code quality?

> of code, because it is the reason for its existence.  
> The aesthetics are, like all aesthetics, a matter of opinion.
>
> I do not agree with the reasoning that effectively says:
> "If it is difficult to comprehend, it must be wrong"

Wrong no, but impractical, possibly or probably or almost certainly,
notwithstanding the subject-dependence of ease of comprehension.
Simple code is more future-resilient than that which is difficult to
comprehend, even holding the language (version) constant. It is a
matter of priorities, which have no objective right. The amount of
people that can comprehend a code structure is a competing value to
that of exploration, pioneering, research, and development. However,
even in simplest terms, some structures e.g. recursion, may be
difficult to comprehend, but that doesn't mean they would be better
more complicated.

BJörn Lindqvist

unread,
Apr 18, 2009, 7:39:23 AM4/18/09
to Leguia, Tony, baykus, pytho...@python.org
I first started programming basic and i don't think it has hurt me much.


I can somewhat sympathise with the op, neither python nor any other
mainstream language can still do this:

SCREEN 13
PSET 160,100,255

2009/4/17, Leguia, Tony <legu...@grinnell.edu>:


> Though I don't know why you would want to reference lines numbers, I assume
> it's for goto statements or something similar.
> With that said please read:
> 1)
> http://www.u.arizona.edu/~rubinson/copyright_violations/Go_To_Considered_Harmful.html
>
> I would also like to put forth my opinion, shared by many in the community,
> that Basic is actually dangerous as an educational programming language, and
> that writing
> large professional code in it is hard, and actually hampered by the
> language. I'm not trying to to start a flame war here but this post almost
> made me cry.
>
> Also python is functional, it's so powerful. Grow and learn to take
> advantage of that. Why hold yourself back?
>

> ________________________________________
> From: python-list-bounces+leguiato=grinne...@python.org
> [python-list-bounces+leguiato=grinne...@python.org] On Behalf Of baykus


> [bayku...@gmail.com]
> Sent: Friday, April 17, 2009 3:37 PM
> To: pytho...@python.org

> Subject: Is there a programming language that is combination of Python and
> Basic?
>

> --
> http://mail.python.org/mailman/listinfo/python-list
> --
> http://mail.python.org/mailman/listinfo/python-list
>


--
mvh Björn

greg

unread,
Apr 18, 2009, 7:41:36 AM4/18/09
to
Steven D'Aprano wrote:
> To
> paraphrase Charles Fiterman, the human should always win, because the
> human can use the machine, but the machine can't use the human.

Unless the machine is Omnius.

--
Greg

Stef Mientki

unread,
Apr 18, 2009, 10:02:10 AM4/18/09
to pytho...@python.org
BJörn Lindqvist wrote:
> I first started programming basic and i don't think it has hurt me much.
>
>
> I can somewhat sympathise with the op, neither python nor any other
> mainstream language can still do this:
>
> SCREEN 13
> PSET 160,100,255
>
Maybe, who is able to understand such nosense without a lot of apriori
knowledge ?
cheers,
Stef

MRAB

unread,
Apr 18, 2009, 10:41:12 AM4/18/09
to pytho...@python.org
What I found strange was that labels could be only unsigned integers,
but they still had to be declared:

label 1, 2, 3;

Fortunately the version(s) I used (TurboPascal/Dephi) permitted
identifiers.

Steven D'Aprano

unread,
Apr 18, 2009, 12:29:30 PM4/18/09
to
On Sat, 18 Apr 2009 13:39:23 +0200, BJörn Lindqvist wrote:

> I first started programming basic and i don't think it has hurt me much.
>
> I can somewhat sympathise with the op, neither python nor any other
> mainstream language can still do this:
>
> SCREEN 13
> PSET 160,100,255

Maybe, maybe not. What on earth does it do?

--
Steven

D'Arcy J.M. Cain

unread,
Apr 18, 2009, 12:36:25 PM4/18/09
to Steven D'Aprano, pytho...@python.org
On 18 Apr 2009 16:29:30 GMT

It makes people scratch their heads and wonder what the hell it does.

--
D'Arcy J.M. Cain <da...@druid.net> | Democracy is three wolves
http://www.druid.net/darcy/ | and a sheep voting on
+1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner.

Tim Rowe

unread,
Apr 18, 2009, 12:38:39 PM4/18/09
to norseman, pytho...@python.org, st...@cybersource.com.au
2009/4/18 norseman <nors...@hughes.net>:

> "...only within the current procedure."   That was one of the "why Pascal
> didn't hang on" as long as it might have.

Really? I thought it was because of the lack of support for packaging,
which was solved in different ways by Object Pascal/Delphi and by
Modula 2, the latter of which in turn became Ada, which is still doing
pretty well in mission-critical contexts.

>  Another was it's COBAL structure
> in defining things. Just like today - the more typing the more errors, the
> longer to 'in service'.

Got any evidence for that? There's a lot of typing in Ada (it shows
its Pascal roots) but in all the studies I've seen Ada production code
has consistently shown fewer errors than the more concise C/C++ family
of languages.

--
Tim Rowe

Aahz

unread,
Apr 18, 2009, 12:45:40 PM4/18/09
to
In article <mailman.4112.1240072...@python.org>,

Tim Rowe <dig...@gmail.com> wrote:
>
>Really? I thought it was because of the lack of support for packaging,
>which was solved in different ways by Object Pascal/Delphi and by
>Modula 2, the latter of which in turn became Ada, which is still doing
>pretty well in mission-critical contexts.

<blink> I had never previously heard that Modula-2 significantly
influenced Ada, and the Wikipedia entry says nothing about it. Do you
have a cite?
--
Aahz (aa...@pythoncraft.com) <*> http://www.pythoncraft.com/

"If you think it's expensive to hire a professional to do the job, wait
until you hire an amateur." --Red Adair

Tim Chase

unread,
Apr 18, 2009, 12:58:09 PM4/18/09
to Steven D'Aprano, pytho...@python.org
>> SCREEN 13
>> PSET 160,100,255
>
> Maybe, maybe not. What on earth does it do?

I believe this attempts to set screen-mode 13 (I'm surprised this
isn't a hex constant, though that may be a (Q)Basic quirk), which
for older VGA cards was 320x200 with 256-colors. It then looks
like it sets a point at (160,100 = the middle of the screen) in
color #255.

Ah, back in the days where each application had to maintain the
screen itself, and you had to use hacks to get square pixels (the
320x200 in this mode had a non-square aspect-ratio) in Mode-X.
Can't say I miss it much beyond nostalgia.

-tkc

Message has been deleted

Mensanator

unread,
Apr 18, 2009, 2:41:04 PM4/18/09
to
On Apr 18, 4:44 am, "Hendrik van Rooyen" <m...@microcorp.co.za> wrote:

Oh, the bugs were there, alright. But they tended to be very
subtle, so much so the original author must not have noticed them.
For instance, a players AGILITY attribute affected the player's
probability of hitting the monster he was attacking. This AGILITY
attribute was altered by the quality of the player's armor, heavier
plate armor being more adverse than light leather armor.

In most situations, the adjustment is made once at the start of
the game. Rarely is armor donned or removed during the course
of the game. But it does happen in some games. I wrote one
in which the player is captured and whatever armor he started
the game with is taken away and part of his quest, in aggition to
finding his way out of the dungeon, is to recover all the
artifacts he entered the game with (which are hidden throughout
to encourage wandering all over the layout).

One of the symptoms of the spaghetti code's jumping around instead
of doing subroutine returns was failure of the armor algorithm to
properly adjust the AGILITY when armor is removed. The result was
that AGILITY was only ever adjusted downwards, and never restored
if it was taken off. If the player then subsequently donned it again,
AGILITY would be further reduced.

The same type of subtlty occured with monster COURAGE. Any monster
(including the friendly ones who fought on your side) that didn't
have a COURAGE rating of 100 was supposed to flee the room if a
certain level of damage was taken. Again, because of goto screwups,
such behaviour was rarely seen. Once corrected, it happened quite
frequently, so much so that it affected the overall game itself.

With the entire dynamic of the game beig very different, desingers
estimates on how many monsters to place in a given scenario were
all incorrect.

> The aesthetics are, like all aesthetics, a matter of opinion.

Game design isn't just a matter of aesthetics.

>
> I do not agree with the reasoning that effectively says:
> "If it is difficult to comprehend, it must be wrong"

A programmer once said to me "Why should I run it, I know
how it works, I wrote it."

My reply: "You only THINK you know how it works. _I_, on
the other hand, ACTUALLY know how it works because I've
run it."

Tim Rowe

unread,
Apr 18, 2009, 4:20:29 PM4/18/09
to Aahz, pytho...@python.org
2009/4/18 Aahz <aa...@pythoncraft.com>:

> <blink>  I had never previously heard that Modula-2 significantly
> influenced Ada, and the Wikipedia entry says nothing about it.  Do you
> have a cite?

Not in writing. I got it from a SPARK user group meeting many years
ago. SPARK is, of course a subset of Ada with some mandatory
structured comments, and is a successor to SPADE which was much the
same thing for Pascal. When somebody asked one of the SPARK team -- I
think it was Denton Clutterbuck -- why they'd gone from Pascal to Ada
rather than Modula2, he observed "If you look at the SPARK subset
you'll see that it pretty much *is* Modula2". So whether Modula2 was a
direct influence or not, it seems to have found its way in.

--
Tim Rowe

Tino Wildenhain

unread,
Apr 18, 2009, 6:49:05 PM4/18/09
to baykus, pytho...@python.org
baykus wrote:
> Hi
>
> I am looking for one of those experimental languages that might be
> combination of python+basic. Now thta sounds weird and awkward I know.
> The reason I am asking is that I always liked how I could reference-
> call certain line number back in the days. It would be interesting to

> get similar functionality in Python.

Apart from the fact that there are basic dialects w/o linenumbers
as all, what would it buy you? Keep in mind that if you edit blocks,
linenumbers can shift (or you end up starting with 10 spaced numbering
and then put lines inbetween).

Anyway, do you have any example of what you would do in such a
hypothetical language?

Tino.

JanC

unread,
Apr 18, 2009, 8:43:31 PM4/18/09
to
Stef Mientki wrote:

> BJörn Lindqvist wrote:
>> SCREEN 13
>> PSET 160,100,255
>
> Maybe, who is able to understand such nosense without a lot of apriori
> knowledge ?

You already needed that sort of knowledge to be able to use a computer back
then... ;-)


--
JanC

Zaphod

unread,
Apr 19, 2009, 1:08:32 AM4/19/09
to
On Fri, 17 Apr 2009 16:07:10 -0600, Michael Torrie wrote:

> Aahz wrote:
>> Why do you want to do that? Before you answer, make sure to read this:
>>
> http://www.u.arizona.edu/~rubinson/copyright_violations/
Go_To_Considered_Harmful.html
>
> Somebody better tell the Linux kernel developers about that! They
> apparently haven't read that yet. Better tell CPU makers too. In
> assembly it's all gotos.

Well, most of the Linux kernel is written in C and while there *is* a
jump (often JMP) in most asms, you should only do so if you really need
to. JSR (jump sub routine) is a better idea in many (most?) cases. You
can write really nice structured assembly just as you can with most
languages - depending on the assembly language, platform, etc. GOTO is
still generally a bad idea, and most of the people that use it can't tell
the difference between a good and a bad time to use it.

Friend of mine made a really nice asm development environment for his
home made OS. Too bad he didn't have any marketing skills.

Tim Wintle

unread,
Apr 19, 2009, 1:33:23 AM4/19/09
to pytho...@python.org
On Sun, 2009-04-19 at 05:08 +0000, Zaphod wrote:
> Well, most of the Linux kernel is written in C and while there *is* a
> jump (often JMP) in most asms, you should only do so if you really
> need
> to. JSR (jump sub routine) is a better idea in many (most?) cases.

Have to say that I feel jump is more than justified in some situations
(when it's jumping to within 10-20 lines of the start position, and it's
a routine that needs to be highly optimised - I'm thinking tail
recursion etc.)

(btw, how come nobody has mentioned python bytecode? Most flow control
is jumps)

Tim Wintle

Steven D'Aprano

unread,
Apr 19, 2009, 2:26:00 AM4/19/09
to


I wrote yesterday:

"GOTO, after all, is just a jump, and we use jumps in Python all the time:

raise Exception
break
continue
if... elif... else...
for... else...
etc."


--
Steven

Hendrik van Rooyen

unread,
Apr 19, 2009, 3:18:08 AM4/19/09
to pytho...@python.org
"Steven D'Aprano" <steveource.com.au> wrote:

COMEFROM on the other hand is just the purest evil imaginable.

*grin* - I expect you say this because it is a bit like COBOL's
alter - you cannot *see* it in place when you read the code, and
the effect is only apparent at run time after the distant statement
has been executed.

Kind of fun...

- Hendrik


Hendrik van Rooyen

unread,
Apr 19, 2009, 4:05:54 AM4/19/09
to pytho...@python.org
"Aaron Brady" <casti...pi@gmail.com> wrote:


On Apr 18, 4:44 am, "Hendrik van Rooyen" <m...@microcorp.co.za> wrote:

>> to untangle some spaghetti code. He did not mention if
>> the spaghetti was actually doing it's job, bug free, which
>> IMO is the only rational test for the quality of a piece
>
>I don't use 'rational' in the same way. Do you mean objective? Do
>readability, brevity, simplicity, purity, etc. contribute to quality?
>Is program quality equivalent (or identical) to code quality?

This paragraph illustrates the problem, I think:

Is there a significant difference between "rational" and "objective"?
Define "readability, brevity, simplicity, purity, etc" as applied
to the quality of a programme - it leads, inevitably, to a floundering
around in a wash of words.

However, to stop playing Devil's Advocate, there is such a thing
as code quality, but it cannot be defined, just like quality in general
terms cannot be defined - as soon as you try, it turns to dross in
your hands. Read Robert Pfirsig's "Zen and the art of motorcycle
maintenance" for a full explanation of this effect.

>> I do not agree with the reasoning that effectively says:
>> "If it is difficult to comprehend, it must be wrong"
>
>Wrong no, but impractical, possibly or probably or almost certainly,
>notwithstanding the subject-dependence of ease of comprehension.
>Simple code is more future-resilient than that which is difficult to
>comprehend, even holding the language (version) constant. It is a

I think that the emphasis on future proofing code is actually overrated.

We try to code as if we are building pyramids, for all time, but the sad
experience is that only a tiny percentage of application code written has
a life of longer than about eight years.

8<------------------------------

>that of exploration, pioneering, research, and development. However,
>even in simplest terms, some structures e.g. recursion, may be
>difficult to comprehend, but that doesn't mean they would be better
>more complicated.

This is true - the one does not imply the other, but the subtlety is that
it cuts either way - not more complicated, and not more simple. One
has to strike a balance, and this is closer to an art than a science.
That said, however, throwing out the goto ( or even the more intriguing
comefrom ) is forcing the artist to paint while removing an element from
his palette - he has to work around the lack.

- Hendrik

Hendrik van Rooyen

unread,
Apr 19, 2009, 4:09:47 AM4/19/09
to pytho...@python.org
"BJörn Lindqvist" <bj...@gmail.com> wrote:

>I can somewhat sympathise with the op, neither python nor any other
>mainstream language can still do this:
>
>SCREEN 13
>PSET 160,100,255

Oh come on! Don't be like that!
Tell us what it does, please.

- Hendrik

Hendrik van Rooyen

unread,
Apr 19, 2009, 4:35:27 AM4/19/09
to Brian Blais, pytho...@python.org
Brian Blais wrote:

>On Apr 18, 2009, at 5:44 , Hendrik van Rooyen wrote:

>>to untangle some spaghetti code. He did not mention if
>>the spaghetti was actually doing it's job, bug free, which
>>IMO is the only rational test for the quality of a piece

>>of code, because it is the reason for its existence.

>>The aesthetics are, like all aesthetics, a matter of opinion.
>
>

>Actually, I strongly disagree with this statement.
>In my experience, there has been very very few
>pieces of code that I've written that I hadn't wanted
>to *modify* at some point: extend it to a new set of
>circumstances, cover a different case, change the
>output, etc... The quality of a piece of code is not just
>if it works right now, but if you can reasonably extend
>it for the future.

Your experience is different from mine - in what I mostly
do, which is struggling around in embedded assembler,
by the time the thing "works" it is stable, and I very
seldom have to go back to fiddle with it.

On the other hand, I understand what you are talking about,
but I think that the origen of the frustration that one feels
when having to battle with some old code, is actually inside
oneself - the code is the same, but I have changed, and I am
no longer the same as I was when I wrote it.

>I toyed with Perl for a year or so, but couldn't give it
>my full attention. As a result, every few weeks when I
>wanted to modify what I wrote, I had to re-learn the
>code all over again because the syntax was so terse.
>The same is true for the typical use of a goto: you have
>to relearn the program, because the flow jumps around.
>It's not just about aesthetics, but about being able to
>work with a piece of code.

In my defense of the goto, I would like to make clear
that I do not support its use to produce spaghetti.
In general, muddled thinking, coupled with expediency,
is what I think are the true precursors of spaghetti code.
The goto is an innocent tool that can be used for good
or evil.

- Hendrik


Hendrik van Rooyen

unread,
Apr 19, 2009, 4:51:15 AM4/19/09
to pytho...@python.org
"Mensanator" <mens..r@aol.com> wrote:

8< ---------- description of bugs in spaghetti ---------------

Looks like that design really needed sorting out!

>A programmer once said to me "Why should I run it, I know
>how it works, I wrote it."

Are you serious?
In my opinion, anybody who says this is not a programmer,
but merely an arrogant idiot with a lot of misplaced self-
confidence - somewhat like a permanent force corporal.

>
>My reply: "You only THINK you know how it works. _I_, on
>the other hand, ACTUALLY know how it works because I've
>run it."

How did you manage to keep your reply so meek?
You must be a really well brought up person.
:-)

- Hendrik


Krishnakant

unread,
Apr 19, 2009, 7:16:15 AM4/19/09
to pytho...@python.org
Hello all,
Right now I am a bit confused on a final stage of my project.

I need to create an installer and an executable file for my python
program for gnu/linux.

The install script has to put the package into site-packages folder
where all other libraries reside. Then put the executable file
into /usr/bin as other files.

The installer must also do the basic task of creating the database and
setting up password for on postgresql.
now here comes the main problem.
I believe putting files into proper places is pritty easy (may be some
one will instantly reply to the issue of putting the executable file and
libraries in place ). But to do the database based activities, I need
python-psycopg2 module for postgresql in the first place. So is it
possible for python to self download and install all the necessary
modules on to the client machine?

What further complicates the system is the fact that I want in future to
create 2 deb files, one for installing the gtk based client application
and the other to install the server side app made in python-twisted for
rpc. Now the obvious problem is that first my python installation
(either 2.5 or 2.4) must check for itself if the modules are present or
not and if they are not present, my install utility must either download
it from net or if that's not the recommended approach then compile the
module from the source.

how do I achieve all this in python?
I know bash could be used to do such things but I don't want to use bash
because it is to clunky and won't run easily on windows.
Moreover I want to create a deb file as I said before so I want to keep
it as simple as possible.

Even regarding the executable, I am confused on using bash as the script
for writing the executable which can then do some thing like python -c
and call the modules, or write this executable code in a main.py and put
that file into the executable path i.e /usr/bin.

Please clear this mater so that I can go ahead.

I know the python list is pritty busy and I must thank all the members
who keep the spirit of the community and the professional organisations
alive so may be I will get a solution to my problem soon.

happy hacking.
Krishnakant.


Tim Wintle

unread,
Apr 19, 2009, 8:44:46 AM4/19/09
to Steven D'Aprano, pytho...@python.org
On Sun, 2009-04-19 at 06:26 +0000, Steven D'Aprano wrote:
> > (btw, how come nobody has mentioned python bytecode? Most flow
> control is jumps)
>
>
> I wrote yesterday:
>
> "GOTO, after all, is just a jump, and we use jumps in Python all the
> time:
>
> raise Exception
> break
> continue
> if... elif... else...
> for... else...
> etc."

Ah - apologies

Tim

News123

unread,
Apr 19, 2009, 8:50:20 AM4/19/09
to
Hi,

I think you got lost in the wrong thread.
Though your subject line is correct your post threads under "Is there a
programming language, that . . . "

Perhaps you 'replied' to above thread and changed 'just' the subject line.

Chances to get an answer might be higher if you repost your question
without replying to an existing thread.

D'Arcy J.M. Cain

unread,
Apr 19, 2009, 9:09:07 AM4/19/09
to Zaphod, pytho...@python.org
On Sun, 19 Apr 2009 05:08:32 GMT
Zaphod <zap...@beeblebrox.net> wrote:
> Friend of mine made a really nice asm development environment for his
> home made OS. Too bad he didn't have any marketing skills.

Was your friend's name Gary Kildall? :-)

Tim Hoffman

unread,
Apr 19, 2009, 9:14:21 AM4/19/09
to
I started my commercial programming in Business Basic, (actually MAI
Basic 4, and it's equivalent on primos (can't think of it's name at
the moment) then later BBX (Basis)

We ran the same code (all development on MAI, and then translated the
few differences programatically between MAI and Prime) and moved the
code via 1/4" tape to prime.

This was general ledger, policy and claims systems for an Insurance
Broker, we had about 300 + users on the two machines running over a
wide area serial network)

Then we moved to BBX on Unix.

Whilst we had goto, no such thing as string arrays (until BBX) etc....
we really formally codified all of our devlopment standards, such that
even line number ranges where for specific tasks (we had a limit of
64K per program, 1 - 9999 for line numbers) and all initialisation had
to be in lines 1000 - 1099. We where only allowed to use goto within
a routine and only as a last resort,. We could only have one return
from a gosub, etc..... on mai we could only have two letter or letter
and digit variable names and they where global for the probram
so if you wanted loop local, or subroutine variables you could safely
use then x[1-9] and y[1-9]
where safe, all initialisation setup use i[1-9] etc ....

There where 3 programmers and we had to peer review everything.

We built rock solid systems, if I say so myself ;-)

You can write well structured and easily understood code in any
language, it just takes more discipline in some environments more than
others.

Having said that I would hate to go back to it from Python ;-)

See ya

T

On Apr 18, 4:52 am, a...@pythoncraft.com (Aahz) wrote:
> In article <f222fcd3-56a4-4b2f-9bf8-3c9c17664...@e18g2000yqo.googlegroups.com>,


>
> baykus  <baykusde...@gmail.com> wrote:
>
> >I am looking for one of those experimental languages that might be
> >combination of python+basic. Now thta sounds weird and awkward I know.
> >The reason I am asking is that I always liked how I could reference-
> >call certain line number back in the days. It would be interesting to
> >get similar functionality in Python.
>

> Why do you want to do that?  Before you answer, make sure to read this:
>

> http://www.u.arizona.edu/~rubinson/copyright_violations/Go_To_Conside...
> --
> Aahz (a...@pythoncraft.com)           <*>        http://www.pythoncraft.com/

Krishnakant

unread,
Apr 19, 2009, 9:15:23 AM4/19/09
to News123, pytho...@python.org

sorry, but I was not replying to another thread.

My mistake.

happy hacking.
Krishnakant.

Aaron Brady

unread,
Apr 19, 2009, 9:34:09 AM4/19/09
to
On Apr 19, 3:05 am, "Hendrik van Rooyen" <m...@microcorp.co.za> wrote:

>  "Aaron Brady" <casti.....@gmail.com> wrote:
>
> On Apr 18, 4:44 am, "Hendrik van Rooyen" <m...@microcorp.co.za> wrote:
>
> >> to untangle some spaghetti code. He did not mention if
> >> the spaghetti was actually doing it's job, bug free, which
> >> IMO is the only rational test for the quality of a piece
>
> >I don't use 'rational' in the same way.  Do you mean objective?  Do
> >readability, brevity, simplicity, purity, etc. contribute to quality?
> >Is program quality equivalent (or identical) to code quality?
>
> This paragraph illustrates the problem, I think:
>
> Is there a significant difference between "rational" and "objective"?
> Define "readability, brevity, simplicity, purity, etc" as applied
> to the quality of a programme - it leads, inevitably, to a floundering
> around in a wash of words.

It is an old philosopher's problem, that is, a problem of old
philosophers: do all rational wo/men behave the same given the same
situations, or more specifically, analogously given related
situations?

Rational and objective are related, I think. An objective test of
code would be a process anyone can follow and derive the same result,
such as how many identifiers it contains. A rational test involves
some sort of abstraction of humans, such as what the ultimately
rational human likes most, etc. Objective partial credit on an exam,
for example, must come from a black-and-white rubric with exactly no
room for interpretation. Rational partial credit could involve
inferences, guesses, and context, esp. acquaintance with the taker.

I agree that many of those traits are matters of degree and multi-
dimensional. I am looking for an objective metric of code: code X has
traits P, Q, and R. Period. It would probably be simpler to start
describing code objectively, rather than trying to square-peg-round-
hole existing words. However, there may be no objective test of
especially large sizes of code, and may fall to some sort of
interpretation or assessment of the most rational wo/man.

If I disagree with your measuring of a code with objective criteria,
we merely walk through the measurement, and resolve our disagreement
from the criteria upon discovering it. If I disagree with your
measuring of it with rational criteria, we have to take into account
all sorts of trade-offs, such as long-short term, one-many readers,
different consequences, etc. I'm speculating a little bit in defining
those words.

I advance that two equifunctional programs (same input-> same output)
can be compared w.r.t. brevity, to take an example, up to isomorphism
of identifier names, control structures, and statement order. That
is, we can determine how brief code X is, disregarding identifier
names, and statement order where irrelevant. Control structure
brevity might be something we're trying to measure:

while 1:
if cond(): break

while not cond():
...

Are these equally brief, assuming they accomplish the same thing? If
we don't have unanimous agreement on the answer to that question, we
must conclude that even brevity is a composite trait and we'll have to
start simpler. A theory of traits would have to make concrete
predictions about *something*. If some code has trait P, it will Q.

> However, to stop playing Devil's Advocate, there is such a thing
> as code quality, but it cannot be defined, just like quality in general
> terms cannot be defined - as soon as you try, it turns to dross in
> your hands.  Read Robert Pfirsig's "Zen and the art of motorcycle
> maintenance" for a full explanation of this effect.

Are you saying that quality reduces to how pleasant a particular
reader, or composite of multiple readers, finds the code?

"In the 1960s, programmers gave goto statements an average rating of 6
out of 10, 10 being most pleasing. In the 70s, that rating dropped to
5 out of 10. Subroutines were initially disliked, but came to be
favored, advancing from 4/10 in the 60s to 7/10 in the 80s and on.
Possible confounding variables include the increase in processor speed
and thus the increased forgivingness of running time of gosubs; the
prevalence of languages capable of generating subroutine calls; and
the efficiency of the particular calls generated, surveys of which
were not attempted." --Fabrication

> >> I do not agree with the reasoning that effectively says:
> >> "If it is difficult to comprehend, it must be wrong"
>
> >Wrong no, but impractical, possibly or probably or almost certainly,
> >notwithstanding the subject-dependence of ease of comprehension.
> >Simple code is more future-resilient than that which is difficult to
> >comprehend, even holding the language (version) constant.  It is a
>
> I think that the emphasis on future proofing code is actually overrated.
>
> We try to code as if we are building pyramids, for all time, but the sad
> experience is that only a tiny percentage of application code written has
> a life of longer than about eight years.

Project managers should, I judge, be versed in the trade-offs between
time spent now and time saved later, especially even before a release
date! That is, for arbitrary unforeseen additional requirement Q, how
much time will it take to add it from path A, vs. from path B? This
is a sophisticated judgment call, and possibly as much as mostly
guesswork. I don't know.

> 8<------------------------------
>
> >that of exploration, pioneering, research, and development.  However,
> >even in simplest terms, some structures e.g. recursion, may be
> >difficult to comprehend, but that doesn't mean they would be better
> >more complicated.
>
> This is true - the one does not imply the other, but the subtlety is that
> it cuts either way - not more complicated, and not more simple.

A 'simpler than' relation should be transitive if it's to be
objective. The simplest recursive solution and the simplest iterative
solution would make a good comparison. If the 'simplicity of'
predicate is not defined over the entire set of code, I hold it's not
objective. 'X not simpler than Y && Y not simpler than X' should
imply that 'simplicity( X ) == simplicity( Y )'. However, it needn't
imply that X==Y, and neighboring trait priorities could diverge.

> One
> has to strike a balance, and this is closer to an art than a science.
> That said, however, throwing out the goto ( or even the more intriguing
> comefrom ) is forcing the artist to paint while removing an element from
> his palette - he has to work around the lack.
>
> - Hendrik

I think there could be any amount of beautiful but useless code. But
we're (uh... for some value of 'we'... heh heh) trying to measure the
utility of a piece, IBNLT including but not limited to its future
value or value elsewhere, that is its /re/usability.

The decision to exclude 'goto' from Pythoneers' tools, or blue from a
some artists' palettes, has unifying effects, such as creating a
"secret club" mentality. It also may have pedagogical value, such as
making the language easier to learn for many or most. "Beginners
always abuse blue hues, so we won't include them in our kits." (I
would have to perform the study that proves it however, or like or
trust the agency that makes the claim, in order to consider it in my
decision to acquire Python as a language.) Its disadvantages include
a lower ceiling on program efficiency, as well as a shade of brevity.
Other claims about utility, such as clarity and reusability, which are
such, I hold, have yet to be proven.

Krishnakant

unread,
Apr 19, 2009, 9:55:08 AM4/19/09
to News123, pytho...@python.org
hi very sorry for that

On Sun, 2009-04-19 at 14:50 +0200, News123 wrote:
> Hi,
>
> I think you got lost in the wrong thread.
> Though your subject line is correct your post threads under "Is there a
> programming language, that . . . "
>
> Perhaps you 'replied' to above thread and changed 'just' the subject line.
>
> Chances to get an answer might be higher if you repost your question
> without replying to an existing thread.

> I did not mean to do so, may be just missed out on removing the lines of the previous thread.

sorry again.
I hope this becomes a new thread now and I get some productive reply.
happy hacking.
Krishnakant.


Chris Jones

unread,
Apr 19, 2009, 10:54:18 AM4/19/09
to pytho...@python.org
On Sun, Apr 19, 2009 at 09:55:08AM EDT, Krishnakant wrote:
> hi very sorry for that
>
> On Sun, 2009-04-19 at 14:50 +0200, News123 wrote:
> > Hi,
> >
> > I think you got lost in the wrong thread.
> > Though your subject line is correct your post threads under "Is there a
> > programming language, that . . . "
> >
> > Perhaps you 'replied' to above thread and changed 'just' the subject line.
> >
> > Chances to get an answer might be higher if you repost your question
> > without replying to an existing thread.
> > I did not mean to do so, may be just missed out on removing the lines of the previous thread.
>
> sorry again.
> I hope this becomes a new thread now and I get some productive reply.
> happy hacking.
> Krishnakant.

No big deal, mature mailers such as mutt let you break threads into
subthreads via a painless "Alt-B".

CJ

Scott David Daniels

unread,
Apr 19, 2009, 11:12:20 AM4/19/09
to

Possibly because the proper reply was probably, "You only THINK
you know how it works. _I_, on the other hand, know how it behaves,
even if I don't know how it was supposed to work."

--Scott David Daniels
Scott....@Acm.Org

Scott David Daniels

unread,
Apr 19, 2009, 11:21:05 AM4/19/09
to
Hendrik van Rooyen wrote:
> In my defense of the goto, I would like to make clear
> that I do not support its use to produce spaghetti.
> In general, muddled thinking, coupled with expediency,
> is what I think are the true precursors of spaghetti code.
> The goto is an innocent tool that can be used for good
> or evil.

The goto is a sharp, spiky dangerous tool that seduces
people into thinking of using it far too often. It should
be used with the same respect you approach beautiful well-
armed people of questionable morals who you find attractive.

--Scott David Daniels
Scott....@Acm.Org

Chris Jones

unread,
Apr 19, 2009, 12:03:02 PM4/19/09
to pytho...@python.org
On Sun, Apr 19, 2009 at 04:35:27AM EDT, Hendrik van Rooyen wrote:
> Brian Blais wrote:
>
> >On Apr 18, 2009, at 5:44 , Hendrik van Rooyen wrote:

> >>to untangle some spaghetti code. He did not mention if the
> >>spaghetti was actually doing it's job, bug free, which IMO is the

> >>only rational test for the quality of a piece of code, because it is


> >>the reason for its existence. The aesthetics are, like all
> >>aesthetics, a matter of opinion.

> >Actually, I strongly disagree with this statement. In my experience,
> >there has been very very few pieces of code that I've written that I
> >hadn't wanted to *modify* at some point: extend it to a new set of
> >circumstances, cover a different case, change the output, etc...
> >The quality of a piece of code is not just if it works right now,
> >but if you can reasonably extend it for the future.

+1 .. obfuscated code never remains bug-free for long.

> Your experience is different from mine - in what I mostly do, which is
> struggling around in embedded assembler, by the time the thing "works"
> it is stable, and I very seldom have to go back to fiddle with it.

Intellectually, assembler programming is the less demanding since its
level of abstraction does not go any further than mapping a few binary
numbers to a small set of usually well-chosen mnemonics.

Unless it features a powerful macro-language that lets the apprentice
create his own high-level patois on top of the assembler, that is.

> On the other hand, I understand what you are talking about, but I
> think that the origen of the frustration that one feels when having to
> battle with some old code, is actually inside oneself - the code is
> the same, but I have changed, and I am no longer the same as I was
> when I wrote it.

> >I toyed with Perl for a year or so, but couldn't give it my full
> >attention. As a result, every few weeks when I wanted to modify what
> >I wrote, I had to re-learn the code all over again because the syntax
> >was so terse. The same is true for the typical use of a goto: you
> >have to relearn the program, because the flow jumps around. It's not
> >just about aesthetics, but about being able to work with a piece of
> >code.

> In my defense of the goto, I would like to make clear that I do not


> support its use to produce spaghetti. In general, muddled thinking,
> coupled with expediency, is what I think are the true precursors of
> spaghetti code. The goto is an innocent tool that can be used for
> good or evil.

How true.

At least goto's have the merit of naming their target.

I have dealt with C code built on the original author's partiality for
200-line+ nested loops where it looked like every other line or so was
either a "break" or a "continue", goto's without the name that don't
clearly state where they are going.

Thank goodness he was not familiar with setjmp/longjmp.

:-)

CJ

MRAB

unread,
Apr 19, 2009, 12:11:41 PM4/19/09
to pytho...@python.org
Chris Jones wrote:
> On Sun, Apr 19, 2009 at 04:35:27AM EDT, Hendrik van Rooyen wrote:
>> Brian Blais wrote:
>>
[snip]

>> In my defense of the goto, I would like to make clear that I do not
>> support its use to produce spaghetti. In general, muddled thinking,
>> coupled with expediency, is what I think are the true precursors of
>> spaghetti code. The goto is an innocent tool that can be used for
>> good or evil.
>
> How true.
>
> At least goto's have the merit of naming their target.
>
Except in (classic) Pascal where they are unsigned integers (they still
need to be declared).

Mensanator

unread,
Apr 19, 2009, 12:43:06 PM4/19/09
to
On Apr 19, 3:51�am, "Hendrik van Rooyen" <m...@microcorp.co.za> wrote:

> "Mensanator" <mens...@aol.com> wrote:
>
> 8< ---------- description of bugs in spaghetti ---------------
>
> Looks like that design really needed sorting out!

Since I was translating to Pascal, I couldn't
emulate that code if I wanted to.

>
> >A programmer once said to me "Why should I run it, I know
> >how it works, I wrote it."
>
> Are you serious?

Absolutely.

> In my opinion, anybody who says this is not a programmer,
> but merely an arrogant idiot with a lot of misplaced self-
> confidence - somewhat like a permanent force corporal.

That might have contributed to the reason why we
din't sell too many systems.

The last product developed ran on an IBM RISC PC
using the PICK operating system. We sold nearly one.

>
>
>
> >My reply: "You only THINK you know how it works. _I_, on
> >the other hand, ACTUALLY know how it works because I've
> >run it."
>
> How did you manage to keep your reply so meek?

He got paid more than I did.

> You must be a really well brought up person.
> :-)

But not behind their backs. A program I created that
tested anuther programmer's attempt at making a hash
table was labeled HASHIT.

Said programmer was long gone when the customer called
and wanted to know why his 10000 record database was
saying it was full when only 3000 employees had been
entered. Turned out that the hashing algorithm could
not access any more than 3000 of the 10000 available
records. This isn't the kind of thing Field Service
is supposed to have to deal with.

>
> - Hendrik

Mensanator

unread,
Apr 19, 2009, 12:45:22 PM4/19/09
to
On Apr 19, 10:12�am, Scott David Daniels <Scott.Dani...@Acm.Org>
wrote:
> Hendrik van Rooyen wrote:

Probably more accurate as his .exe file crashed
immediately when executed. That's what lead me to
supect he never ran it.

>
> --Scott David Daniels
> Scott.Dani...@Acm.Org

Zaphod

unread,
Apr 19, 2009, 1:11:03 PM4/19/09
to
On Sun, 19 Apr 2009 09:09:07 -0400, D'Arcy J.M. Cain wrote:

> On Sun, 19 Apr 2009 05:08:32 GMT
> Zaphod <zap...@beeblebrox.net> wrote:
>> Friend of mine made a really nice asm development environment for his
>> home made OS. Too bad he didn't have any marketing skills.
>
> Was your friend's name Gary Kildall? :-)

Nope - Craig Carmichael. The OS was originally called OMEN but later
changed to Oases and was initially designed to run on 68k based
machines. Craig just loves 68k assembly - less hair pulling required
than x86.

Gabriel Genellina

unread,
Apr 19, 2009, 1:55:09 PM4/19/09
to pytho...@python.org
En Sun, 19 Apr 2009 08:16:15 -0300, Krishnakant <hack...@gmail.com>
escribió:

> I need to create an installer and an executable file for my python
> program for gnu/linux.
>
> The install script has to put the package into site-packages folder
> where all other libraries reside. Then put the executable file
> into /usr/bin as other files.

Write a setup.py script using the distutils package:
http://docs.python.org/distutils/index.html

> I believe putting files into proper places is pritty easy (may be some
> one will instantly reply to the issue of putting the executable file and
> libraries in place ). But to do the database based activities, I need
> python-psycopg2 module for postgresql in the first place. So is it
> possible for python to self download and install all the necessary
> modules on to the client machine?

You said you want to create a .deb -- list the required dependencies there.

> Even regarding the executable, I am confused on using bash as the script
> for writing the executable which can then do some thing like python -c
> and call the modules, or write this executable code in a main.py and put
> that file into the executable path i.e /usr/bin.

I've seen both a bash script with a single line: python path/to/main.py,
and a Python script that just imports some modules and then calls the main
function. Perhaps bash is more useful if your program (or any library)
requires some environment variables to be set.

--
Gabriel Genellina

Scott David Daniels

unread,
Apr 19, 2009, 2:25:25 PM4/19/09
to
Chris Jones wrote:
> ...

> Intellectually, assembler programming is the less demanding since its
> level of abstraction does not go any further than mapping a few binary
> numbers to a small set of usually well-chosen mnemonics.
>
> Unless it features a powerful macro-language that lets the apprentice
> create his own high-level patois on top of the assembler, that is.

No, I've dealt with an assembler named 'SLOE' that had an elaborate
mechanism for laying out code in memory in a way that the CPU would
be happy with. Between that and the instruction prefect, the thing
was famously called "immune to programming."

--Scott David Daniels
Scott....@Acm.Org

Message has been deleted

Krishnakant

unread,
Apr 19, 2009, 5:40:58 PM4/19/09
to Gabriel Genellina, pytho...@python.org
On Sun, 2009-04-19 at 14:55 -0300, Gabriel Genellina wrote:

> Write a setup.py script using the distutils package:
> http://docs.python.org/distutils/index.html
>

So that can distutil do the work of setting up the database and can it
find for itself if psycopg2 and other related libraries are installed?
I am going to create a deb file, so is it a good idea to some how have
the deb rules execute the setup.py file of the distutils?

Besides, I will also like to create a single file containing all the
modules i need as dependencies so even if a user does not have internet,
we can still install the package on that machine.

So will it be a good idea to let distutils do every thing I had
described about putting files in the place and having the script copyed
to /usr/bin etc?

happy hacking.
Krishnakant.


Tim Rowe

unread,
Apr 19, 2009, 6:23:03 PM4/19/09
to pytho...@python.org
2009/4/19 Steven D'Aprano <st...@remove-this-cybersource.com.au>:

> "GOTO, after all, is just a jump, and we use jumps in Python all the time:
>
> raise Exception
> break
> continue
> if... elif... else...
> for... else...
> etc."

So as a syllogism:
P1: GOTO is a jump;
P2: GOTO is bad.
C: Jumps are bad.

And then by showing the conclusion is false, you believe you have
shown a contradiction? Try looking up "Affirming the consequent"!

GOTO is an /unstructured/ jump. Raise, break, continue, if, for and so
an are all /structured/ jumps.

--
Tim Rowe

Steven D'Aprano

unread,
Apr 19, 2009, 7:51:51 PM4/19/09
to
On Sun, 19 Apr 2009 23:23:03 +0100, Tim Rowe wrote:

> 2009/4/19 Steven D'Aprano <st...@remove-this-cybersource.com.au>:
>
>> "GOTO, after all, is just a jump, and we use jumps in Python all the
>> time:
>>
>> raise Exception
>> break
>> continue
>> if... elif... else...
>> for... else...
>> etc."
>
> So as a syllogism:
> P1: GOTO is a jump;
> P2: GOTO is bad.
> C: Jumps are bad.
>
> And then by showing the conclusion is false, you believe you have shown
> a contradiction? Try looking up "Affirming the consequent"!

Sheesh. Talk about cherry-picking data. Go read my post in it's entirety,
instead of quoting mining out of context. If you still think I'm unaware
of the difference between unstructured GOTOs and structured jumps, or
that I'm defending unstructured GOTOs, then you might have something
useful to contribute.

--
Steven

Gabriel Genellina

unread,
Apr 20, 2009, 1:36:53 AM4/20/09
to pytho...@python.org
En Sun, 19 Apr 2009 18:40:58 -0300, Krishnakant <hack...@gmail.com>
escribió:

> On Sun, 2009-04-19 at 14:55 -0300, Gabriel Genellina wrote:
>
>> Write a setup.py script using the distutils package:
>> http://docs.python.org/distutils/index.html
>>
> So that can distutil do the work of setting up the database and can it
> find for itself if psycopg2 and other related libraries are installed?
> I am going to create a deb file, so is it a good idea to some how have
> the deb rules execute the setup.py file of the distutils?

There are many concerns here:

Database: setup.py can do whatever you want, it's a Python script (it
*uses* Distutils as a library, not the other way around). So you could
create the database there. (Some applications do that on the first run,
when they detect there is none)

Dependencies: If all your dependencies are available as Debian packages,
just let dpkg handle them. You only have to enumerate the required
dependencies in the control file.

rules: the rules file will refer to a Makefile where you map the actions
("build", "install") to the corresponding arguments to setup.py

From the last point, it's better to start writing a setup.py that works --
at least, test building a source distribution. Then, add your special
actions (like creating the initial database). The last step would be to
add the required Debian files to create a .deb

There are several tutorials on making a .deb out of Python programs -
google for them.

> Besides, I will also like to create a single file containing all the
> modules i need as dependencies so even if a user does not have internet,
> we can still install the package on that machine.

Isn't enough to distribute all the required packages?

> So will it be a good idea to let distutils do every thing I had
> described about putting files in the place and having the script copyed
> to /usr/bin etc?

You don't *let* distutils do that, you *use* distutils in order to do that.

--
Gabriel Genellina

Hendrik van Rooyen

unread,
Apr 20, 2009, 4:05:11 AM4/20/09
to pytho...@python.org
"Chris Jones" <cjns...@gmail.com> wrote:

> Intellectually, assembler programming is the less demanding since its
> level of abstraction does not go any further than mapping a few binary
> numbers to a small set of usually well-chosen mnemonics.

This is the surface complexity - it is true that when you write an assembler
statement, you know exactly *what* it is going to do. The *why*, however,
is not always as obvious, as it entails keeping far more *registers and memory
locations* alive in your mind as you go - and the temptation is great, for
efficiency's sake, to let a series of calls leave their answers *in place*,
ready
for the next call to use:

call this
jc error_handling
call that
jc error_handling
call thenextthing
jc error_handling
...

This kind of thing is in a way worse than spaghetti, and it is about
the hardest thing to understand that I know of. It is also fragile,
as you are never sure if you change something, no matter how well
documented your individual routines are, what the effect of a change
somewhere will have somewhere further down the line, as the
parameters are not explicitly named before the calls. I find higher
level languages a lot easier to read because of this.

You can do the same kind of thing in Python, using globals, and if
there are enough of them, it will be just as hard to follow.

> Unless it features a powerful macro-language that lets the apprentice
> create his own high-level patois on top of the assembler, that is.

This is the fun part of assembly programming - and here again, one
has to exercise restraint, or the "language" becomes baroque.
Used correctly, however, it allows you to generate a lot of
required boilerplate with very few keystrokes.

It is also very useful to create application specific virtual machines
with specialised *instruction sets* which can make solving some
problems a lot easier. - and that is a level of abstraction that is
in a sense orthogonal to the levels of abstraction brought to the
party by a high level language that has a simple von Neumann
machine as it's base assumption.

- Hendrik


Marco Mariani

unread,
Apr 20, 2009, 4:55:23 AM4/20/09
to
Michael Torrie wrote:

> http://www.u.arizona.edu/~rubinson/copyright_violations/Go_To_Considered_Harmful.html
>
> Somebody better tell the Linux kernel developers about that! They
> apparently haven't read that yet. Better tell CPU makers too. In
> assembly it's all gotos.


I'm sure you are joking.
Using goto for error handling in C is a reasonable practice,
Avoiding that for the sake of it would be like, say, avoiding "raise" in
python because "a procedure should only have one exit point".

Marco Mariani

unread,
Apr 20, 2009, 5:01:27 AM4/20/09
to
baykus wrote:

> those "lines" as numbered steps or numbered bricks that are sitting on
> eachother but I see them as timelines or like filmstrips. Anyways it
> sounds like such a toy programming language does not exists except
> Arnaud surprisingly efficient code. and I will search my dream
> somewhere else :)

Actually, your dreams have already been implemented in Python.

As an april fool's joke. Really.

It works, but is so silly and depraved that I'm not going to provide a link.

Tim Rowe

unread,
Apr 20, 2009, 8:06:35 AM4/20/09
to Steven D'Aprano, pytho...@python.org
2009/4/20 Steven D'Aprano <st...@remove-this-cybersource.com.au>:

> Sheesh. Talk about cherry-picking data. Go read my post in it's entirety,
> instead of quoting mining out of context. If you still think I'm unaware
> of the difference between unstructured GOTOs and structured jumps, or
> that I'm defending unstructured GOTOs, then you might have something
> useful to contribute.

I wasn't cherry picking data, and I did read the entire post. However,
looking back through the message base I see that exactly the same text
appears in another posting by you, and the /other/ post makes it clear
that you know the difference. Sorry for the confusion.

--
Tim Rowe

david

unread,
Apr 20, 2009, 8:34:18 AM4/20/09
to
When I was at Data General, writing C (and a little C++), we had a set
of internal coding conventions that mandated a single return point for
a function. Goto's were used during error checks to branch to the
function exit; something like this:

int
frodo() {
int rval = 0;

if (bilbo() != 0) {
rval = -1;
goto leave;
}

if (gandalf() != 0) {
rval = -1;
goto leave;
}

/* lot's of code here */

leave:
return rval;
}

Made sense to me.

-- david

Tim Rowe

unread,
Apr 20, 2009, 9:52:28 AM4/20/09
to pytho...@python.org
2009/4/20 david <young...@gmail.com>:

> When I was at Data General, writing C (and a little C++), we had a set
> of internal coding conventions that mandated a single return point for
> a function.

How long ago was that? Or, more relevant, how old was the rule? Or how
long earlier had the person who wrote the rule learned their craft?
One reason for mandating single exit points was that early flow graph
reducers couldn't handle them, but, because of the GOTO equivalents
that you give, graphs with multiple exit points /are/ reducible
without the exponential blowup that node splitting can cause, so
they've been able to handle multiple exits for many years.

Of course, your code is equivalent to:

int
frodo() {
int rval = 0;

if (bilbo() != 0) rval = -1

else
{


if (gandalf() != 0) rval = -1

else
{
/* lots of code here */
}
}
return rval;
}

with not a GOTO in sight, and to my mind much clearer logic. If the
nesting meant that the indentation was marching off the side of the
page I'd refactor the "lots of code here" into an inline helper
function. And provided bilbo() and gandalf() don't have side effects,
I'd probably rewrite it as:

int
frodo()
{
int rval = 0;

if ((bilbo() == 0) || (gandalf() == 0)
{


/* lot's of code here */
}

else rval = -1;
return rval;
}

I'd be inclined to do it that way even if multiple exits were allowed;
it just seems so much clearer.

--
Tim Rowe

david

unread,
Apr 20, 2009, 10:54:40 AM4/20/09
to
I was at DG in the early nineties. A lot of very smart people devised
some of these conventions, from hard-earned experience in the kernel
and system-level software. I've never been one for "fascist-rules
documents", but in DG's case many of the rules made good sense. I'm
not advocating one approach over another; just wanted to show an
example where some careful thought went into the use of goto.

-- david

Rhodri James

unread,
Apr 20, 2009, 10:52:26 PM4/20/09
to pytho...@python.org

Similarly, TI's DSP products come with a very competant "linear
assembler" that puts you at one remove from the actual assembly
language. This allows it to re-order your code to take advantage of
sets of instructions that can be executed in parallel, shield you
from the fact that the results of some instructions take several
cycles to arrive, and do some wonderfully bizarre loop optimisations.
I have written hand-optimised assembly for those chips, but it's
not for the faint of heart.

--
Rhodri James *-* Wildebeeste Herder to the Masses

Ivan Illarionov

unread,
Apr 21, 2009, 6:37:38 AM4/21/09
to
On Apr 18, 3:39 pm, BJörn Lindqvist <bjou...@gmail.com> wrote:
> I first started programming basic and i don't think it has hurt me much.
>
> I can somewhat sympathise with the op, neither python nor any other
> mainstream language can still do this:
>
> SCREEN 13
> PSET 160,100,255

This is not true. It's trivial with pygame or equivalent SDL
bindings in other mainstream languages:

basic.py:
-------------------------------------------------------------------------------
import sys
import pygame

class BasicInterpreter:
def SCREEN(self, x):
self.surface = pygame.display.set_mode(
(320, 200), pygame.FULLSCREEN, 8)

def PSET(self, x, y, c):
self.surface.set_at((x, y), c)
pygame.display.flip()

if __name__ == '__main__' and len(sys.argv) > 1:
basic = BASIC()
with open(sys.argv[1]) as bas:
for line in bas:
eval("basic.%s(%s)" % tuple(x.strip() for x in line.split
(' ', 1)))
while True:
for event in pygame.event.get():
if event.type in (pygame.QUIT, pygame.KEYDOWN):
sys.exit(0)

-------------------------------------------------------------------------------

This will execute your BASIC program.

--
Ivan

Mensanator

unread,
Apr 21, 2009, 12:59:40 PM4/21/09
to
On Apr 21, 5:37 am, Ivan Illarionov <ivan.illario...@gmail.com> wrote:
> On Apr 18, 3:39 pm, BJörn Lindqvist <bjou...@gmail.com> wrote:
>
> > I first started programming basic and i don't think it has hurt me much.
>
> > I can somewhat sympathise with the op, neither python nor any other
> > mainstream language can still do this:
>
> > SCREEN 13
> > PSET 160,100,255
>
> This is not true. It's trivial with pygame or equivalent SDL
> bindings in other mainstream languages:
>
> basic.py:
> ---------------------------------------------------------------------------­----

> import sys
> import pygame
>
> class BasicInterpreter:
>     def SCREEN(self, x):
>         self.surface = pygame.display.set_mode(
>             (320, 200), pygame.FULLSCREEN, 8)
>
>     def PSET(self, x, y, c):
>         self.surface.set_at((x, y), c)
>         pygame.display.flip()
>
> if __name__ == '__main__' and len(sys.argv) > 1:
>     basic = BASIC()
>     with open(sys.argv[1]) as bas:
>         for line in bas:
>             eval("basic.%s(%s)" % tuple(x.strip() for x in line.split
> (' ', 1)))
>     while True:
>         for event in pygame.event.get():
>             if event.type in (pygame.QUIT, pygame.KEYDOWN):
>                 sys.exit(0)
>
> ---------------------------------------------------------------------------­----

>
> This will execute your BASIC program.

And you did it without Goto? Wow.

>
> --
> Ivan

0 new messages