mersenneforum.org

mersenneforum.org (https://www.mersenneforum.org/index.php)
-   Programming (https://www.mersenneforum.org/forumdisplay.php?f=29)
-   -   PHP vs. Python vs. C (all with GMP) (https://www.mersenneforum.org/showthread.php?t=19131)

daxmick 2014-02-09 10:08

PHP vs. Python vs. C (all with GMP)
 
I've written a PHP script that uses sqlite as a backend database. My goal is to collect "all" the primes starting with 2.

I've done *some* work with PHP and C relating to large numbers, using GMP, but I haven't played with Python any more than printing out "Hello World".

That said, is 1 language better than another? I understand that compiled code executes faster but once the program is loaded into memory aren't they all pretty much the same?

Mini-Geek 2014-02-09 20:54

[QUOTE=daxmick;366486]My goal is to collect "all" the primes starting with 2.[/QUOTE]
There are an infinite number of primes. What are you really trying to do?

[QUOTE=daxmick;366486]I've written a PHP script that uses sqlite as a backend database. My goal is to collect "all" the primes starting with 2.

I've done *some* work with PHP and C relating to large numbers, using GMP, but I haven't played with Python any more than printing out "Hello World".

That said, is 1 language better than another? I understand that compiled code executes faster but once the program is loaded into memory aren't they all pretty much the same?[/QUOTE]

In practice, you might have bottlenecks for various reasons. In the specific context of using GMP, it shouldn't matter much which you use, since I'd assume the bulk of the work is done in the GMP library's code, not in yours.

daxmick 2014-02-10 01:45

[QUOTE=Mini-Geek;366529]There are an infinite number of primes. What are you really trying to do?

I know that, hence the quotes around "all". My goal is just to start accumulating the primes starting with 2 and going forward till I can no longer go! No real reason other than just to do it.

In practice, you might have bottlenecks for various reasons. In the specific context of using GMP, it shouldn't matter much which you use, since I'd assume the bulk of the work is done in the GMP library's code, not in yours.[/QUOTE]

That is what I figured too. However, I came across something interesting about PHP GMP. (Damn, I can't find the URL I was reading or I'd post it here.) Anyway, the info was something to the effect that PHP's GMP can only handle 2^31 digits until their new code comes out and then it will be 2^63 digits. (It could have been an old post too bear in mind.)

Not that I plan on reaching either of those limits any time soon but I hadn't seen those limitations in C. Just saying.


All times are UTC. The time now is 04:21.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.