Page 4 of 8

Re: General language discussion.

Posted: Fri May 17, 2019 7:55 pm
by John_Spikowski
Interesting if performance wasn't an issue.

Re: General language discussion.

Posted: Fri May 17, 2019 8:05 pm
by John_Spikowski
I was just thinking. If we embed ScriptBasic in Python, the language would be extended with BASIC, Scheme and V7 JavaScript. The gcc of scripting languages. 8-)

Re: General language discussion.

Posted: Fri May 17, 2019 8:19 pm
by Heater
Performance is not an issue.

Most of the reported time there is engine start up. If I run the thing multiple times in a loop or let it run to 1000000 it's orders of magnitude faster:

Code: Select all

$ time node  floyd.js
    1
    2     3
    4     5     6
    7     8     9    10
...
...
999993 999994 999995 999996 999997 999998 999999
real    0m47.850s
user    0m6.172s
sys     0m14.766s
That's 10,000 times more work in 48 seconds. Or 0.0047 seconds for the 100 odd numbers I presented above.

If performance is an issue didn't we already discover, in the fibo challenge, that JS far outruns SrciptBasic :)

Re: General language discussion.

Posted: Fri May 17, 2019 8:23 pm
by jahboater
C version, run once ...

Code: Select all

$ time ./floyd
  1 
  2   3 
  4   5   6 
  7   8   9  10 
 11  12  13  14  15 
 16  17  18  19  20  21 
 22  23  24  25  26  27  28 
 29  30  31  32  33  34  35  36 
 37  38  39  40  41  42  43  44  45 
 46  47  48  49  50  51  52  53  54  55 
 56  57  58  59  60  61  62  63  64  65  66 
 67  68  69  70  71  72  73  74  75  76  77  78 
 79  80  81  82  83  84  85  86  87  88  89  90  91 
 92  93  94  95  96  97  98  99 100 101 102 103 104 105 

real	0m0.001s
user	0m0.000s
sys	0m0.000s

Re: General language discussion.

Posted: Fri May 17, 2019 8:25 pm
by John_Spikowski
Can you post those Fibonacci(87) times again for Node and ScriptBasic?

Re: General language discussion.

Posted: Fri May 17, 2019 8:48 pm
by Heater
fibo(87) in JS on my Intel i7 2600K 3.4GHz

Code: Select all

$ time node fibo.js
2ms
679891637638612258

real    0m0.192s
user    0m0.094s
sys     0m0.094s
What that shows is a 192ms total load and run time. Only 2ms running the fibo from start to end.

Re: General language discussion.

Posted: Fri May 17, 2019 8:51 pm
by ejolson
jahboater wrote:
Fri May 17, 2019 8:23 pm
C version, run once ...

Code: Select all

$ time ./floyd
  1 
  2   3 
  4   5   6 
  7   8   9  10 
 11  12  13  14  15 
 16  17  18  19  20  21 
 22  23  24  25  26  27  28 
 29  30  31  32  33  34  35  36 
 37  38  39  40  41  42  43  44  45 
 46  47  48  49  50  51  52  53  54  55 
 56  57  58  59  60  61  62  63  64  65  66 
 67  68  69  70  71  72  73  74  75  76  77  78 
 79  80  81  82  83  84  85  86  87  88  89  90  91 
 92  93  94  95  96  97  98  99 100 101 102 103 104 105 

real	0m0.001s
user	0m0.000s
sys	0m0.000s
Here is my C code:

Code: Select all

#include <stdio.h>
int main(){
    for(int i=1;i<=14;i++){
        for(int j=1;j<=i;j++){
            printf("%3d ",((i-1)*i>>1)+j);
        }
        printf("\n");
    }
    return 0;
}
Note for simplicity that only two variables are used: one for the row and one for the column. Is it possible to do the same using only one variable?

Re: General language discussion.

Posted: Fri May 17, 2019 9:01 pm
by Heater
ejolson,
Is it possible to do the same using only one variable?
That might be complex.

Get it? :)

Re: General language discussion.

Posted: Fri May 17, 2019 9:07 pm
by John_Spikowski
Heater wrote:
Fri May 17, 2019 8:48 pm
fibo(87) in JS on my Intel i7 2600K 3.4GHz

Code: Select all

$ time node fibo.js
2ms
679891637638612258

real    0m0.192s
user    0m0.094s
sys     0m0.094s
What that shows is a 192ms total load and run time. Only 2ms running the fibo from start to end.
Post the code as that is not what I'm seeing. FIBO(87) on the RPi 3B please.

Re: General language discussion.

Posted: Fri May 17, 2019 9:26 pm
by John_Spikowski
This is what I'm seeing for ScriptBasic and the fibo(87) time on the RPi 3B.

Code: Select all

FUNCTION sfibo (n)
        IF n < 2 THEN
                sfibo = 1
        ELSE
                m = 0
                p = 1
                q = 0
                FOR i = 2 TO n
                        m = p + q
                        q = p
                        p = m
                NEXT i
                sfibo = m
        END IF
