Page 1 of 3 123 LastLast
Results 1 to 10 of 22

Thread: Yet another unknown language

  1. #1
    Guest

    Yet another unknown language

    Factorial using Python, Perl (for Ashcrow and Feztaa) and Pike 7.2. Here are the time outputs.

    Python:
    ./fact.py 65536 215.14s user 5.06s system 91% cpu 3:59.47 total
    Perl (is not yet finished, but here's the latest output from top):
    2548 vince 19 0 67548 65M 1108 R 99.0 17.5 400:04 perl
    Pike:
    ./fact.pike 65536 36.60s user 4.01s system 91% cpu 40.626 total

    Want to see what the Pike program looks like:
    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;
    }
    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.

  2. #2
    Guest

    Re: Yet another unknown language

    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

  3. #3
    Guest

    Re: Yet another unknown language

    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.

  4. #4
    Guest

    Re: Yet another unknown language


    A moderator that double-posts? ;D
    It happens sometimes, I have trouble connecting when pressing post. I usually remove the dbl posts, but sometimes one slips by me.

  5. #5
    Guest

    Re: Yet another unknown language

    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.

  6. #6

    Re: Yet another unknown language

    I am too lazy to do research right now, but what are the advantages of Pike over C++?

  7. #7
    Guest

    Re: Yet another unknown language

    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.

  8. #8
    Guest

    Re: Yet another unknown language

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

  9. #9
    Guest

    Re: Yet another unknown language

    +10 Hours

  10. #10
    Guest

    Re: Yet another unknown language

    Approaching 11 hours.

    2548 vince 20 0 68120 66M 1108 R 92.8 17.7 640:53 perl
    There's something wrong. The thing works, I tried it with 100, 500, 1000 and it works (but it's still MUCH slower than Python and Pike)

Similar Threads

  1. language bar not showing on task bar
    By alexdabiri in forum Windows - General Topics
    Replies: 2
    Last Post: 03-24-2006, 07:27 PM
  2. Asus A8N-E problem...maybe
    By Rockhound in forum Linux - Hardware, Networking & Security
    Replies: 8
    Last Post: 02-09-2006, 01:41 AM
  3. Unknown Hard Error = ?
    By -=<Night Wolf>=- in forum Windows - General Topics
    Replies: 2
    Last Post: 09-19-2005, 01:20 PM
  4. suse sources
    By mojo jojo in forum Linux - General Topics
    Replies: 17
    Last Post: 09-08-2004, 03:45 AM
  5. OpenOffice language modules
    By kungfuramone9 in forum Linux - General Topics
    Replies: 5
    Last Post: 08-16-2004, 03:51 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •