Hrmm that looks alot like C++ to me, I might even understand it.... YEAH... rock on !
Pike you say... blazing fast you say....
/me rushs off to find pike tutorials
Factorial using Python, Perl (for Ashcrow and Feztaa) and Pike 7.2. Here are the time outputs.
Python:
Perl (is not yet finished, but here's the latest output from top):./fact.py 65536 215.14s user 5.06s system 91% cpu 3:59.47 total
Pike:2548 vince 19 0 67548 65M 1108 R 99.0 17.5 400:04 perl
./fact.pike 65536 36.60s user 4.01s system 91% cpu 40.626 total
Want to see what the Pike program looks like:
This is pretty familiar, isn't it? :-) Pike uses GMP to handle BigInt's, so this might explain why Pike is so blazing fast. I think Python implemented their own in C, and Perl did theirs in Perl AFAIK.Code:#!/usr/bin/env pike7.2 int fact(int n) { int total = 1; int i; for (i = 1 ; i <= n ; i++) total *= i; return(total); } int main(int argc, array(string) argv) { if (argc < 2) { write("Usage: %s <Integer>\n", argv[0]); exit(1); } int number = (int)argv[1]; int ans = fact(number); write("%d\n", ans); return 0; }
Hrmm that looks alot like C++ to me, I might even understand it.... YEAH... rock on !
Pike you say... blazing fast you say....
/me rushs off to find pike tutorials
A moderator that double-posts? ;D
Yeah, it's not too hard. And it has goos string manipulation, OO programming, etc. Definitely worth looking at.
It happens sometimes, I have trouble connecting when pressing post. I usually remove the dbl posts, but sometimes one slips by me.A moderator that double-posts? ;D
And yeah, Pike is one cute language. I prefer Python, but for someone that wants to do C/C++ later or that knows C/C++ and wants something to do scripting without relearning everything, Pike is an intelligent choice.
I am too lazy to do research right now, but what are the advantages of Pike over C++?
Pike is interpreted, so there's no need to wait after compiling. A good string module, bigint's are done automatically if you have GMP installed, the OO model is said to be cleaner.
And can we say that Perl is probably never gonna finish? It's been running for 10 hours and 33 minutes now... I mean, it may be a big number, but damn, Pike got it in 40 seconds, Python 3m40s...
+10 Hours![]()
![]()
![]()
![]()
Bookmarks