Bailador
Bailador is a light-weight route-based web framework similar to Perl Dancer, Ruby Sinatra, and Python Flask.
This book is going to be about web development in Perl 6 using Bailador.
A few words about myself
I've been using Perl 5 since 1995 and teaching it since 2000. In addition to the basic
Perl Programming course I have developed and taught several additional courses: an
Advanced Perl programming course; a course called
Test Automation Using Perl; and a course called
Web Development Using Perl.
In addition, I have taught courses combining a Perl-based backend with frontend written in JavaScript, JQuery, and AngularJS.
In the last couple of years I have also extensively used Python Flask for several web applications.
I run the Perl Maven website with 770 articles about Perl 5 that receive approximately 10,000 visits a day. I created the Perl Weekly newsletter that has more than 6,000 subscribers. The Perl 6 Maven has more than 50 articles. The Code Maven site has more than 200 articles about languages that are not Perl. Other sites and projects are listed on my home page.
Altogether I've written over 1,000 articles in the last couple of years. If you are interested in my writing style, head over to either of the Maven sites and check out your favorite subjects. Specifically you might want to take a look at the articles about Bailador.
The Perl 6 Maven site has been running on Bailador and Rakudo Perl 6 for several years now on a simplified blog engine. Its source code is available here.
I have been using Perl 6 on and off for several years now and a couple of years ago I also taught several courses of Perl 6. In Oslo, Lisbon, and Frankfurt.
Perl 6 books
... that will show you it is time for this book.
A handful of Perl 6 books have been published, and there are more in the works. There is a desire for Perl 6 books from both publishers and developers. Given the importance of web development, it’s time for a web development book for Perl 6.
Andrew Shitov published
Perl 6 at a Glance and he is working on
Migrating to Perl 6 now.
Laurent Rosenfeld with Allen B. Downey has finished Think Perl 6. It is also available as a free download.
Moritz Lenz is close to the finish line with Perl 6 Fundamentals.
brian d foy is working on the Learning Perl 6 book.
I think it is time to publish a book about Web development using Perl 6.
Crowd-funding
Writing well researched articles is not an easy task. Preparing teaching material is really difficult. Writing a book is the combination of the two.
In addition, for this book I'll have to develop several web applications. It needs a lot of time. Ther are also other expenses. Like the bailador.net domain name, the design of a logo, the hosting of the web site together with the demo site. As the book will be self-published through LeanPub all this expense falls on me.
I believe by the time I finish writing the book in December there will more than a 1,000 who will want to buy it, but having many supporters up front will encourage me much more.
Indiegogo, allows for partial funding of a project. That means any amount contributed will be used. Basically you can think about it as buying the book at a discount and showing the other potential readers that there is interest.
The planned date for publishing the final version is December 2017.
What happens if the crowdfunding goal is not reached?
I definitely want to produce something that will be valuable to those who supported the book. So I'll write the book even if we don't reach the goal.
However, if you did not support support the book, you'll have to pay more for the book and you'll also miss out on the opportunity to show your support.
Planned Chapters
The chapters are a work in process, and as with all works in progress, the details may evolve or change completely as I work on it. But the following gives my current plan. Moreover, you are more than welcome to suggest changes!
Hello World
In this chapter we set up the basic environment for developing our web application.
- Install and set up Rakudo Perl 6
- "Hello World" on the command line
- Install Bailador
- "Hello World" with Bailador
- Testing the "application" so far
- Adding to Git and GitHub
- Setting up Continuous Integration using Travis-CI
Deployment
Most of the books will put the deployment to the end of the book
or skip it entirely. In today's world of Continuous Integration
and Continuous Deployment we need to make sure we can deploy
our application from the very beginning. Even if it is as simple
as our "Hello World" application. Then we need to keep deploying to ensure
the pipe never breaks.
- Configuring Nginx as a reverse proxy
- Configuring Apache as a reverse proxy
- Deploying on Ubuntu
- Using Docker
Database access
Most of the web applications have some kind of relational database behind them.
In this chapter we are going to see how to set up and configure three of them:
- Use SQLite
- Configuring MySQL
- Configuring PostgreSQL
- Database access from Perl 6
- Command line program to access the database
- CRUD (Create, Read, Update, Delete) from the command line
User Input
- Echo with Bailador
- Counter that stores the count in a text file.
- Processing forms
- Input validation
- Counter that stores the count in a database.
Sessions
- Cookies
- Session management
Cookbook
- Sending e-mail
- Hashing Passwords
- Registration process with double-opt-in
- Change Password (when logged in)
- Reset forgotten password process
- IP based access restriction (2-step verification with e-mail)
- Secure initial configuration of web application
- Uploading files (e.g. images)
API and Ajax
- Creating an API that returns JSON
- Ajax - interaction between the client and the server.
- Client side in plain JavaScript
- Client side in JQuery
- Implementing a RESTful API.
Routing
- Setting up simple routes
- Routes with parameters
- Routes with wildcards
- Responding to GET request
- Responding to POST requests
- Request and Response objects
- Prefix and nested routes
Templating system
- Mobile friendly - Make the HTML mobile friendly.
- Template::Mojo, the Templating System of Bailador
- Passing data to the templates
Handling errors
Handling errors while serving pages
- Handling 404 errors
- Handling 500 errors
- Handling 30x redirects
- Setting the HTTP header manually
- Debugging
Serving static files
- Serving static files such as images, css, JavaScript files
- Generating RSS feed
- Generating robots.txt
- Generating sitemap.xml
NoSQL
- Using MongoDB
- Using Redis
Applications
The book will follow the development of 2 of the following web applications:
Exactly which 2 will be decided later. Either by myself or by the people who
contribute to the crowd-funding.
- Personal Bookmark manager
- URL shortener
- TODO list
- Blog engine
- A job board
- Real estate manager
- Flight ticket vendor for low-cost flights
- Banner ads rotator
- Conference organizer
The expected end results
I am writing the book in LeanPub and you can access it here. The book will be available in electronic format (pdf, epub, and mobi). I have a plan to provide a printed version of the book, but I don't know yet how and thus I don't want to make promises.
Prerequisites
The book assumes some some programming background and some web development background, but it won't require a knowledge of Perl 6. It will introduce enough knowledge of Perl 6 to understand the code in the book.
Risks & Challenges
This is an outline of the book. Some of the planned features might not be implemented for Perl 6 yet. Features missing from Bailador probably won't be an issue as I have commit rights to the main repository of Bailador, but I am not a web-framework developer.
Features outside of Bailador might not to be available yet.
With that said, the writing of the book and the sample applications will certainly impact the development of Bailador and the additional libraries needed to implement the applications and thus I am quite confident, this is doable
Other Ways You Can Help
- You can certainly help getting the word out and make some noise about this campaign.
- You can ask your employer to chip in, or to invite me for a training session.
- Twitter, Facebook, IRC channels, blog post, etc. Anything that might help reaching more people.
- You can also contribute sample project ideas for consideration.
What others say
"I think this is an excellent proposal. Now that Perl 6 is officially released, more than anything else we need books that show potential users how convenient, practical, and real-world useful the language is. This book would meet those criteria admirably, and Gabor certainly has the understanding, the experience, and the writing skills to complete it successfully. Take my money, dammit! :-)"
![]()
-- Damian Conway author of Perl Best Practices
"With Gabor's many years of experience teaching and writing about Perl, I'm confident that he'll be able to deliver on this proposal and provides us with a Perl6 book that will be a helpful resource for many future Perl6 programmers."
![]()
-- Olaf Alders creator of MetaCPAN.
"I've been largely ignoring Perl 6 development since the project
started in 2000. I figured that I would have plenty of chance to catch
up with it before clients started expecting me to know it. The
official release of Perl 6 eighteen months ago means that the time is
now right for me to start taking an interest. A lot of the code I
write drives web sites, so I want to get up to speed with web
development in Perl 6 quickly. That's why I supported this
crowdfunding campaign - I want to read this book and I think that
Gabor is the right person to write it."
![]()
-- Dave Cross author of Data Munging with Perl.
"It's been apparent for a few years now that Perl 6 is the single greatest computer language ever
invented, yet the world has not yet woken up to this. Gabor's persistent dedication to the Perl
community has been an example to all of us and his book will make an immense contribution towards getting Perl 6 the recognition it so richly deserves."
![]()
-- Peter Scott author of Perl Debugged, Perl Medic, and Human Cusp.