| I don't necessarily want to wade into the discussion on the tone of the article, but I do want to detail something I've used Perl 6 for that makes me really enjoy working with the language. I've noticed a trend in threads where P6 comes up: I rarely see people actually point to specific instances where P6 features have been helpful. This lack of examples certainly doesn't help push back against the idea that the language isn't usable or, indeed, useful with anything less than 100% of the spec implemented. I use P6 for all of my small deployment scripts (as well as a number of small utilities I've written, like a tmux wrapper). It gets out of my way when I just need something quick and useful from the start. For example it's exceedingly easy to wrap other utilities because arguments to MAIN generate a command line interface automatically. It also provides features that help me as I move from a useful-but-dirty prototype to a more maintainable script or piece of a more complex system. Gradual typing is a big part of this. I tend not to add types for most things, but it's very easy to use the P6 type system to watch my back when I do want that help. It's not as good at catching things before runtime as a hardcore static type system, but it manages to warn me "... will never succeed with declared signature ..." often enough. I have a no-frills, no-auth file sharing site I deploy periodically to get a web front-end to share things with people (usually already on a VPN, sometimes just on a LAN). At the moment, I use a simple deploy script to do this manually, but I'm considering setting something up to automatically deploy it when connecting to a particular network. I almost definitely won't get that part right on the first try and would really rather not end up accidentally deploying a no-auth filesystem on my server's public IP address. Using the P6 type system, I can easily define a subset of IPv4 addresses: my @private-ranges = <10.0.0.0/8 172.16.0.0/12 192.168.0.0/16>;
subset IPv4::Private of IPv4 where -> $ip { Net::Netmask.new(any @private-ranges).match($ip) };
Then simply defining MAIN with a typed (and named, in this case, hence the colon) argument will handle all the checking at the type level. sub MAIN(IPv4::Private :$ip) { ... }
Now I won't be able to deploy this service on a public IP as long as I use this deploy script as a primitive in whatever eventual solution I end up with, and the automatically generated usage message even helps communicate why a call failed (provided you have descriptive type/parameter names). λ | ./deploy --ip=$(dig +short myip.opendns.com @resolver1.opendns.com)
Usage:
./deploy.p6 [--ip=<Private>]
λ | ./deploy --ip=10.0.0.2
Deploy successful.
|