Skip to content

Instantly share code, notes, and snippets.

@cygx
cygx / myths.md
Created July 8, 2019 22:04
Perl 6 Myths, Revisited

Perl 6 Myths, Revisited

Perl 6 will never be finished

Perl 6 has had two proper language releases, v6.c in Dec 2015 and v6.d in Nov 2018, with accompanying compiler releases.

The language is not 'finished' insofar that parts of the original design have yet to be realized (eg macros), and as any language that isn't dead, it continues to evolve to meet developers' needs.

Perl 6 has a bizarre ecosystem

@cygx
cygx / bench.p6
Last active July 15, 2019 18:39
Performance of Perl6 string operations
use v6;
my $N = 100_000;
my %words;
print "generating input...";
my $input = join '', map { "$_\t42\n" }, 1..$N;
print "done.\n";
sub bench($name, &code) {
sub catch-control {
my $the-answer = 42;
CONTROL {
die "Caught a CONTROL ({.gist})";
}
die "forced exception";
say "resumed!";
}
for 1 {
use NativeCall;
use Native::Types;
use TinyCC::Eval;
my $i := cref(longlong);
$i = 123;
EVAL q:to/__END__/, :lang<C>, :symbols(i => $i.VAR.ptr);
extern long long i;
@cygx
cygx / eval-nqp.p6
Last active October 31, 2015 21:50
multi EVAL(Cool $code, Str() :$lang! where 'NQP', *%_) {
use nqp:from<NQP>;
EVAL $code, :lang<nqp>, |%_;
};
EVAL 'my int $i := 42; say($i)', :lang<NQP>;
@cygx
cygx / bench.nqp
Last active October 14, 2015 17:25
P5 vs P6 shootout
my $N := 100_000;
my %words := hash();
print("generating input...");
my @lines := [];
my $i := 1;
while $i <= $N {
@lines.push("$i\t42\n");
++$i;
}
@cygx
cygx / money.nqp
Last active August 29, 2015 14:21
my int $s := -1;
while ++$s <= 9 {
next if $s == 0;
my int $e := -1;
while ++$e <= 9 {
next if $e == $s;
my int $n := -1;
while ++$n <= 9 {
@cygx
cygx / bench.p6
Last active August 29, 2015 14:20
# https://raw.githubusercontent.com/kevina/wordlist/master/pos/part-of-speech.txt
my $input = slurp('part-of-speech.txt');
my %words;
sub bench(&code) {
%words = ();
my $start = now;
code;
my $end = now;
use lib <libc tinycc>;
use libc;
use TinyCC <tinycc/libtcc>;
my $p = libc::malloc(4).to(libc::int);
$p.lv = 42;
tcc.target(:MEM).set('-Ltinycc');
tcc.declare(x => $p);
@cygx
cygx / nqp.c
Last active August 29, 2015 14:17
nqp fakecutable
#include <moar.h>
extern MVMuint8 _binary_MASTNodes_moarvm_start[65534];
extern MVMuint8 _binary_MASTOps_moarvm_start[118564];
extern MVMuint8 _binary_ModuleLoader_moarvm_start[12282];
extern MVMuint8 _binary_nqp_moarvm_start[967444];
extern MVMuint8 _binary_NQPCORE_setting_moarvm_start[49056];
extern MVMuint8 _binary_NQPHLL_moarvm_start[370149];
extern MVMuint8 _binary_nqpmo_moarvm_start[87514];
extern MVMuint8 _binary_NQPP5QRegex_moarvm_start[282448];