Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
PerlMonks (I know Kung Fu)

by Anonymous Monk
on Aug 30, 2019 at 09:25 UTC ( #11105299=CUFP: print w/replies, xml ) Need Help??


Saved as
#!/usr/bin/perl my $h = "hello"; my $w = "world"; for (my $i = 0; $i < 3; $i++) { print "$h $w \n"; } my $n = 0; my $x = 100000000; for (my $i = 0; $i < $x; $i++) { $n++; } print "\n"; print "Counted to $n \n";
perl < | tee hw.cpp && g++ hw.cpp -o hw.o && time pe +rl && time hw.o
#include <iostream> int main(){ //!/usr/bin/perl std::string h("hello"); std::string w("world"); for (double i=0; i < 3; i++) { std::cout << "" << h << " " << w << " \n"; } double n=0; double x=100000000; for (double i=0; i < x; i++) { n++; } std::cout << "\n"; std::cout << "Counted to " << n << " \n"; return 0; }
Observed discrepancy:
perl	0m3.213s
c++	0m0.298s
Cool use for Perl, to learn a little C++!

Replies are listed 'Best First'.
Re: (I know Kung Fu)
by Discipulus (Abbot) on Aug 30, 2019 at 11:15 UTC
    First line by the author, after shebang:

    > # A horrible prototype of a Perl to C++ compiler.

    But interesting ;)


    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: CUFP [id://11105299]
Approved by Discipulus
Front-paged by Discipulus
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2020-06-05 13:59 GMT
Find Nodes?
    Voting Booth?
    Do you really want to know if there is extraterrestrial life?

    Results (38 votes). Check out past polls.