• Like
  • Save
Nigel hamilton-megameet-2013
Upcoming SlideShare
Loading in...5
×
 

Nigel hamilton-megameet-2013

on

  • 235 views

Perl6 is fast approaching. This talk invites early-adopting, polyglot programmers to start taking a deeper look.

Perl6 is fast approaching. This talk invites early-adopting, polyglot programmers to start taking a deeper look.

Statistics

Views

Total Views
235
Views on SlideShare
235
Embed Views
0

Actions

Likes
1
Downloads
0
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as OpenOffice

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Nigel hamilton-megameet-2013 Nigel hamilton-megameet-2013 Presentation Transcript

    • Perl6 – Am I Bovvered?
    • say “Hello” … X Factor
    • Hello Earthling???!!!
    • But the Genius® at the Apple Storetold me it would connect!!??
    • Who has the X Factor?puts “Hello!”Hello! printNl.print(“Hello!”);System.out.println(“Hello!”);“Am I Bovvered?”
    • “Yeah But No But Yeah”public class HelloWorld {public static void main(String[] args) {System.out.println("Hello!");}}
    • (format t "Hello!~%")#include <iostream>int main () {std::cout << "Hello!" << std::endl;return std::cout.bad();}“Stop giving me evils!”console.log("Hello!");say “Hello!”;
    • Perl5 <=> Perl6→
    • linguistics ~ comp sciLarry Wall ~~ Cunning Linguist
    • Rosetta Stone Codehttp://rosettacode.org● A+ to ZED● 501 Languages● Hundreds of Tasks
    • Expressitivity   # Perl5 old Skoolsub factorial {my $n = shift;my $result = 1;for (my $i = 1; $i <= $n; ++$i) {$result *= $i;};$result;}
    • Iterative / Recursive / Declarative?Expressivesub postfix:<!> { [*] 1 .. $^n }say 5!; # prints 120 
    • [Meta] WAT?­ operators on operators
    • [Reduction Meta Operator]my @numbers = 1 .. 3;say [+] @numbers;say [max] @numbers;say [min] @numbers;say [~] @numbers;say [>] @numbers;say [<] @numbers;say [>] @numbers.reverse;   
    • [Reduction Meta Operator]my @numbers = 1 .. 3;say [+] @numbers; # 6say [max] @numbers; # 3say [min] @numbers; # 1say [~] @numbers; # 123say [>] @numbers; # Falsesay [<] @numbers; # Truesay [>] @numbers.reverse; # True
    • [Reduction Meta Operator]my @numbers = 1 .. 3;say [+] @numbers;say [max] @numbers;say [min] @numbers;say [~] @numbers;say [>] @numbers;say [<] @numbers;say [>] @numbers.reverse;   
    • X product – Meta Operatormy @suits  = <       >;♣ ♢ ♡ ♠my @ranks  = 2..10, <J Q K A>;my @deck   = @ranks X~ @suits;my @hand   = @deck.pick(5);say @hand;nige@hammer:~/megameet­talk$ perl6 hand.p6 7  5  2  J  10♣ ♡ ♣ ♠ ♠
    • Whipupitudemulti sub MAIN ($number-of-nodes) {say "deploy to: $number-of-nodes nodes";}nige@hammer:~/megameet-talk$ perl6 deploy.p6Usage:deploy.p6 <number-of-nodes>
    • Whipupitudemulti sub MAIN (Int $number-of-nodes) {say "deploy to: $number-of-nodes nodes";}nige@hammer:~/megameet-talk$ perl6 deploy.p6 liveUsage:deploy.p6 <number-of-nodes>
    • Whipupitudemulti sub MAIN (Int $number-of-nodes) {say "deploy to: $number-of-nodes nodes";}multi sub MAIN (Bool :$run-tests?,Str :$cluster =staging) {say "running tests" if $run-tests;say "deploying to cluster: $cluster-name";}
    • Whipupitudenige@hammer:~/megameet-talk$ perl6 deploy.p6 --helpUsage:deploy.p6 <number-of-nodes>deploy.p6 [--run-tests] [--cluster-name=<Str>]nige@hammer:~/megameet-talk$ perl6 deploy.p6 --run-tests --cluster=liverunning testsdeploying to cluster: live
    • UtilityBOSS: “I need dates for all the last Fridays of the month for this year”Agile programmer grabs a highlighter and a calendar.BOSS: “Oh, and for any year out of the last 20”Agile programmer opens up a terminal window … and types ...
    • Pythons Last Friday (14 LOC)import calendarc=calendar.Calendar()fridays={}year=raw_input("year")for item in c.yeardatescalendar(int(year)):for i1 in item:for i2 in i1:for i3 in i2:if "Fri" in i3.ctime() and year ini3.ctime():month,day=str(i3).rsplit("-",1)fridays[month]=day
    • Last Friday in Perl6 (5 LOC)sub MAIN (Int :$year = Date.today.year) {my @fri;for Date.new("$year-01-01") .. Date.new("$year-12-31"){@fri[.month] = .Str if .day-of-week == 5;}.say for @fri[1..12];}nige@hammer:~/megameet-talk$ perl6 date.p6 --helpUsage:date.p6 [--year=<Int>]nige@hammer:~/megameet-talk$ perl6 date.p62013-01-25
    • Simple Search EngineInverted Index (11 LOC)sub MAIN (*@files) {(my %norm).push: do for @files -> $file {$file X=> slurp($file).lc.words;}(my %inv).push: %norm.invert.uniq;while prompt("Search terms: ").words -> @words {for @words -> $word {say "$word => %inv.{$word.lc}";}}}
    • Oh my god that is so unfair!package org.rosettacode;import java.io.BufferedReader;import java.io.File;import java.io.FileReader;import java.io.IOException;import java.util.ArrayList;import java.util.Arrays;import java.util.HashMap;import java.util.HashSet;import java.util.LinkedList;import java.util.List;import java.util.Map;
    • -O Fun camelia => http://perl6.org
    • Rosetta Stone Codehttp://rosettacode.org● A+ to ZED● 501 Languages● Hundreds of Tasks