Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

About using rperl

by hakonhagland (Scribe)
on Aug 13, 2019 at 09:13 UTC ( #11104372=perlquestion: print w/replies, xml ) Need Help??

hakonhagland has asked for the wisdom of the Perl Monks concerning the following question:

I just saw this video https://www.youtube.com/watch?v=NyphRo5roV0 about RPerl. Maybe I am missing something, but how can this be useful?
  • If I want fast code, I can write it directly in C++, why would I use RPerl?
  • As I understand it, I cannot use CPAN modules with rperl? They first have to be rewritten to comply with the restricted sub set of Perl? It feels like this is a major issue
  • If I find a piece of a large perl program that needs optimization, how can I use rperl to optimize only that part of the code? Do I compile the code first into a shared library, and then load it at run time using DynaLoader? Then, why not just write an XS-module?
Note: I am not trying to criticize the project. I found it very interesting. I am just trying to understand how it can be used in practice. Thanks!

Replies are listed 'Best First'.
Re: About using rperl
by LanX (Saint) on Aug 13, 2019 at 09:41 UTC
    I'm not an expert on rperl, but I think the answer to your third question should be obvious.

    > Then, why not just write an XS-module?

    XS modules are not easy to write. Being able to write high performance code in "pure" Perl should be an advantage.

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

      Yes I agree! It would be great to see an example of how to call a sub in the shared library from regular Perl code.
        It would be great to see an example of how to call a sub in the shared library
        I haven't seen such example of code, but I attended a talk by Will Braswell a few months ago, and asked whether it is feasible, and Will answered that it is possible. So you could have your CPU intensive nested loops or other computations in a RPerl module, and the rest in a regular Perl program. This looks very interesting to me, because it seems easier to write a RPerl module than an XS module.
Re: About using rperl
by dave_the_m (Monsignor) on Aug 13, 2019 at 11:26 UTC
    As far as I can tell, RPerl is perl but with every feature which makes perl either useful or "perlish" removed.

    Dave.

      Yeah, I definitely get your point and I mostly agree. And I probably don't want to write a full RPerl application.

      But if I could write my main program in Perl and have my limited CPU intensive part(s) of the code (e.g. deeply nested loops) in RPerl, maybe I could have the best of two worlds: high speed of compiled programs for the CPU intensive part, and the high expressive power of Perl for the rest of the program.

      I once agree with you, but now I don't. you think RPerl is not real perl, just because rperl is not smart enough yet.

      I don't talk with Will Braswell, But I believe that his target is Rperl will be a compiler for perl which compile all no magic perl code but remain magic perl for perl itself automatically!. That would save a lot of time to manual write C/XS code for performance.

        If RPerl ever starts to be able to seamlessly e.g. mix in regexes, use $1, declare lexical vars without types, become able to use a string var as an integer without an explicit conversion, etc etc, then I will of course revise my opinion of it.

        Dave.

Re: About using rperl
by Anonymous Monk on Aug 14, 2019 at 02:31 UTC

    If I want fast code, I can write it directly in C++, why would I use RPerl?

    Why write directly in C++ when you can write directly in perl? rperl writes the c++ for you

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11104372]
Approved by marto
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2023-09-24 17:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?