Go to advanced search

by Heater
Thu Jun 20, 2019 6:07 am
Forum: Other programming languages
Topic: ScriptBasic
Replies: 1130
Views: 28069

Re: ScriptBasic

This makes no sense to me. High level languages should be cross platform. Even if some libs/modules/extensions are platform specific. Having yet another fork of SB is even more confusing it than it is now. It's more maintenance work. Plenty of people use MySql and such on their Pi. I don't get it.
by Heater
Thu Jun 20, 2019 4:38 am
Forum: General programming discussion
Topic: A Final Fibonacci Challenge
Replies: 565
Views: 15401

Re: A Final Fibonacci Challenge

ejolson, Where is that red line going? Your graphs seem to show that the recursive doubling aka hfibo has a massive overhead compared to the others. It's 10 times slower for small n. But the the curve goes up at a lesser slope and is converging with the others for big n. I'm guessing that slope does...
by Heater
Thu Jun 20, 2019 3:50 am
Forum: General programming discussion
Topic: A Final Fibonacci Challenge
Replies: 565
Views: 15401

Re: A Final Fibonacci Challenge

ScriptBasic, The term golden ratio popped up shortly after I posted the Fibonacci pinecone code. Any connection? Yes. High school maths! If you take any two successive numbers of the Fibonacci sequence and divide the bigger one by the smaller one you get an approximation to the golden ratio. The big...
by Heater
Thu Jun 20, 2019 3:30 am
Forum: Other programming languages
Topic: ScriptBasic
Replies: 1130
Views: 28069

Re: ScriptBasic

Airr, I don't know if using 'top' is the correct way to check for leaks; Top is a pretty crude tool. But when you watch a program running for an hour or so and you see that top reports the memory consumption going up every few seconds, eventually going through 10%, 20% , 40%, 80% of your available 8...
by Heater
Wed Jun 19, 2019 11:09 pm
Forum: Off topic discussion
Topic: Should old threads be locked / warned about
Replies: 3
Views: 75

Re: Should old threads be locked / warned about

Conversely, of course, I feel that often a question asked years ago can still be a valid question today. Not everything is predicated on versions of OS or application code. As such, valid answers, new improved answers, corrections to wrong answers, etc can still be valid contributions. Perhaps they ...
by Heater
Wed Jun 19, 2019 9:14 pm
Forum: General programming discussion
Topic: A Final Fibonacci Challenge
Replies: 565
Views: 15401

Re: A Final Fibonacci Challenge

jalih, Thank you for that. Neat, no recursion! I transcribed it to Javascript like so: // // A non-recusive Fast Doubling Fibonacci algorithm by jalih. // // Transcribed from jalih's BASIC version here: https://www.raspberrypi.org/forums/viewtopic.php?f=31&t=240287&p=1482273#p1482299 // function fib...
by Heater
Wed Jun 19, 2019 8:53 pm
Forum: Other programming languages
Topic: ScriptBasic
Replies: 1130
Views: 28069

Re: ScriptBasic

We already did that in C. The example C code I made for you for kick starting the GMP extension using decimal strings to hold the numbers does not leak memory. See code and memory leak test results here: https://www.raspberrypi.org/forums/viewtopic.php?f=31&t=240287&start=525#p1481907 The problem is...
by Heater
Wed Jun 19, 2019 7:22 pm
Forum: General programming discussion
Topic: A Final Fibonacci Challenge
Replies: 565
Views: 15401

Re: A Final Fibonacci Challenge

ejolson,
I wonder if the iterative computation also leaks memory but just not so fast.
Yes, it does. See my bug report here:
viewtopic.php?f=34&t=238001&p=1482285#p1482283
by Heater
Wed Jun 19, 2019 7:20 pm
Forum: Other programming languages
Topic: ScriptBasic
Replies: 1130
Views: 28069

Re: ScriptBasic

jahboater, I do think most programmers of our generation will have used Fortran. Long ago it was as popular as C is now. Also Fortran 2018 looks like a highly capable modern language. True enough. It's just that after an introduction to programming at tech school in 1973 my next language was ALGOL a...
by Heater
Wed Jun 19, 2019 7:16 pm
Forum: Other programming languages
Topic: ScriptBasic
Replies: 1130
Views: 28069

Re: ScriptBasic

ScriptBasic, You, hippy and ejolson are my three respected members I referred to. Why, thank you. HFIBO is hungriest Fibo at the table Perhaps, but only in the SB encarnation. Also the iterative fibo in 1mildibo.sb leaks memory as well. Out of a suggestion by ejolson I wrapped the 1milfibo program i...
by Heater
Wed Jun 19, 2019 7:06 pm
Forum: General programming discussion
Topic: A Final Fibonacci Challenge
Replies: 565
Views: 15401

Re: A Final Fibonacci Challenge

jalih, Fibo(4784969) using Fast Doubling algorithm needs just one loop and exactly 23 iterations (that is number of bits in 4784969 in binary). Perhaps. I have no idea. What you see above is my first, no doubt naive, attempt at the fast doubling algorithm based on the equations I found here under th...
by Heater
Wed Jun 19, 2019 6:50 pm
Forum: General programming discussion
Topic: A Final Fibonacci Challenge
Replies: 565
Views: 15401

Re: A Final Fibonacci Challenge

ejolson, Are you sure? Theoretically the doubling formulas should iterate somewhere between 22 and 46 times when n=4784969. In both cases it would be interesting to instrument the code with an additional counter or two to see exactly what's going on. I'm sure that the simple fibo in JS, that the Scr...
by Heater
Wed Jun 19, 2019 5:40 pm
Forum: General programming discussion
Topic: A Final Fibonacci Challenge
Replies: 565
Views: 15401

Re: A Final Fibonacci Challenge