END FUNCTION

PRINT FORMAT("%.0f",sfibo(87)),"\n"

Code: Select all

[email protected]:~/sbrpi/examples $ time scriba fibo87.sb
679891637638612224

real	0m0.016s
user	0m0.009s
sys	0m0.008s
[email protected]:~/sbrpi/examples $
Note: The Fibo(87) is used as it is the largest integer that can be represented by a real without deteriorated precision.

Re: General language discussion.

Posted: Fri May 17, 2019 9:33 pm
by Heater
Ah, totally different algorithm. I was running the big fibo algorithm above. I don't know at what size numbers it becomes faster than the schoolboy algorithm. 87 is probably a bit small.

Re: General language discussion.

Posted: Fri May 17, 2019 9:48 pm
by John_Spikowski
Great!

We can debunk that statement of yours that Node runs circles around ScriptBasic.

Re: General language discussion.

Posted: Fri May 17, 2019 10:16 pm
by Heater
ScriptBasic,
We can debunk that statement of yours that Node runs circles around ScriptBasic.
How so? That debunks nothing.

I recall you complaining that ScriptBasic was so slow at completing the fibo challenge that you only ever wanted to run it once!

I will concede that you may have found an edge case with your small example, where the integers are just a bit to big to handle with Javascript's regular numbers but a bit too small to get the edge with big integer algorithms.

Anyway, the fibo challenge was not about performance. Within reason.

Re: General language discussion.

Posted: Fri May 17, 2019 10:24 pm
by John_Spikowski
I recall you complaining that ScriptBasic was so slow at completing the fibo challenge that you only ever wanted to run it once!
I said ScriptBasic is slow when thrashing a 1.7 million element dynamic variant based array.

You have selective reading issues.

Re: General language discussion.

Posted: Fri May 17, 2019 10:33 pm
by Heater
ScriptBasic,
You have selective reading issues.
Yes, I do. The internet is huge. Can't read it all. Even this forum.

Please do link us to where you have posted better ScriptBasic results.

Re: General language discussion.

Posted: Fri May 17, 2019 10:35 pm
by John_Spikowski
Wow!

It's only been a couple posts back and you're asking for it again.

I'm still waiting for your fibo(87) in JavaScript. I thought we already discovered that JavaScript dies early in the precision race.

Re: General language discussion.

Posted: Fri May 17, 2019 10:46 pm
by Heater
Sorry, I thought you were talking of the fibo(4784969) challenge results. Not this trivial little program. Now I start to understand why you posted it with the number 87.

Re: General language discussion.

Posted: Fri May 17, 2019 10:48 pm
by John_Spikowski
Yeah, like playing in the same ballpark.

ScriptBasic can play fantasy fibo like the best of them with GMP in its holster.

Re: General language discussion.

Posted: Fri May 17, 2019 10:54 pm
by Heater
I don't follow, what are we talking about?

I have probably had my head stuck in Verilog and FPGA for too many hours today to understand anything !

Re: General language discussion.

Posted: Fri May 17, 2019 10:57 pm
by John_Spikowski
Simple. Post your Node code and I'll take it from there.

Re: General language discussion.

Posted: Fri May 17, 2019 11:02 pm
by Heater
Which node code are we talking about?

Re: General language discussion.

Posted: Fri May 17, 2019 11:03 pm
by John_Spikowski
Fibo(87) in JavaScript.

Re: General language discussion.

Posted: Fri May 17, 2019 11:24 pm
by Heater
I posted the results of this code: https://github.com/ZiCog/fibo_4784969/b ... pt/fibo.js

Just changed the line:

timeIt(fiboFaster, 4784969)

to:

timeIt(fiboFaster, 87)

Re: General language discussion.

Posted: Fri May 17, 2019 11:47 pm
by John_Spikowski
Never mind.

Here is a Fibonacci(87) in JavaScript running under Node.

Code: Select all

function fibonacci(num){
  var a = 1, b = 0, temp;

  while (num >= 0){
    temp = a;
    a = a + b;
    b = temp;
    num--;
  }

  return b;
}

console.log(fibonacci(87));
Output

Code: Select all

[email protected]:~/sbrpi/examples $ time node fibonacci.js
1100087778366101900

real	0m2.401s
user	0m2.280s
sys	0m0.110s
[email protected]:~/sbrpi/examples $
Like I said, it's slow and precision has limited range.

Re: General language discussion.

Posted: Fri May 17, 2019 11:49 pm
by Douglas6
I don't generally weigh in on 'my favorite language' dialogues, but having slogged thru this thread, let me just say this.

Code is no longer written by individuals with 'jazz' or 'funk' sensibilities. Code is written by teams of 5, 10, 20, 200 people. The choice of language, and more importantly, coding standards, should be the least concern of a good programmer. If the code base is COBOL, you learn to write good COBOL. Choosing a language is all well and good for an experimentor, but in the real world, we simply need to develop good coders.

Those coders can meet at a bar and whinge, or meet on a forum and whinge, it's not going to change reality.