21
A first go at Perl 6 “Weather App” Florent Mara <[email protected]>

A first go at Perl 6 “Weather App”...Instructions to install Perl 6 are different on Perl6.org Weather App Workshop - part 2 / 3 More about the benefits of writing design documentation

  • Upload
    others

  • View
    4

  • Download
    0

Embed Size (px)

Citation preview

Page 1: A first go at Perl 6 “Weather App”...Instructions to install Perl 6 are different on Perl6.org Weather App Workshop - part 2 / 3 More about the benefits of writing design documentation

A first go at Perl 6“Weather App”

Florent Mara <[email protected]>

Page 2: A first go at Perl 6 “Weather App”...Instructions to install Perl 6 are different on Perl6.org Weather App Workshop - part 2 / 3 More about the benefits of writing design documentation

Introduction

What this presentation is● A first attempt at a Perl 6 application● Potentially solving a problem ● WARNING: Contains some Perl code!

What it is not● Perl 5 versus Perl 6● Me knowing everything about Perl 6 (or Perl 5)● A review of Perl 6 features

Page 3: A first go at Perl 6 “Weather App”...Instructions to install Perl 6 are different on Perl6.org Weather App Workshop - part 2 / 3 More about the benefits of writing design documentation

Disclaimer

This presentation is largely based on “Perl 6 Hands-on workshop: Weatherapp” written by Zoffix Znet (aka Peter Evans)

Page 4: A first go at Perl 6 “Weather App”...Instructions to install Perl 6 are different on Perl6.org Weather App Workshop - part 2 / 3 More about the benefits of writing design documentation

Weather App Workshop - part 1 / 3

● Project purpose:

“... build an application that talks to an API. The app will tell us weather at a location we provide.”

● Preparation covers git (but not Perl6) ● Design doc: DESIGN.md● Research and prior art:

○ Perl 6 returned no results ○ Multi-languages: C with NativeCall, one of the 8 Inline::* modules○ Perl 5 Weather::Underground and Weather::OpenWeatherMap

Page 5: A first go at Perl 6 “Weather App”...Instructions to install Perl 6 are different on Perl6.org Weather App Workshop - part 2 / 3 More about the benefits of writing design documentation

Installing Perl 6

● Google first result: Rakudo.org○ git clone https://github.com/tadzik/rakudobrew ~/.rakudobrew

echo ‘export Path=~/.rakudobrew/bin:$PATH >> ~/.bashrcsource ~/.bashrc

rakudobrew build moarrakudobrew build panda

panda install Task::Star

● Instructions to install Perl 6 are different on Perl6.org

Page 6: A first go at Perl 6 “Weather App”...Instructions to install Perl 6 are different on Perl6.org Weather App Workshop - part 2 / 3 More about the benefits of writing design documentation

Weather App Workshop - part 2 / 3

● More about the benefits of writing design documentation● … and talking to ‘the future boss’● … and tests● … and user documentation● … and sound architecture

-> Adding ‘General Outline’ and ‘Interface Details’ sections into DESIGN.md

Page 7: A first go at Perl 6 “Weather App”...Instructions to install Perl 6 are different on Perl6.org Weather App Workshop - part 2 / 3 More about the benefits of writing design documentation
Page 8: A first go at Perl 6 “Weather App”...Instructions to install Perl 6 are different on Perl6.org Weather App Workshop - part 2 / 3 More about the benefits of writing design documentation

Weather App Workshop - part 3 / 3

● Test driven development● Install testing modules: panda install Test::When Test::Meta● Test files use .t extension and are located in t/ directory● Documents a recommended folder structure

Page 9: A first go at Perl 6 “Weather App”...Instructions to install Perl 6 are different on Perl6.org Weather App Workshop - part 2 / 3 More about the benefits of writing design documentation

Weather App Workshop - part 3 / 3

● t/01-use.t, t/author/01-meta.t and

Page 10: A first go at Perl 6 “Weather App”...Instructions to install Perl 6 are different on Perl6.org Weather App Workshop - part 2 / 3 More about the benefits of writing design documentation
Page 11: A first go at Perl 6 “Weather App”...Instructions to install Perl 6 are different on Perl6.org Weather App Workshop - part 2 / 3 More about the benefits of writing design documentation

Running tests

● prove -e ‘perl6 -Ilib’ -vr t/● Or alias the command

○ alias prove6=”prove -e ‘perl6 -Ilib’ -vr”○ prove6 t/

That’s it!

Page 12: A first go at Perl 6 “Weather App”...Instructions to install Perl 6 are different on Perl6.org Weather App Workshop - part 2 / 3 More about the benefits of writing design documentation

Why look at Perl6?

● Math that works● Useful types and simpler sigils● Function signatures● Optional gradual typing● Vector operators● Parallelism, concurrency and asynchrony● …● Something called OO (?!?)

Page 13: A first go at Perl 6 “Weather App”...Instructions to install Perl 6 are different on Perl6.org Weather App Workshop - part 2 / 3 More about the benefits of writing design documentation

Some Perl6 code - fibonacci

Page 14: A first go at Perl 6 “Weather App”...Instructions to install Perl 6 are different on Perl6.org Weather App Workshop - part 2 / 3 More about the benefits of writing design documentation

More Perl6 code - A Class

Page 15: A first go at Perl 6 “Weather App”...Instructions to install Perl 6 are different on Perl6.org Weather App Workshop - part 2 / 3 More about the benefits of writing design documentation

More Perl6 code - Parallel Computing

Found bug #123072

Page 16: A first go at Perl 6 “Weather App”...Instructions to install Perl 6 are different on Perl6.org Weather App Workshop - part 2 / 3 More about the benefits of writing design documentation

Random Perl 6 features

Page 17: A first go at Perl 6 “Weather App”...Instructions to install Perl 6 are different on Perl6.org Weather App Workshop - part 2 / 3 More about the benefits of writing design documentation

Conclusion

● No weather app

● Easy to get started● Powerful features● Familiar technology for Perl developers● Most of it works already● What next? Complete the weather app

Page 18: A first go at Perl 6 “Weather App”...Instructions to install Perl 6 are different on Perl6.org Weather App Workshop - part 2 / 3 More about the benefits of writing design documentation

Addendum - Webservice::Weather

● Perl 6 Weather module

Page 19: A first go at Perl 6 “Weather App”...Instructions to install Perl 6 are different on Perl6.org Weather App Workshop - part 2 / 3 More about the benefits of writing design documentation

Bonus slide 1 - some Perl 5

Which is slowest?

Neither (~100ms)

Page 20: A first go at Perl 6 “Weather App”...Instructions to install Perl 6 are different on Perl6.org Weather App Workshop - part 2 / 3 More about the benefits of writing design documentation

Bonus slide 2

Which is slowest?

~ 600 ms > 300 ms

Page 21: A first go at Perl 6 “Weather App”...Instructions to install Perl 6 are different on Perl6.org Weather App Workshop - part 2 / 3 More about the benefits of writing design documentation

Florent Mara<[email protected]>

Questions