ScriptBasic, And you don't see that as a problem? Only in ScriptBasic. I have the same algorithm in Python, Javascript. Some of the Fibo Challenge entries in other languages are very similar. How many WHILE loops do you think AIR's Fibo takes to come up with an answer? Well, there is only one WHILE ...
by Heater
Wed Jun 19, 2019 5:16 pm
Forum: General programming discussion
Topic: A Final Fibonacci Challenge
Replies: 565
Views: 15401

Re: A Final Fibonacci Challenge

ejolson, I thought we decided earlier that no memory leaks are possible in Linux because all user memory is freed by the operating system after the program crashes. Ha! Depends what you mean by memory leak. I took a look under my PC and did not find any memory puddles on the floor. I wonder whether ...
by Heater
Wed Jun 19, 2019 4:00 pm
Forum: General programming discussion
Topic: A Final Fibonacci Challenge
Replies: 565
Views: 15401

Re: A Final Fibonacci Challenge

gkreidl, Of course they are getting smaller, but there are more of them, not just "20 or so (recursions)" as you wrote some posts above. And usually 3 numbers of about half the size are required (not for the first recursion). What I wrote was correct: "That is very different to starting with a bunch...
by Heater
Wed Jun 19, 2019 3:44 pm
Forum: Other programming languages
Topic: ScriptBasic
Replies: 1130
Views: 28069

Re: ScriptBasic

Guys, "Fortran: 65 years old. BBC BASIC: 38 years" I know. I was restricting myself to languages ScriptBasic, or anyone, is likely to have actually used. ScriptBasic, It has taken me almost two months to get three respected members of the forum to try ScriptBasic. Hopefully you guys while help carry...
by Heater
Wed Jun 19, 2019 5:11 am
Forum: Other programming languages
Topic: ScriptBasic
Replies: 1130
Views: 28069

Re: ScriptBasic

"OSBASIC" is a terrible name. I suggest calling it YAFSB :) Going platform specific is a terrible idea. Even if that platform is the Pi. Not being cross-platform would severely limit it's attraction, that after all is a lot of the point of a high level language. It would annoy any existing (not)Scri...
by Heater
Tue Jun 18, 2019 7:53 pm
Forum: General programming discussion
Topic: A Final Fibonacci Challenge
Replies: 565
Views: 15401

Re: A Final Fibonacci Challenge

gkreidl, That's not very precise. I believe what I posted is very precise. There are 1000000 digits in fibo(4784969) There are 500000 digits in fibo(4784969 / 2) There are 250000 digits in fibo(4784969 / 2 / 2) There are 125000 digits in fibo(4784969 / 2 / 2 / 2) ... That accounts for the sizes of t...
by Heater
Tue Jun 18, 2019 7:46 pm
Forum: General programming discussion
Topic: A Final Fibonacci Challenge
Replies: 565
Views: 15401

Re: A Final Fibonacci Challenge

Why does it matter what GMP is made of? We know it does not leak memory when used as prescribed. Don't you recall the code I offered to help create the ScriptBasic extension to use GMP via decimal strings: integer_string.c $ cat integer_strings.c // // An experiment in doing integer arithmetic using...
by Heater
Tue Jun 18, 2019 6:24 pm
Forum: General programming discussion
Topic: A Final Fibonacci Challenge
Replies: 565
Views: 15401

Re: A Final Fibonacci Challenge

At every level of recursion a fibo(n) is making calls to fibo(n/2) and fibo(n/2 + 1)

So the number of digits of the result of each recursion is half as many as the caller is calculating. 500000, 250000, 125000, 62500, 31250....etc.

They get small pretty fast.
by Heater
Tue Jun 18, 2019 6:01 pm
Forum: Other programming languages
Topic: ScriptBasic
Replies: 1130
Views: 28069

Re: ScriptBasic

hippy, How for example do I raise an error when a pin number may be negative ... ? Why, return an imaginary result of course :) But if pin numbers cannot be negative how come they are not held in an unsigned long rather than a signed long? If it were unsigned there would not be this problem. About e...
by Heater
Tue Jun 18, 2019 5:44 pm
Forum: General programming discussion
Topic: A Final Fibonacci Challenge
Replies: 565
Views: 15401

Re: A Final Fibonacci Challenge

ejolson, If you compute the 4784969th Fibonacci number twice or thrice before exiting, does the memory use stabilise at 500MB, or does it continue to increase? As a quick and simple experiment I put this: count = 0 WHILE count < 100 PRINT "count", ": ", count, "\n" PRINT hfibo(4784969),"\n" count = ...
by Heater
Tue Jun 18, 2019 5:16 pm
Forum: General programming discussion
Topic: A Final Fibonacci Challenge
Replies: 565
Views: 15401

Re: A Final Fibonacci Challenge

ScriptBasic, I'm curious how JavaScript stores its recursive state that makes it more efficient than ScriptBasic? Good question. I have no idea of the internal of Javascript engines but from what I have gathered: JS uses a stack for return addresses and local variables, just like most other language...
by Heater
Tue Jun 18, 2019 6:48 am
Forum: Off topic discussion
Topic: how heavy is raspbian ?
Replies: 30
Views: 995

Re: how heavy is raspbian ?

drgeoff, I need more persuasion about that. Yes the mass and energy relationship applies when mass is changed and energy released/created (or vice-versa) but is that applicable here? You the General Theory of Relativity. It's been out for over 100 years now :) You may have heard that relativity pred...
by Heater
Tue Jun 18, 2019 6:27 am
Forum: Other programming languages
Topic: ScriptBasic
Replies: 1130
Views: 28069

Re: ScriptBasic

The expected normal way to do this is:

$ make clean

To remove all build products.

It did not occur to me to use that here because we are using a weird build system.

Go to advanced search