FRDB Archives

Freethought & Rationalism Archive

The archives are read only.


Go Back   FRDB Archives > Archives > IIDB ARCHIVE: 200X-2003, PD 2007 > IIDB Philosophical Forums (PRIOR TO JUN-2003)
Welcome, Peter Kirby.
You last visited: Yesterday at 05:55 AM

 
 
Thread Tools Search this Thread
Old 07-12-2003, 09:54 AM   #91
Veteran Member
 
Join Date: Jan 2001
Location: USA
Posts: 1,072
Default

Quote:
NialScorva: My first response to you (and further responses) were commenting on your statement that implied that it was no big deal to run past the end of an array by one element.
DNAunion: That's not what I was saying.

First, I was not making a generalized statement that overrunning arrays by one elelemt is acceptable. I am aware of the dangers of overwriting memory.

Second, my statement was based on very specific conditions. Namely, IF a program does not make function calls, AND IF the last variable declared is the array, AND IF the compiler allocates memory for variables in the same order that they are listed, THEN there should be little problem (remember, as I already mentioned, at the time I made my comment I overlooked the fact that my program made function calls).

Third, I discovered my own off-by-one error after it already was made, and after it was LITERALLY too late to correct the error. Could I have corrected my own code (as is possible in the real world of programming), this whole subsequent discussion would not have even started.

Fourth, the empirical probability results of the program runs were consistent and very close to the theoretical probability. This alone suggests that the overrun IN THIS PARTICULAR CASE was not that big of a deal.

Fifth, my question about the overrun was (whether I originally made this clear or not) why a "frameshift mutation" catastrophe did not result.
DNAunion is offline  
Old 07-12-2003, 10:22 AM   #92
Veteran Member
 
Join Date: May 2003
Location: On the road to extinction. . .
Posts: 1,485
Default an instructive thanks

DNAunion: Now you can. I just taught you what a safe array is!

Very well put, again I concede. In my days when it was invented, they called it bounds checking.

Further, on the science part of programming, if your program is 'proofed', before testing, most errors can be caught, and a minimal set of test cases can be produced before you interpret the results of the production code.

This is the new science of programming, the rest I think has ontologically shifted into hacking. This entails if you have not proven your program correct and you run out and test it, you are a hack.

Note (if you can remember) how this has changed from years previously, where hacking was sitting at the terminal banging away at the code without any previous planning. Now to not be called a hack, one has to plan the program AND proof it. (Hope I am not too off topic)
sophie is offline  
Old 07-12-2003, 11:17 AM   #93
Veteran Member
 
Join Date: Jan 2001
Location: USA
Posts: 1,072
Default Re: an instructive thanks

Quote:
Sophie: Further, on the science part of programming, if your program is 'proofed', before testing, most errors can be caught, and a minimal set of test cases can be produced before you interpret the results of the production code.
DNAunion: I did test the program I used to demonstrate the error in Rode’s calculation…that program being the original Visual FoxPro one.

First, I tested the pseudo-random number generating function to ensure that it produced an even distribution of results (note that one does NOT expect an EXACTLY even distribution, so very slight discrepancies are EXPECTED to occur).

Second, I used the program to calculate empirical probabilities on simple cases that I could calculate by hand, and the output was extremely close to the predicted theoretical probabilities (remember, here too, one does NOT expect EXACT matches, so very slight discrepancies are EXPECTED to occur).

Third, in a limited way, I did test the program for the complex cases. I ran it under multiple scenarios and determined if the results were reasonable. That is all I could do. If you read the first thread you would see that my reason for writing the program in the first place was that I could not do the needed calculations by hand on paper. But, I knew how to calculate the empirical probability using an urn and lettered tiles, and, being a programmer, I knew how to model that programmatically. Hence, the Visual FoxPro program.

Since the underlying logic of the program was sound and does not change when moving from simple to the more complex, the natural conclusion is that it actually was working on all levels of complexity. No code runs have yet to show otherwise.


Quote:
Sophie: This is the new science of programming, the rest I think has ontologically shifted into hacking. This entails if you have not proven your program correct and you run out and test it, you are a hack.
DNAunion: Then I’m not a hack. I tested the VFP program and its one function. I made sure the program produced accurate results on the straightforward calculations and reasonable/accurate results on the ones too hard for me to calculate. Furthermore, even switching to the C++ program, the multiple millions of iterations that I and Principia ran had a mean result that was only about one-half of one-tenth of one-percent from the theoretical probability. For an EMPIRICAL probability calculation, that’s about as close as one could ever hope.

