Why Python is like C++

G

Gene Heskett

Doh, forgot momentarily that the 6502 had X, Y, and A, making THREE
registers. ooh, the luxury of 2-bit naming conventions! :-D

-tkc

And the HD63C09EP kicks them both clear out of the game. Too bad Hitachi is
to this day, contractually enjoined from even admitting that the new
registers it sports, or the new, much faster instructions it supports are
actually in the chip. Like how about a 32 bit value, divided by a 16 bit
value, 39 clocks worst case? In a supposedly 8 bit cpu. Lots of little
surprises in that 40 pin block of epoxy that was supposed to be a work-a-
like of the Motorola MC6809EP.

Cheers, Gene
--
"There are four boxes to be used in defense of liberty:
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
Genes Web page <http://geneslinuxbox.net:6309/gene>

Be cheerful while you are alive.
-- Phathotep, 24th Century B.C.
A pen in the hand of this president is far more
dangerous than 200 million guns in the hands of
law-abiding citizens.
 
T

Terry Reedy

On the last large C++ project I worked on, we decided (i.e. obeyed a
corporate mandate) to start using Coverity's static analysis tool on our
15 year old codebase. I learned a few things about static analysis then.

CPython was about that old when Coverity started giving us reports on
the C part of CPython (about 400000 loc). CPython is now essentially
free of errors detected by Coverity.
1) It finds bugs you would never find yourself.

Coverity apparently found several for CPython.
2) If your code does tricky things, you can fool the static analyzer,
leading to false positives.

One can define code patterns that are false positives, to silence such
reports.
Presumably, it also leads to false
negatives, but you don't know about those :-(

We use unit tests to find logic bugs ;-).
3) If you're going to use static analysis, probably the best way is to
start using it from day one. Trying to duct-tape a static analysis step
into your development process for a legacy codebase is probably more
effort than it's worth.

Some of the C coders on the development team thought it *was* for
CPython. The fact that CPython has been compiled for, say, 20 different
systems may have meant that it already depended less on
'implementation-defined' behavior.
 
R

Roy Smith

Terry Reedy said:
CPython was about that old when Coverity started giving us reports on
the C part of CPython (about 400000 loc). CPython is now essentially
free of errors detected by Coverity.

How many of those errors were real, and how many were "I suppose,
technically, this isn't quite correct but in real life, it's just never
going to be an issue?" I'm not being cynical here; I'm interested to
know if it really helped.
One can define code patterns that are false positives, to silence such
reports.

Yes, we did some of those.
 
G

Gregory Ewing

Christian said:
GW-BASIC was a weak language, but two significant characters is
definitely too few. I think it was eight.

That may have been true for MS-DOS era BASICS. If
you have a whopping 640KB for your program, then
it doesn't matter so much.

The 8-bit era was much more constrained. With only
48KB (or less, depending on how fancy a graphics
mode you wanted to use) people didn't like to use
any more chars than they strictly needed!
 
G

Gregory Ewing

Tim said:
Doh, forgot momentarily that the 6502 had X, Y, and A, making THREE
registers. ooh, the luxury of 2-bit naming conventions! :-D

Two bits? That's enough to name FOUR registers!
We've been cheated!
 
T

Terry Reedy

How many of those errors were real, and how many were "I suppose,
technically, this isn't quite correct but in real life, it's just never
going to be an issue?" I'm not being cynical here; I'm interested to
know if it really helped.

http://search.gmane.org/ search gmane.comp.python.devel for 'Coverity'
and you should get some relevant hits.
 
G

Gregory Ewing

Tim said:
In know that my first BASIC, Applesoft BASIC had the 2-character
names, and you had to load Integer Basic (with Ints in addition to the
standard Floats used in the BASIC provided by the ROM, a strange
choice).

That's not the way I remember it working. Integer Basic
provided only integers; Applesoft was an alternative ROM
that replaced Integer Basic and provided both float and
int variables.

But I think the only reason to use int variables (ending
with %) in Applesoft was to save memory -- they were
always converted to floats for doing arithmetic. And they
were 16-bit ints, so they had less precision than floats.
 
G

Gregory Ewing

Michael said:
And you could DIM something with a

Some versions of 8-bit Microsoft Basic also had a way of
overriding the default type for a range of names.
So, for example, Fortran programmers could DEFINT I-N
and feel right at home.

I guess that means it would occupy a zero-crossing on
the sigil oscillation curve -- you could have it either
way.
 

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

Forum statistics

Threads
474,082
Messages
2,570,587
Members
47,209
Latest member
Ingeborg61

Latest Threads

Top