Sid1968 Posted September 27, 2019 Author Share Posted September 27, 2019 (edited) 17 minutes ago, Lee Stewart said: A “program” in Forth is a word you define in Forth. You run the “program” by typing the word. In the case you quoted, the word is SNLOOP , which you run (execute) by typing it followed by <enter>. ...lee Worked... yippi... : SNLOOP ( -- n ) \ loop with single-cell, 16-bit numbers 0 \ 0 to stack for first drop in loop 15000 0 DO \ loop 15000 times DROP \ drop num on stack I 2 + \ index (I) + 2 I * \ I*(I+2) LOOP CR \ next line . \ print last loop result ; FIG FORTH REL 2.0: 5 Seconds. fbForth 2.0: 9 Seconds (Lees information). : DNLOOP ( -- d ) \ loop with double-cell, 32-bit numbers 0 0 \ double num 0 for first drop in loop 15000 0 DO \ loop 15000 times DROP DROP \ drop double num on stack I 2 + \ index (I) + 2 I U* \ I*(I+2)..U* leaves a double num result LOOP CR \ next line D. \ print double num from last loop result ; FIG FORTH REL 2.0: 6 Seconds. fbForth 2.0: 7 Seconds (Lees information). : FPNLOOP ( -- f ) \ loop with 4-cell, 64-bit, radix-100 floating point (FP) numbers 0 0 0 0 \ FP 0 for first drop in loop 15000 0 DO \ loop 15000 times FDROP \ drop FP num on stack I 2 + \ index (I) + 2 S->F \ convert to FP I S->F \ I to FP F* \ FP multiply I*(I+2) LOOP CR \ next line F. \ print FP num from last loop result ; FIG FORTH REL 2.0: Test couldnt run, because FDROP is unknown for this program. fbForth 2.0: 59 Seconds (Lees information). Edited September 27, 2019 by Sid1968 Quote Link to comment Share on other sites More sharing options...
Casey Posted September 28, 2019 Share Posted September 28, 2019 12 hours ago, Sid1968 said: 10 FOR I=1 TO 3000 20 A=RND 30 NEXT I 40 PRINT A TI-Basic: 46 Seconds RXB 2015: 50 Seconds Cortex Basic: 14 Seconds Just for grins, I ran this program twice on the TI 99/8 emulation in MESS using Extended BASIC II (which I believe is mostly written in Assembly with some GPL, and the processor is faster). As written, it completed in 18 seconds. Then I modified it as follows: 5 INTEGER I 10 FOR I=1 TO 3000 20 A=RND 30 NEXT I 40 PRINT A It completed in just under 15 seconds. Combining the program into 1 line using statement separators produced a runtime of 12.5 seconds. 1 Quote Link to comment Share on other sites More sharing options...
Sid1968 Posted September 28, 2019 Author Share Posted September 28, 2019 Thought that (TI-) Basic would define "I" as Integer by default? 5 FLOAT I Would define it as floatingpoint? Quote Link to comment Share on other sites More sharing options...
+mizapf Posted September 28, 2019 Share Posted September 28, 2019 No, TI BASIC and Extended BASIC do not have an integer data type. Everything floats. 2 Quote Link to comment Share on other sites More sharing options...
Sid1968 Posted September 28, 2019 Author Share Posted September 28, 2019 Then i dont understand the result from Casey. Quote Link to comment Share on other sites More sharing options...
+mizapf Posted September 28, 2019 Share Posted September 28, 2019 He referred to the TI-99/8 and its Extended Basic II. You can try it in MAME (or you have to be one of the lucky few to have a real one). 1 Quote Link to comment Share on other sites More sharing options...
Sid1968 Posted September 28, 2019 Author Share Posted September 28, 2019 How big are the steps in "I" after every Loop? Oner steps or hundreths steps? In German: Wie groß sind die Wertunterschiede von I nach jeder Schleife? Steigt der Wert in Einerschritten oder in hundertsteln oder tausendsteln? Quote Link to comment Share on other sites More sharing options...
Sid1968 Posted September 28, 2019 Author Share Posted September 28, 2019 (edited) 34 minutes ago, mizapf said: No, TI BASIC and Extended BASIC do not have an integer data type. Everything floats. Commodore Basic do have 40 BIT Floatingpoint, 16 Bit Integer, and Strings up to 255 characters datatypes. I think thats the main reason the VIC-20 was so fast compared to the TI-99/4A that it uses Integer for I. Good morning... i realise this but now. Isnt it possible to give RXB Integer Datatype? I guess that would help tremendous. Edited September 28, 2019 by Sid1968 Quote Link to comment Share on other sites More sharing options...
+mizapf Posted September 28, 2019 Share Posted September 28, 2019 As with every BASIC (that I know), a missing STEP parameter in the FOR line means STEP 1. FOR I=1 TO 1000 <=> FOR I=1 TO 1000 STEP 1 If I remember correctly, Commodore BASIC variables of integer type needed a % character after the name (like I%). 1 Quote Link to comment Share on other sites More sharing options...
Sid1968 Posted September 28, 2019 Author Share Posted September 28, 2019 30 minutes ago, mizapf said: As with every BASIC (that I know), a missing STEP parameter in the FOR line means STEP 1. FOR I=1 TO 1000 <=> FOR I=1 TO 1000 STEP 1 If I remember correctly, Commodore BASIC variables of integer type needed a % character after the name (like I%). Thats what i thought too. Quote Link to comment Share on other sites More sharing options...
senior_falcon Posted September 28, 2019 Share Posted September 28, 2019 I compiled this program: 10 FOR I=1 TO 3000 20 A=RND*100 30 NEXT I 40 PRINT A To be fair, RND must be multiplied by something or else you get a zero every time. Multiply by 100 gives random numbers from 0 to 99. I have a nice GIF video of the compilation process but cannot upload it. All you have to do is press enter at the prompts and a few seconds later you have a finished compiled program. Some seem to think this requires advanced knowledge, but if you can find the enter key, just keep pressing it. When compiled this takes about 3 seconds to run. 3 1 Quote Link to comment Share on other sites More sharing options...
+Lee Stewart Posted September 28, 2019 Share Posted September 28, 2019 3 hours ago, Sid1968 said: Thought that (TI-) Basic would define "I" as Integer by default? 5 FLOAT I Would define it as floatingpoint? There may be others, but the only programming language I remember having integer data types attached by default to variable names beginning with certain letters was Fortran. My first programming language was Fortran 2B (I said I was old! ) and variable names beginning with I – N were integer data types by default. REAL was the Fortran equivalent of FLOAT and the default for all other variable names. There were other data types, but I digress... ...lee 2 Quote Link to comment Share on other sites More sharing options...
Sid1968 Posted September 28, 2019 Author Share Posted September 28, 2019 (edited) 42 minutes ago, senior_falcon said: I compiled this program: 10 FOR I=1 TO 3000 20 A=RND*100 30 NEXT I 40 PRINT A To be fair, RND must be multiplied by something or else you get a zero every time. Multiply by 100 gives random numbers from 0 to 99. I have a nice GIF video of the compilation process but cannot upload it. All you have to do is press enter at the prompts and a few seconds later you have a finished compiled program. Some seem to think this requires advanced knowledge, but if you can find the enter key, just keep pressing it. When compiled this takes about 3 seconds to run. I get other values then zero. Floatingpointvalues smaller then 1. RXB 2015 TI-Basic Edited September 28, 2019 by Sid1968 1 Quote Link to comment Share on other sites More sharing options...
Sid1968 Posted September 28, 2019 Author Share Posted September 28, 2019 5 minutes ago, Lee Stewart said: There may be others, but the only programming language I remember having integer data types attached by default to variable names beginning with certain letters was Fortran. My first programming language was Fortran 2B (I said I was old! ) and variable names beginning with I – N were integer data types by default. REAL was the Fortran equivalent of FLOAT and the default for all other variable names. There were other data types, but I digress... ...lee Thank you Lee, as always very competently. ? Is it possible to answer my questions a few postings above about the languages? 1 Quote Link to comment Share on other sites More sharing options...
Sid1968 Posted September 28, 2019 Author Share Posted September 28, 2019 (edited) Nice too see you people here again. ? Edited September 28, 2019 by Sid1968 1 Quote Link to comment Share on other sites More sharing options...
+Lee Stewart Posted September 28, 2019 Share Posted September 28, 2019 12 minutes ago, Sid1968 said: Thank you Lee, as always very competently. ? Is it possible to answer my questions a few postings above about the languages? Post #? ...lee Quote Link to comment Share on other sites More sharing options...
senior_falcon Posted September 28, 2019 Share Posted September 28, 2019 (edited) I get other values then zero. Floatingpointvalues smaller then 1. This is true in XB which uses floating point numbers. The integer math of the compiler makes RND = 0. The only way to get a useful RND when compiled is to multiply RND by a number. You get INT(RND*100) in my example. So to compare the two fairly, mine needs to multiply RND by something and the actual XB does not. Without the x100 it takes 2 seconds. Edited September 28, 2019 by senior_falcon Quote Link to comment Share on other sites More sharing options...
+adamantyr Posted September 28, 2019 Share Posted September 28, 2019 If I remember right, the BASIC interpreter uses a full 8 bytes for every numeric variable but it does treat integers slightly differently, only using 2 bytes for them. If you ever interacted that variable with decimals though it became a float from then on. An interesting early case of a weakly cast variable type. To answer your earlier question, adding an Integer type explicitly is a lot of headache. If you use the % as an indicator it could break old BASIC programs using it in a variable name. Most functions would need to be altered to accept integer or numeric. You would need byte, word and double word versions. Conversion functions would need to be added. And finally, what exactly are you gaining? Memory mostly, but not a lot. It only makes sense if you are designing a new BASIC with 0% compatibility. 2 Quote Link to comment Share on other sites More sharing options...
wierd_w Posted September 28, 2019 Share Posted September 28, 2019 (edited) Odd, qbasic has several data types. integer == "short int" (8bit) long == "long int" (16bit) single == Single precision floating point (16bit) double == double precision floating point (32bit) String == String It also has operations for modulo (mod), and integer division (\), in addition to normal division (/). So, I don't see the above argument about 0% compatibility. If you did it their way, by adding new operators and types, old programs would still work (because they would use the normal division operator for division, and thus do the floatingpoint routine, like they expect), but you would still have the option (with established precedent) of using integer division if you wanted. Just assume all integers are longs unless explicitly declared with DIM, and assume floating points are singles unless explicitly declared with DIM. That way your programs don't hit overflows they were not designed to handle, and the wrong type will not be selected when running an old program, preventing "incorrect type" errors. https://en.wikibooks.org/wiki/QBasic/Arrays_and_Types The issue is with the compiler being designed for "Maximal performance gain", rather than "Maximal user control". The latter would permit you to disable integer math substitution on compilation with an option, or would interpret the intent from parsing the variable type declarations, and math operators used. If we are talking about a new basic interpreter, we should also talk about a new compiler that respects it. (otherwise the new basic will not be supported by that compiler.) Edited September 28, 2019 by wierd_w 1 Quote Link to comment Share on other sites More sharing options...
RXB Posted September 28, 2019 Share Posted September 28, 2019 29 minutes ago, adamantyr said: If I remember right, the BASIC interpreter uses a full 8 bytes for every numeric variable but it does treat integers slightly differently, only using 2 bytes for them. If you ever interacted that variable with decimals though it became a float from then on. An interesting early case of a weakly cast variable type. To answer your earlier question, adding an Integer type explicitly is a lot of headache. If you use the % as an indicator it could break old BASIC programs using it in a variable name. Most functions would need to be altered to accept integer or numeric. You would need byte, word and double word versions. Conversion functions would need to be added. And finally, what exactly are you gaining? Memory mostly, but not a lot. It only makes sense if you are designing a new BASIC with 0% compatibility. Sadly yes that is the end result. All TI Basic or XB programs would have to be converted each time or suffer even worse performance issues. As this new TI Basic or XB would have so much added to interpreter to look for if a number is Integer or Floating Point. This would force a Compiled version to not slow down the programs, thus defeating the entire reason for Basic in the first place. This is what also happened to all Compiled Basic versions, as if you compiled Basic, just might as well just jump to C or Pascal or Assembly. 1 Quote Link to comment Share on other sites More sharing options...
wierd_w Posted September 28, 2019 Share Posted September 28, 2019 I thought the reason for BASIC was spelled out in the name-- Beginner's All-purpose Symbolic Instruction Set. Emphasis on "beginner's". Being slow is a consequence of its interpreted nature, not its function. 2 Quote Link to comment Share on other sites More sharing options...
RXB Posted September 28, 2019 Share Posted September 28, 2019 5 minutes ago, wierd_w said: Odd, qbasic has several data types. integer == "short int" (8bit) long == "long int" (16bit) single == Single precision floating point (16bit) double == double precision floating point (32bit) String == String It also has operations for modulo (mod), and integer division (\), in addition to normal division (/). So, I don't see the above argument about 0% compatibility. If you did it their way, by adding new operators and types, old programs would still work (because they would use the normal division operator for division, and thus do the floatingpoint routine, like they expect), but you would still have the option (with established precedent) of using integer division if you wanted. Just assume all integers are longs unless explicitly declared with DIM, and assume floating points are singles unless explicitly declared with DIM. That way your programs don't hit overflows they were not designed to handle, and the wrong type will not be selected when running an old program, preventing "incorrect type" errors. https://en.wikibooks.org/wiki/QBasic/Arrays_and_Types The issue is with the compiler being designed for "Maximal performance gain", rather than "Maximal user control". The latter would permit you to disable integer math substitution on compilation with an option, or would interpret the intent from parsing the variable type declarations, and math operators used. If we are talking about a new basic interpreter, we should also talk about a new compiler that respects it. (otherwise the new basic will not be supported by that compiler.) The entire point of Basic in the first place was to have a interpreter that did edit mode or program mode instantly so debugging could be done without files needed. A compiler just adds unnecessary complications to a simple to use interface, this defeats the debugging advantage Basic had over these other languages. Compiled Basic killed off the Basic market, why compile Basic when C or Pascal or Assembly is also compiled at 10 times faster results? 1 Quote Link to comment Share on other sites More sharing options...
RXB Posted September 28, 2019 Share Posted September 28, 2019 1 minute ago, wierd_w said: I thought the reason for BASIC was spelled out in the name-- Beginner's All-purpose Symbolic Instruction Set. Emphasis on "beginner's". Being slow is a consequence of its interpreted nature, not its function. Yes that is so true that I have tried my best to stay with that in RXB all these years. Making Basic into C is just kind of silly, might as well just use C for that reason. 1 Quote Link to comment Share on other sites More sharing options...
wierd_w Posted September 28, 2019 Share Posted September 28, 2019 Intellectual barrier to entry is the reason for BASIC. This is not obviated by using a compiler (which is optional.) Same reason why fewer kids enjoy learning to program these days; Setting up a full compiler toolchain is no bueno, and fraught with pitfalls and caveats. Then there are the niggly details about those languages. (ASM is different for every CPU ISA out there.) An abstracted BASIC supplies essential tools with a robust, easy to use and debug execution framework. BUT-- you don't want or need those handrails once you are finished with a program. Compiling it is what you do when you are done with the interpreter, and want something fast and reliable. 3 1 Quote Link to comment Share on other sites More sharing options...
Sid1968 Posted September 28, 2019 Author Share Posted September 28, 2019 1 hour ago, Lee Stewart said: Post #? ...lee #198 ? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.