Keep in mind, once again, that the C++ program is just a hastily done translation of the actual VFP program, completed in about an hour while also posting at two different discussion forums. The C++ program is not the program of interest.

PS: Perhaps you could save yourself some time and effort by refraining from trying to think up any more ways you might be able to mislabel me as an incompetent programmer or hack.
DNAunion is offline  
Old 07-12-2003, 11:30 AM   #94
Veteran Member
 
Join Date: Jan 2001
Location: USA
Posts: 1,072
Default Re: Re: an instructive thanks

Quote:
Sophie: You don't teach so you have no clue about this.
DNAunion: Wrong, I do teach, computer programming, to university students.

What I am not is a professor...I am a tutor. I have a full-time, very good-paying "computer programming" job and on the side, I go to my old university and tutor students (for pay, by the way).

Some I am a professional "computer programmer" who also teaches computer programming to university students.


PS: The quotes around the term "computer programmer" means that it does not fully describe my position. I am a systems analyst, a lead programmer, and a database manager employeed by a multi-national corporation, where I have been working for the past 7 years.
DNAunion is offline  
Old 07-12-2003, 11:37 AM   #95
Veteran Member
 
Join Date: May 2003
Location: On the road to extinction. . .
Posts: 1,485
Default yes sir

DNAunion, very valid, useful and helpful insights. I acknowledge your capabilities. Curiously, I noted a bit of science embedded in one of your statements. Was this :

Since the underlying logic of the program was sound and does not change when moving from simple to the more complex, the natural conclusion is that it actually was working on all levels of complexity. No code runs have yet to show otherwise.

your attempt to imply program corectness through induction?
sophie is offline  
Old 07-12-2003, 11:50 AM   #96
Veteran Member
 
Join Date: May 2003
Location: On the road to extinction. . .
Posts: 1,485
Default help to debug me

here is one of my applications for windows

http://www.notrich.org/kombatS.exe

you learn to use it through intuition. Have fun and you can comment if you wish
sophie is offline  
Old 07-12-2003, 03:48 PM   #97
Veteran Member
 
Join Date: Jan 2001
Location: USA
Posts: 1,072
Default Re: yes sir

Quote:
sophie: Curiously, I noted a bit of science embedded in one of your statements. Was this :

***********************
DNAunion: Since the underlying logic of the program was sound and does not change when moving from simple to the more complex, the natural conclusion is that it actually was working on all levels of complexity. No code runs have yet to show otherwise.
***********************

your attempt to imply program corectness through induction?
DNAunion: <sigh> If you want to continue to be that way....program correctness was determined through a combination of unit testing, program testing, and logic, as I explained previously.

I find your implication that I must have absolutely proven my program to be 100% correct in every way and under all scenarios in order for me to avoid being labeled a "hack" or some other derogatory term highly unreasonable, considering that the programmers at Microsoft and tons of other software companies regularly ship final versions that contain multiple bugs.

Furthermore, I doubt your own programs live up to your own high standards. How about you post the code for one of your programs here and let us all take a look at it?
DNAunion is offline  
Old 07-13-2003, 07:12 AM   #98
Veteran Member
 
Join Date: May 2003
Location: On the road to extinction. . .
Posts: 1,485
Default Simple Java animation

The following http://www.notrich.org/GREETING/ALLsee.html
uses the basic WEB page idea of switching images BUT adds animation by controlling the rates at which the images flash. A simple idea using only two images gives flash and flair.

Sorry there are no comments AND (I did not cheat by renaming the LANspeed array to its PROPER descriptive name) the variable names were not meant for public consumption, hence you can have a direct look into my brain...

Works on both Netscape and Internet Explorer. Though you can hardly tell.

The code :
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>GREETINGs by Sophie </title>
<link type="text/css" rel="stylesheet" href="http://www.notrich.org/GREETING/greeting.css">


<script language="JavaScript1.2">
var PLANPic = new Array() ;
PLANPic[0] = 'http://www.notrich.org/ANIMATION/PLAN2.jpg' ;
PLANPic[1] = 'http://www.notrich.org/ANIMATION/PLAN1.jpg' ;

var PLANrc ;
var PLANj = 0 ;
var PLANp = PLANPic.length ;

var PLANpreLoad = new Array() ;
for (i = 0; i < PLANp; i++){
PLANpreLoad[i] = new Image() ;
PLANpreLoad[i].src = PLANPic[i] ;
}

