On 8/30/22 13:34, Richard Hainsworth wrote:
Hi Todd,

Long time no see.

Re your 'keeper'. There is a reason why things are called the way they are in Raku (aka Perl6). BEGIN is NOT a special subroutine.

BEGIN is a phaser. And it introduces a block. Blocks are not subroutines (subs). Even though blocks and subs (and methods and callables) are code related things, a sub can take a signature, but a block cannot. You can pass arguments to a block using pointy syntax, eg -> $x, %y {  ... }, which is why it is possible to do things like 'for %some-hash.kv -> $key, $value { .... }'. The 'for' takes a block, which can be pointy. 'for' does not take a special subroutine.

But a sub can have a parameter list, eg., 'sub (Int $b where *>= 10) { say %b }; ' The 'where' bit means that the compiler will put in checks that $b is always greater-equal to 10. So subs are far far more than blocks.

Also you cannot return from a block, but you can return from a sub.

So, by putting in your keeper that BEGIN is a special subroutine, you are ignoring a whole world of Raku goodness, as well as making it difficult for yourself to understand other phasers.

And talking of phasers, there are some really useful ones, like FIRST and LAST, that are in loops. So if you want something to happen first time in a loop, put it in FIRST { }.

Also I see you are on the compile time whine again. When perl6 first became available as 'pugs', it did take FOREVER. Then as more of perl6 became implemented as rakudo, startup times became slower.

Things changed when modules were precompiled. I really do not understand what you are talking about when you say you don't think precompile is useful everywhere.

For example, when I write something that is called from the command line (for example in my raku-collection-raku-documentation distribution), I have a one-liner raku program 'RakuDoc' that just says 'use Collection::RakuDoc'.

EVERYTHING else is in the module Collection::RakuDoc, all the MAIN subroutines, and stuff. That then only gets compiled once. So, the first time RakuDoc is called from the command line, there is a startup delay because the whole module is compiled. Every other time RakuDoc is called, its really so fast I don't notice a problem. Only the *one* line is compiled each time the program is called. All the rest is in precompiled form.

Same with my Extractor program, which is in the raku-extraction module. This is a GUI program that takes the rakudoc (aka POD6) files and converts them into markdown. For example, I write the README's for my github repos as README.rakudoc, then use Extractor to turn it into a README.md. The result is far better because the rakudoc renderer I use (from my pod-render distribution) automatically collects all the headers and puts them into a Table of Contents. If you've tried to do a TOC in markdown, you know what a hassle it is.

But Extractor is a GTK::Simple program. And GTK::Simple takes forever to precompile. But once done, I don't notice any startup time.

And I change my software quite a lot, so every time I change something, yes, startup is slow the first time, but not the next time. Surely, you use a piece of software more than once.

Compared to the OLD days,

Last week ?????  Chuckle.

rakudo programs react like lightning. Design your software properly, and you wont - as a human - notice much of a delay.

I think the startup complaint (not the compile time for something) has been effectively relegated to the days when rakudo was young. So whilst in the past I truly sympathised with your rants about compile times, I am now quite confused and I find sympathy hard to come by.

Since you continue for ever to complain about 'compile' time issues,

"Stage parce" is specifically what I am whining about

rather than startup times, I wonder whether the programs you write are massive monolithic lines of code with thousands of lines, much like most standard software when FORTRAN or COBOL were the high level languages, or whether you design things to make each section more manageable.


$ raku -c --stagestats GetUpdates.pl6
Stage start : 0.000
Stage parse : 17.851
Stage syntaxcheck: Syntax OK

Perl 5 does it over 300 times faster on the code I ported


If the programs you write to be run from the command line are thousands of lines long, then yes!! you will suffer!!! from long!!!! startup times because the program is re-compiled EVERY time. However, if you redesign the code, putting things into classes, roles, subroutines, and Raku-y goody things, you can push stuff into modules, and reduce your calling program to a single line.

When you change your software, do you change every part of it every time? Or do you change some client related interface part? Put the interface part into one module, and the other more stable functionality into other modules. Then when you change the interface part, you dont change the other modules. They have already been compiled. So the first time you start up your program, only the section you have changed gets recompiled, not the entire monolith.

By the way, I assume that you understand the Raku meaning of 'module', as opposed to a 'distribution'. When I write a large piece of software, I may have three or four different modules under the lib/ directory. The top level program (I try to make it one line only), uses one module, which then may use other modules, all of them in the same directory, under the lib/ subdirectory. The distribution can then also contain simple tests under t/ and development tests under xt/

Regards,

Richard



Hi Richard,

Long time no talk to you either.  Don't be a stranger.
(If you like, I can always "whine" about compile times
to get your attention, if you like.  Chuckle.)

Thank you.  That letter took a lot of work!

How does this sound?

     BEGIN is a special block of code called a "phaser"
     that runs at compile time.  It will see any code
     above it, such as variables and  imported modules,
     but not below it.

Speaking of muscle memory, I have not programmed in Modula2
for over 30 years, but I still catch myself wanting to put BEGIN and END on every procedure (M2's name for subs).
Chuckle.


Can you show me an example of FIRST and LAST


To me module means the same thing as in Modula2.  It
is a pm6 file that I import with "use".  Geez, am I
calling that wrong too?  Once compiled, it gets  stuck
in the .precomp directory.  Most of the time that
workaround will work.  Write once; debug everywhere.
Wait.  That is Java.

Where .precomp does not work for me is my software
updates program.  This is a behemoth program (imports
six of my custom modules too) that goes out and checks
for software updates that I support at my customer
sites.  it is about 70 programs.

To do this open the web site with firefox.  Then I
use their developer's tools to examine the page's
source code.  I find the fragment I am looking
for and regex them to extract them.

In the process, I goof the regex/s "A LOT".  Not
to mention  having to chase down hidden character
that do not appear in Firefox's page source.
And download that are different on a web browser
than with curl.

I do have a function that allows me to only run that
one web site's extraction, so I do not have to go
through all 70 of them.

So, I have to recompile the code maybe up to 20 times
depending on the difficulty of the web site.  The
L-O-N-G delays drives me nuts.



   if $PageStatus ne 0  {
      $Status +|= %StatusHash<DOWNLOAD_FAIL>;
      PrintRedErr( "$SubName: failed to download <$WebSite>\n" );

   } else {
        # spurt "eraseme.html", $WebPage;
        #  <h2>Windows</h2>
# <p><a href='https://github.com/darktable-org/darktable/releases/download/release-3.6.1/darktable-3.6.1-win64.exe' title='Microsoft Windows'>darktable-3.6.1-win64.exe</a></p>

      $ClickHere  = $WebPage;
      $ClickHere ~~ s/ .* '<h2>Windows</h2>' //;
      $ClickHere ~~ s/ .*? 'http' /http/;
      $ClickHere ~~ s/ '.exe' .* /.exe/;

      $NewRev  = $ClickHere;
      $NewRev ~~ s/ .* 'darktable-' //;
      $NewRev ~~ s/ '-win64.exe' .* //;

if $Debug { PrintBlue "$SubName: Click Here = <$ClickHere>\n NewRev = <$NewRev>\n\n"; }
   }



It is especially annoying when I get the .* in the
wrong position or I forget the ? on .*?.  The goof ups
are prodigious.  And not to mention the web site
changing all the time.

Was it you that told me how to use Q[] inside a
regex.  If it was, you are my hero!

So .precomp is not always practical.

Speaking of BEGIN, is this Raku's "parallel
processing" method?  Does Raku have a way to
spawn parallel processes and have them talk to
each other?

-T






Reply via email to