Perl 6 Hands-On Workshop: Weatherapp (Part 1)

Read this article on Perl6.Party

Welcome to the Perl 6 Hands-On Workshop, or Perl 6 HOW, where instead of learning about a specific feature or technique of Perl 6, we'll be learning to build entire programs or modules.

Knowing a bunch of method calls won't make you a good programmer. In fact, actually writing the code of your program is not where you spend most of your time. There're requirements, design, documentation, tests, usability testing, maintenance, bug fixes, distribution of your code, and more.

This Workshop will cover those areas. But by no means should you accept what you learn as authoritative commandments, but rather as reasoned tips. It's up to you to think about them and decide whether to adopt them.

Project: "Weatherapp"

In this installment of Perl 6 HOW we'll learn how to build an application that talks to a Web service using its API (Application Programming Interface). The app will tell us weather at a location we provide. Sounds simple enough! Let's jump in!

Preparation

Virtual Spring Cleaning (part 10 of X) wherein I tackle finances

One of my tasks when I'm not working or writing Perl code is to keep the finances of the Frankfurt Perlmongers e.V. club in order. Part of this is doing the taxes but a more important part is to pay the incoming invoices in time and to keep all the receipts for this in order. As we do most transfers electronically, it was a long-term goal for me to provide the board with an automated monthly account statement.

Playing with Docker and Sparrow

Docker is quite popular solution to rapidly spin up developers environments. I have been playing with it and it seems fun for me. The other fun thing I found that Sparrow could be a good solution to build up new docker images.

Here is short example of how it could be. A few lines in Dockerfile and you have a GitPrep server up and running as docker container. Whew!

Here is my Dockerfile:

FROM perl:5.20
RUN apt-get update
RUN apt-get install sudo
RUN apt-get install git-core
RUN cpanm Sparrow
RUN sparrow index update
RUN sparrow index summary
RUN sparrow plg install gitprep
RUN sparrow plg run gitprep
CMD sparrow plg run gitprep --param action=start --param start_mode=foreground

I base on official perl docker image and then let all the job to be done by sparrow gitprep plugin!

This is how one can use it:

$ git clone https://github.com/melezhik/docker-projects.git
$ cd docker-projects/gitprep

Travis-CI and Perl

If you're interested into using Travis-CI for your Perl projects, here's a few pointers that you should not miss:

Too bad that it took me so long to find them out.

Working on getting the Perl 6 setting to compile.

Currently rakudo.js is at the point where:
node rakudo.js --setting=NULL -e 'use nqp; nqp::say "Hello World"'
works but node rakudo.js -e 'say "Hello World"' doesn't.

What's needed for the later is to get rakudo.js (Rakudo compiled to JavaScript) to compile the setting

The general work-flow for that is:
  1. Try to compile the setting with rakudo.js.
  2. While rakudo.js is compiling some error appears.
  3. I then figure out wheter it's a result of a missing feature or some bug in the js backend.
  4. I implement the feature and write tests for it or fix the bug.
  5. I then repeat the process.

Lather, rinse, repeat.

Until the setting compiles Rakudo.js is not yet usable by users.
Even getting something very simple like say "Hello World" requires a fair chunk of the setting to work.

The rakudo specific work is done in the js branch of rakudo https://github.com/rakudo/rakudo/tree/js.
Most of the work on the backend itself is done in the master branch in the nqp repo.

Veure's Database

I recently wrote about Veure's test suite and today I'll write a bit about how we manage our database. Sadly, this will be a long post because it's a complicated problem and there's a lot to discuss.

When I first started Veure, I used SQLite to prototype, but it's so incredibly limited that I quickly switched to Postgres. It's been a critically important decision, but I want to take a moment to explain why.

All software effectively has four "phases" which amount to:

  1. Initialization
  2. Input
  3. Calculation
  4. Output

Note that we could rewrite the above as:

  1. Initialization of data
  2. Input of data
  3. Calculation of data
  4. Output of data

Notice a pattern?

Yeah, I thought so. There are all sorts of areas where we could get things wrong in software, but the further down the stack(s) you go, the more care you need to take because the more damaging bugs can be. Data storage is often pretty low in your stack and you don't want to get this wrong. So what happens?

Perl 5 Porters Mailing List Summary: May 10th-18th

Hey everyone,

Following is the p5p (Perl 5 Porters) mailing list summary for the past week. Enjoy!

Perl 6 .polymod: Break Up a Number Into Denominations

Read this article on Perl6.Party and play with code examples right in your browser!

Back in the day, I wrote Perl 5 module Number::Denominal that breaks up a number into "units," say, 3661 becomes '1 hour, 1 minute, and 1 second'. I felt it was the pinnacle of achievement and awesome to boot. Later, I ported that module to Perl 6, and recently I found out that Perl 6 actually has .polymod method built in, which makes half of my cool module entirely useless.

Today, we'll examine what .polymod does and how to use it. And then I'll talk a bit about my reinvented wheel as well.

Denominated

The .polymod method takes a number of divisors and breaks up its invocant into pieces:

my $seconds = 1 * 60*60*24 # days
            + 3 * 60*60    # hours
            + 4 * 60       # minutes
            + 5;           # seconds

say $seconds.polymod: 60, 60;
say $seconds.polymod: 60, 60, 24;

# OUTPUT:
# (5 4 27)
# (5 4 3 1)

About blogs.perl.org

blogs.perl.org is a common blogging platform for the Perl community. Written in Perl and offering the modern features you’ve come to expect in blog platforms, the site is hosted by Dave Cross and Aaron Crane, with a design donated by Six Apart, Ltd.