var PLANspeed = new Array() ;
PLANspeed[0] = 300 ;
PLANspeed[1] = 240 ;
PLANspeed[2] = 180 ;
PLANspeed[3] = 140 ;
PLANspeed[4] = 50 ;
PLANspeed[5] = 130 ;
PLANspeed[6] = 183 ;
PLANspeed[7] = 130 ;
PLANspeed[8] = 50 ;
PLANspeed[9] = 321 ;
PLANspeed[10] = 440 ;
PLANspeed[11] = 500 ;

var LANspeed = new Array() ;
LANspeed[0] = 6 ;
LANspeed[1] = 3 ;
LANspeed[2] = 5 ;
LANspeed[3] = 1 ;
LANspeed[4] = 8 ;
LANspeed[5] = 2 ;
LANspeed[6] = 7 ;
LANspeed[7] = 2 ;
LANspeed[8] = 11 ;
LANspeed[9] = 2 ;
LANspeed[10] = 4 ;
LANspeed[11] = 4 ;

var Nimage = PLANPic.length ;
var REPSperIMAGE = Nimage ;

var FANc = PLANspeed.length - 1;
var Nreps = LANspeed[FANc];

function NEXTplanSPEED(){
if (++REPSperIMAGE > Nimage )
{
if ( ++Nreps > LANspeed[FANc] )
{
++FANc ; REPSperIMAGE = 1 ; Nreps = 0 ;
if (FANc >= PLANspeed.length)
FANc = 0 ;
}
}

return (PLANspeed[FANc])
}

function ANIMATEplan(){
if (document.images){
document.images.PLAN.src = PLANpreLoad[PLANj].src;
var newspeed = NEXTplanSPEED() ;
if (++PLANj > (PLANp-1)) PLANj=0 ;
PLANrc= setTimeout('ANIMATEplan()', newspeed) ;
}
}

</script>


<script language="JavaScript1.2">
function ANIMATIONS(){
ANIMATEplan();
}
</script>

</head>
<body onload="ANIMATIONS()" bgcolor=green >

<img src = "http://www.notrich.org/ANIMATION/PLAN1.jpg" border=no NAME="PLAN">

We Give NICE Hi U</font>



</body>
</html>
sophie is offline  
Old 07-13-2003, 08:59 AM   #99
Veteran Member
 
Join Date: Jan 2001
Location: USA
Posts: 1,072
Default Re: Simple Java animation

DNAunion:
(1) I guess the only real problem I found is that it didn’t work. I could see the repeated alternating commands to download the two images, one after the other, but the web page showed no change…no animation.

(2) You wrote spaghetti code. Look at this section:

Code:
   if (++REPSperIMAGE > Nimage )
   {
       if ( ++Nreps > LANspeed[FANc] )
       {
            ++FANc ; REPSperIMAGE = 1 ; Nreps = 0 ;
            if (FANc >= PLANspeed.length)
                FANc = 0 ;
       } 
   }
DNAunion: Look at all those Ifs!!!!! How is anyone supposed to follow that tangled logic!!!!

Just kidding about the spaghetti code thing….just remaking an old point to someone else.

(2) Concerning your code I posted above, see the line, ++FANc ; REPSperIMAGE = 1 ; Nreps = 0 ;. It is considered to be a good programming practice to have only one statement per line.

(3) Although you did point it out ahead of time, the lack of internal documentation (i.e., comments) makes your code harder to follow than it should be.

(4) Although you also pointed this out ahead of time, it is considered good programming practice to make your code self-documenting by choosing descriptive variable names that clearly indicate the variables’ meaning/usage. Perhaps to you the names PLANj, PLANp, PLANc, and PLANrc make perfect sense, but to someone reading the code for the first time, the variables’ meanings cannot be determined from their names alone and one must read through all of the code (probably more than once) to try to figure out what each one does.

(5) You have a couple of indentation “errors”. This first one deals with the var newspped = NEXTplanSPEED(); statement.

Code:
function ANIMATEplan(){
       if (document.images){
           document.images.PLAN.src = PLANpreLoad[PLANj].src;
   var newspeed = NEXTplanSPEED() ;
       if (++PLANj > (PLANp-1)) PLANj=0 ;
       PLANrc= setTimeout('ANIMATEplan()', newspeed) ;
   }
}
DNAunion: And here it’s the ending curly brace.

Code:
function ANIMATIONS(){
     ANIMATEplan();
   }

All in all, I see only one real problem:

(1) The code did not work.

And one that would be real problem (except that you sort of covered yourself ahead of time by saying you didn't intend the program for "public consumption"):

(2) The clarity of the code suffers much from (a) a lack of comments and (b) the use of non-meaningful variable names.


PS: Here is the code from the web. To get code to display with indentations and other whitespace preserved, wrap your code in [code ] … [/code ] tags (but without the spaces just before the ending ‘]’ of each tag I added here).

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

        "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<title>GREETINGs by Sophie </title>
