User avatar
John_Spikowski
Posts: 1544
Joined: Wed Apr 03, 2019 5:53 pm
Location: Anacortes, WA USA
Contact: Website Twitter

Re: General language discussion.

Fri May 17, 2019 7:55 pm

Interesting if performance wasn't an issue.

User avatar
John_Spikowski
Posts: 1544
Joined: Wed Apr 03, 2019 5:53 pm
Location: Anacortes, WA USA
Contact: Website Twitter

Re: General language discussion.

Fri May 17, 2019 8:05 pm

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-)

Heater
Posts: 13643
Joined: Tue Jul 17, 2012 3:02 pm

Re: General language discussion.

Fri May 17, 2019 8:19 pm

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 :)
Memory in C++ is a leaky abstraction .

jahboater
Posts: 4769
Joined: Wed Feb 04, 2015 6:38 pm

Re: General language discussion.

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

User avatar
John_Spikowski
Posts: 1544
Joined: Wed Apr 03, 2019 5:53 pm
Location: Anacortes, WA USA
Contact: Website Twitter

Re: General language discussion.

Fri May 17, 2019 8:25 pm

Can you post those Fibonacci(87) times again for Node and ScriptBasic?

Heater
Posts: 13643
Joined: Tue Jul 17, 2012 3:02 pm

Re: General language discussion.

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.
Memory in C++ is a leaky abstraction .

ejolson
Posts: 3700
Joined: Tue Mar 18, 2014 11:47 am

Re: General language discussion.

Fri May 17, 2019 8:51 pm

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?

Heater
Posts: 13643
Joined: Tue Jul 17, 2012 3:02 pm

Re: General language discussion.

Fri May 17, 2019 9:01 pm

ejolson,
Is it possible to do the same using only one variable?
That might be complex.

Get it? :)
Memory in C++ is a leaky abstraction .

User avatar
John_Spikowski
Posts: 1544
Joined: Wed Apr 03, 2019 5:53 pm
Location: Anacortes, WA USA
Contact: Website Twitter

Re: General language discussion.

Fri May 17, 2019 9:07 pm

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.

User avatar
John_Spikowski
Posts: 1544
Joined: Wed Apr 03, 2019 5:53 pm
Location: Anacortes, WA USA
Contact: Website Twitter

Re: General language discussion.

Fri May 17, 2019 9:26 pm

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.
Last edited by John_Spikowski on Fri May 17, 2019 10:19 pm, edited 2 times in total.

Heater
Posts: 13643
Joined: Tue Jul 17, 2012 3:02 pm

Re: General language discussion.

Fri May 17, 2019 9:33 pm

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.
Memory in C++ is a leaky abstraction .

User avatar
John_Spikowski
Posts: 1544
Joined: Wed Apr 03, 2019 5:53 pm
Location: Anacortes, WA USA
Contact: Website Twitter

Re: General language discussion.

Fri May 17, 2019 9:48 pm

Great!

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

Heater
Posts: 13643
Joined: Tue Jul 17, 2012 3:02 pm

Re: General language discussion.

Fri May 17, 2019 10:16 pm

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.
Memory in C++ is a leaky abstraction .

User avatar
John_Spikowski
Posts: 1544
Joined: Wed Apr 03, 2019 5:53 pm
Location: Anacortes, WA USA
Contact: Website Twitter

Re: General language discussion.

Fri May 17, 2019 10:24 pm

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.

Heater
Posts: 13643
Joined: Tue Jul 17, 2012 3:02 pm

Re: General language discussion.

Fri May 17, 2019 10:33 pm

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.
Memory in C++ is a leaky abstraction .

User avatar
John_Spikowski
Posts: 1544
Joined: Wed Apr 03, 2019 5:53 pm
Location: Anacortes, WA USA
Contact: Website Twitter

Re: General language discussion.

Fri May 17, 2019 10:35 pm

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.

Heater
Posts: 13643
Joined: Tue Jul 17, 2012 3:02 pm

Re: General language discussion.

Fri May 17, 2019 10:46 pm

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.
Memory in C++ is a leaky abstraction .

User avatar
John_Spikowski
Posts: 1544
Joined: Wed Apr 03, 2019 5:53 pm
Location: Anacortes, WA USA
Contact: Website Twitter

Re: General language discussion.

Fri May 17, 2019 10:48 pm

Yeah, like playing in the same ballpark.

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

Heater
Posts: 13643
Joined: Tue Jul 17, 2012 3:02 pm

Re: General language discussion.

Fri May 17, 2019 10:54 pm

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 !
Memory in C++ is a leaky abstraction .

User avatar
John_Spikowski
Posts: 1544
Joined: Wed Apr 03, 2019 5:53 pm
Location: Anacortes, WA USA
Contact: Website Twitter

Re: General language discussion.

Fri May 17, 2019 10:57 pm

Simple. Post your Node code and I'll take it from there.

Heater
Posts: 13643
Joined: Tue Jul 17, 2012 3:02 pm

Re: General language discussion.

Fri May 17, 2019 11:02 pm

Which node code are we talking about?
Memory in C++ is a leaky abstraction .

User avatar
John_Spikowski
Posts: 1544
Joined: Wed Apr 03, 2019 5:53 pm
Location: Anacortes, WA USA
Contact: Website Twitter

Re: General language discussion.

Fri May 17, 2019 11:03 pm

Fibo(87) in JavaScript.

Heater
Posts: 13643
Joined: Tue Jul 17, 2012 3:02 pm

Re: General language discussion.

Fri May 17, 2019 11:24 pm

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)
Memory in C++ is a leaky abstraction .

User avatar
John_Spikowski
Posts: 1544
Joined: Wed Apr 03, 2019 5:53 pm
Location: Anacortes, WA USA
Contact: Website Twitter

Re: General language discussion.

Fri May 17, 2019 11:47 pm

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.

User avatar
Douglas6
Posts: 4778
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: General language discussion.

Fri May 17, 2019 11:49 pm

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.

Return to “Other programming languages”