<link type="text/css" rel="stylesheet" href="http://www.notrich.org/GREETING/greeting.css">


<script language="JavaScript1.2">
var PLANPic = new Array() ;
PLANPic[0] = 'http://www.notrich.org/ANIMATION/PLAN2.jpg' ;
PLANPic[1] = 'http://www.notrich.org/ANIMATION/PLAN1.jpg' ;

var PLANrc ;
var PLANj = 0 ;
var PLANp = PLANPic.length ;

var PLANpreLoad = new Array() ;
for (i = 0; i < PLANp; i++){
   PLANpreLoad[i] = new Image() ;
   PLANpreLoad[i].src = PLANPic ;
}

var PLANspeed = new Array() ;
PLANspeed[0] = 300 ;
PLANspeed[1] = 240 ;
PLANspeed[2] = 180 ;
PLANspeed[3] = 140 ;
PLANspeed[4] = 50 ;
PLANspeed[5] = 130 ;
PLANspeed[6] = 183 ;
PLANspeed[7] = 130 ;
PLANspeed[8] = 50 ;
PLANspeed[9] = 321 ;
PLANspeed[10] = 440 ;
PLANspeed[11] = 500 ;

var LANspeed = new Array() ;
LANspeed[0] = 6 ;
LANspeed[1] = 3 ;
LANspeed[2] = 5 ;
LANspeed[3] = 1 ;
LANspeed[4] = 8 ;
LANspeed[5] = 2 ;
LANspeed[6] = 7 ;
LANspeed[7] = 2 ;
LANspeed[8] = 11 ;
LANspeed[9] = 2 ;
LANspeed[10] = 4 ;
LANspeed[11] = 4 ;

var Nimage = PLANPic.length ;
var REPSperIMAGE = Nimage ;

var FANc = PLANspeed.length - 1;
var Nreps = LANspeed[FANc];

function NEXTplanSPEED(){
   if (++REPSperIMAGE > Nimage )
   {
       if ( ++Nreps > LANspeed[FANc] )
       {
            ++FANc ; REPSperIMAGE = 1 ; Nreps = 0 ;
            if (FANc >= PLANspeed.length)
                FANc = 0 ;
       } 
   } 
 
   return (PLANspeed[FANc])
}

function ANIMATEplan(){
       if (document.images){
           document.images.PLAN.src = PLANpreLoad[PLANj].src;
   var newspeed = NEXTplanSPEED() ;
       if (++PLANj > (PLANp-1)) PLANj=0 ;
       PLANrc= setTimeout('ANIMATEplan()', newspeed) ;
   }
}

</script>


<script language="JavaScript1.2">
function ANIMATIONS(){
     ANIMATEplan();
   }
</script>

</head>
<body  onload="ANIMATIONS()" bgcolor=green >

<img src = "http://www.notrich.org/ANIMATION/PLAN1.jpg" border=no NAME="PLAN"> 
                                   
We Give NICE Hi U</font>



   </body>
</html>





*******************************
DNAunion: Came back to add two more things.


(1) Using i as a subscript/index in C-style languages can cause problems when posting to sites such as this one. You end up with [ i ] which is markup for "begin italicizing here".


(2) A computer programmer is not supposed to know all computer languages, any more than an author has to know how to write in English, and French, and German, and Spanish, and Chinese, and so on.

I have never programmed in JavaScript (and it's been years since I programmed in Java), but it is close enough to C/C++ that I can follow the code pretty much. The reason I bring this up is that PLAN showed up all over the place in Sophie's code. "PLAN" means nothing to me, so the variable names PLANj, PLANp, PLANc, PLANrc, and others are meaningless. But perhaps they have clearly defined meanings to JavaScript programmers.
DNAunion is offline  
Old 07-13-2003, 09:23 AM   #100
Veteran Member
 
Join Date: May 2003
Location: On the road to extinction. . .
Posts: 1,485
Default

DNAunion,

you musta turned off Javascript, or disabled images. The code was working only you could not see it.

Whenever I select the link, http://www.notrich.org/GREETING/ALLsee.html
I see someone doing a jig.

further, no comments on a lack of else statements! Does this make my code linearily faster? Or would you suppose the else was implied?

(added)
Actually the PLAN was intended as a self-conveyance of something cute. What a plan I thought.
sophie is offline  
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump


All times are GMT -8. The time now is 05:41 AM.

Top

This custom BB emulates vBulletin® Version 3.8.2
Copyright ©2000 - 2015, Jelsoft Enterprises Ltd.