 So the room seems to settle down quite nicely, so we may as well start a Couple months ago. I think it was in October Louder louder whoa, I Already did all my shouting on Friday in the beer event. So But I will try okay a couple months ago. I guess it was in October. I Stumbled across a blog post about web development With pro 5 and it started like this Even though I'm in the thrills of pro 6 I still do all my web development in pro 5 Because the ecology of modules is so mature When I read this sentence it kind of rub me the wrong way Here's someone who clearly likes pro 6 yet cannot use it for what he needs to be doing and To me that's kind of unacceptable. I just refuse to believe that after so many people Port so much time into pro 6 It should still not be ready for something as mundane as web development So I set out on my quest to show that this site sentence is misguided or just plain obsolete So where do we begin how do we show that everything is not as bad as this blogger believes Well, I did a little survey of modules thought pro 6.org and Had a look at everything that at least sounded like a web framework to me These are the results as You can see here. It's a reasonably short list in itself. That's not that bad The list of actively developed web frameworks for pro 5 is probably not that much longer Of course, there are lots and lots and lots of failed attempts or abandoned frameworks on c-pen This raises the second question To which category do these belong to answer this question. I had a look at the date of the last commit to the repositories now keep in mind that the very first stable release of pro 6 as a language was in December 2015 and in the couple of months before this release We really rushed in a lot of semantic changes that we knew we had to get in before we were ready to commit to a stable version of the language so everything that has not seen any commits in these months or afterwards Is probably bit-wroted or really incredibly lucky For example, web app Bayer web app belay Claims that it's going to be merged with beta door in the near future now got curious and had a look about when the sentence was added to the documentation and he guesses It's not that bad, you know, it's March 2013 It hasn't happened yet. I'm not sure if it will ever happen, but with this filter applied. We are left with three contenders So no, no, no, no, let's not jump to conclusions here See three can still be a very decent pool to choose from We'll just have a look The first one is crust Crust is in short a PSGI implementation in pearl six It's a glue between the web server and the web framework itself It lets us centralize code for supporting different ways of connecting our application to a web server like fast CGI or being run behind the front-end proxy Though certainly very useful. It's probably not the very first thing that you'll be looking for But let's keep it in mind for now. We'll come back to it later Web can be considered one level above crust in the stack It gives you requests and response objects and the dispatcher Not luxurious, but sounds like at least a good start except for that it apparently does not even support fancy new fangled features like file uploads and And there's another thing missing that I'd consider somewhat essential part And I will come back to this later for now. Let's move on to the first thing that you should have considered Belador is pretty much a very straightforward port of Danza to pearl six It is lightweight. It is being actively developed Those somewhat slowly and it brings much of what you would expect from a web framework It's a little thin on the documentation and on examples, but since it's a very straightforward port of Danza. I could just implement Danza tutorial example application in Belador Just to see how how well it does The program I'm talking about is this kind of a minimalistic block you can lock in block something inside full And it's this gets then displayed on the front page Now Belador does not come with any kind of built-in configuration system So first off I wrote an extremely sophisticated one which you can see here Well, at least it lets me stick very closely to the original example Now here's a bit of database setup code. It's nothing special Do I have to mention that I very much like how DBI issues his name parameters instead of parsing some obscure connection string? Though it's kind of odd that the sq light driver doesn't cope too well with being Given a proper IO path object. So I have to stringify the path before giving it, but okay Now if you know a bit of Danza, you're gonna feel right at home here This is pretty much the same as you would write in crawl 5 we define a route for our get requests to the route and Give Belador a code block to execute when the route matches Again DBI ish interface looks quite a bit cleaner than good old DBI to me That's the the advantage of being able to start over with a fresh new code base The login handler Seems to be a good example for how to access parameters sessions and redirects very straightforward Easy to use very familiar from Danza So have I convinced you yet that crawl 6 is absolutely ready for web development Who have you noticed the little interesting bit in the last line here? Instead of just calling the template function as you would do in Danza. I Passed the result to a function called layout. Why is that? Well, Belador has simply hasn't seen as much development as Danza or more delicious. So again is had as No built-in support for layout templates or hooks. So I had to write a little helper nothing bad really There's also no facility to construct your eyes yet So for now a little example application cannot be run with the path prefix and This is also a part that I consider very much with missing from web Again, probably not a deal breaker. It just shows that Belador is not as mature a framework as Danza or much delicious No, wait a minute Do you remember crusts the PSGI framework for pulse 6? Well, the cool thing about PSGI is that it allows for sharing so-called middlewares Between applications and frameworks. There are tons of middlewares from support for running behind the front and proxy To awesome debug panels, and I don't know what else So in theory you could have the same with crust But middlewares have yet to appear Nevertheless crusts is certainly a good base. So we may as well give it a try the Documentation makes this look much more complicated than it actually is this tiny PSGI file is all that's needed to bring crusts and Belador together So we could give it a try As I have much extra time I can do a little live demo here Okay, it starts. That's a good sign and the application is running. Nice So Yeah, that's it. We can go forward be heroes right awesome middlewares, but first off I'm gonna show you the login thingy So, oh no it now you're seeing my super secret password. Oh Well, this is the error message and You know everyone has a point where she just gives up The question is only where exactly this point is and It will probably depend on if you're just playing around with this like I have or you need to earn some hard currency with this So is there no hope? Are we really stuck with the choice between a mature ecology of modules and the devotion to our new love? Well screw it. I want to have both if Dancer to is where the development is and the features are then dancer to I will use Now this is kind of like the canonical hello world example in dancer to taken straight out of its tutorial Okay, it's probably updated by now, but okay, it's probably not looking much that much different Um, okay, but if I were to try this it would explode again and why is that? Well the documentation doesn't tell you this but dancer to actually passes the application object to your handler routine Since Paul six does have proper sub routine signatures integrated in the language It expected it to declare those parameters that are passed to your code So it would rightfully complain that no parameters were declared But passed in anyway, so what could we do to make Paul six happy we could do it like this We declared the parameter, but this is undocumented and it would be tedious and look less pretty and we cannot have that can we Now luckily touchy who first tried this Found a really pretty way around that in Paul six code blocks are not just syntactic elements But first-class objects You can think of sub routines as code blocks with explicit signatures Naked code block blocks have a default signature That is used to create the topic variable dog dollar underscore And one argument is exactly what we need to get around this Now let's have a look at how well we do at the original doubt down say example I ported to baila though I'm not going to show you the full source code that would mostly just being boring code like this Interesting bits may be to point out That I do stick with the tutorial closely, so I use prol fives dbi and template toolkit Also one of the little improvements of prol six that matters so much at least to me in my daily life as a programmer Is that we have file specs functionality integrated into the language? So you can just use the temp dear variable and its convenient child method for platform independent generation of the path to a good temp directory as I mentioned I just use Dbi which all of you should know really so this will look very familiar to you, but also a little strange First of all, there's no undef anymore even undefined type undefined values are typed in prol six so The closest thing to a plain undef is an undefined any Which is what I passed to the connect method here Now what the hell is this dollar hash thingy any ideas? No, it's it's an itemist hash It's a hash that should be treated like a single item and that's the most important part not Interpolated into the argument list of the method call It's a bit like taking a reference in prol five except that we hope don't have references anymore or That everything is by reference depending on the way you look at it Now lastly this show code shows how to access global pro five variables In pro six, which is exactly like in pro five itself If you try this at home, and it doesn't work that way you have a version of inline pro five installed. That's Been written before this weekend Just a lot The old way was not as pretty and I Just hate showing things that are not pretty in my slides. So I had to fix it Onto a more mundane piece of codes the before template render hook as you Probably know better than me. This is just a sub that gets passed a hash into which it can set some values Now please a quick show of hands. How many of you people have forgotten this emiculon? After the closing curly in code like this It happens to me all their time in pro five, which is why I'm so glad that pro six has fixed this for us You don't need it anymore the compiler smart enough to guess what you actually meant, which is the statement ends there Now this is the heart of our program the code that actually delivers the page this The one specialty here is this map thingy Now what's that when we pass a hash from pro six to pro five? What the thing in the background does is it ties a pro five hash? So all the excess is redirected to the pro six hash now if this sounds slow your spot on It's so slow that it's very visible in benchmarks now a map is an immutable hash and Since it's immutable since we know it cannot ever be changed anymore We get by with just copying it to a plain pro five hash so this is much faster and Lancer accesses this hash a lot so This is a little way to really speed it up The final piece of dancer code. I'm going to show is this bit. There's nothing out of the ordinary here In fact, it's actually a little bit closer to what the dancer documentation suggests than the tutorial itself I'm talking about using the body parameters I think you call it key keywords Yeah Other than this being the recommended way anyway There's a reason for this deviation and this reason is the param keyword is context sensitive It behaves different in list context than in scalar context And this is a tricky bit of the language that pro six doesn't have anymore There's no distinction between call contexts anymore So there's also no way to communicate to the pro five function In which context it is called So what we do is we call every function in list context because it's the most general one in Almost every case it will just play in work Now, yeah, as I said in pro six the we don't have this distinction anymore Now all this switching between pro five and pro six must surely cost a lot of performance But how much? Well a benchmark the little block application and found that it's actually doing quite fine a 170 requests per second on my laptop is surely enough for many websites In fact, I think most websites out there see far less traffic than that For comparison, I tried the same with Baylador and was quite stunned And that didn't exactly expect stellar performance But 240 milliseconds for a simple websites like that for a single request. That's that's kind of embarrassing really I was sure that I have made some mistakes So I dug a little into it and I found out that template mojo which Baylador uses Uses a pro six grammar to parse the templates and pro six grammars are not fast. What is does then is it? Generates pro six code and then evils this code Now no one ever expected pro six to compile fast It's it's a humongously complex language and We are working hard on getting it fast at runtime, but compile time is is very much beyond that So doing this double parse for every single request is pretty much the slowest thing you could do The good news is that it's fixable and it's trivially fixable. I mean you just have to cash the generated sub routine and Template mojo actually has such a cash But Baylador uses it in a way that it cannot use it because it changed a new template object every request It's fixable. It's quite simple. It's it's just a symptom of of Baylador and pro six being relatively new Next I had a look at motorlicious As motorlicious is quite similar to dancer the results were quite similar as well So instead of a boring introduction, I will just focus on a couple of stumbling blocks I discovered when porting all the tutorial examples This hello world should be pretty much exactly what you expected as it happened to me just note this space before the After the sub and before the the opening parenthesis if you leave out the space in there And I should have used another font to make it more clear Pro six will think that you will want to call a sub called sub And give you a very confusing error message about dollar C not being declared But other than that if you do it correctly, it's it's just works like this Now it would be really cool if this example worked as shown Because motorlicious supports storing templates and static files in the data section of your program But pro six doesn't have this data File handle instead this is integrated into part so we have the finish part command Which just tells it you're all pro six stopped here the rest is yeah data Now as I have a little extra time I can Do a little side story this does not work yet but Just a question to the audience. How would you implement this in pro five? You have this magic data file handle and in pro six we have Well a port command Any ideas? Well my first thought would be yes, okay. We we probably have to Create this file handle probably give it a memory buffer Now the night and one of the nice things about pro six is that? We have lots and lots of introspection features so you can also actually very simply Access all the pot in your program from within the program. There are magic variables like dollar equals finish Contains all this data We have to create a file handle backed by a string and we have a string So why have I not yet implemented this? I hate showing things that don't work Now turns out the really tricky part is the timing because You have this usual use motorlicious light from pull five up there. This is where Motorlicious is loaded from pull five. This is where all the the initialization code runs It's a begin time because use is a begin time construct the finish Part command has not even been parsed yet so I'm not sure where exactly to put it in the program flow If you have any of you have any idea about this I'd be glad so What you do to get around this is you put this in a proper template file Which is what you should do anyway at least to get the proper syntax highlighting for this code When I prepared the example to show how to give a route a name I stumbled over another subtle difference between pull five and pull six in Pull six the fat comma operator. I use up there is It's not long is no longer just a fancy way to spell comma It's an operator that creates a pair object a pair is just a key in the value Now if you chain those fat commas you create a nested pair structure with a pair that has a another pair is a value and Motorlicious gets quite confused if it sees that So instead of having a another fat comma there just because it looks pretty just use the comma Now this is the very first example that really really doesn't work because right now. It's unfortunately impossible to pass a regular expression from pull six to pull five I Actually have a patch That implements the support Just need to clean it up and finish it Unfortunately, it would still not be enough because what motorlicious does is it takes this regular expression it stringifies it and Then includes this string inside another regular expression for a dispatch and the way I implemented the support is To create a pearl five regex that really just has a code block inside Which can then delegate to the pull six regex which tells it should you match or not and This code block of course does not stringify to anything sensible So I think there's a way around it. I have found ways around any of the problems I had so far, but It's gonna take some time What does work on the other hand is web sockets and I just can't help but find this incredibly cool And if you look at this, there's really nothing special you have to do It just works like this like documented Now for something that looks a bit different than the last three frameworks Catalyst is an interesting candidate Catalyst puts a bit more pressure on you to stick to an MVC architecture. It automatically loads your module view and controller modules and of course it expects us to be written in pull five It even gives a step further and generates the boilerplate code for you And this is code that we probably better leave just as it is So I won't miss waste much time on it. The far more interesting question is how do we get our pulse six code into there? The answer is by declaring that the rest of the file is written in pull six Everything from the use v6 in line line up there is just plain old Perl six code. We have an index method with appropriate catalyst attributes Making the method a catalyst action Of course, we get past the context object and we can call methods on it and We can use the usual methods to get our job done This pretty much works out of the box Except for the catalyst attributes and it was quite surprised surprised that Steven little Did not come up with this example for attributes because it's it's the place. We have seen it. I'm used most, but okay Like I said in crawl the six we don't have subroutine attributes. We have traits instead not traits can for example be a Convenient way to add a role to a method object Because even methods like code blocks and everything else are really proper objects in pull six for catalyst action, we want to Mix in the pearl the inland pearl five pearl five attributes role because I suck at naming And because I suck at naming this role provides an attributes attributes Which is just a list of attributes to apply to the pearl five wrapper That gets generated for inland pro six methods now this little helper method the catalyst x pro six component profile five attributes contains Two more trade mode functions for Supporting the arcs and action class attributes, but they look pretty much exactly like this code. So That's it and this is really all you should have to know and use to be able to use catalyst in a pro six project Which is quite cool and Now I know what's been bothering me about the sentence that haunted us so far It just takes two really tiny changes For me to be able to make peace with it Because Even though it's certainly fun building a new web framework. I sometimes just need the reliable tools I know and I'm so familiar with and luckily they're still there for me Now the question with which I haven't touched yet is Why would I want to? Why would I want to leave the familiar territory and venture forth into the unknown? Well for some the answer would be exactly because that's what I want to do. I want to explore Well, some will be attracted by the opportunity to carve out a name for yourself to become the Sebastian reedal for the pro six world Others will simply feel that pro six as a language is incredibly well suited for web tasks For example, thanks to emoticons Unicode is huge right now and pro six is at the forefront of Unicode and of course having Having the gradual type support pro six covers a sweet spot between Type support that catches so many stupid errors we all make But not too much type support so it would get in a way like I experienced with Java and rep development which sucks And of course having good parallelism and concurrency support in the language Let's just finally move into this day and age regarding the use of our computing power So while the solutions I've shown you today will not get you there immediately They will be a good first step into that direction Thank you any questions, please There's at least one question that I'm extremely surprised that does not come Prancer ah the name rings a bell, but it must be so old Yeah, I haven't I haven't seen him talk about it for quite a while, so probably somewhere out there This one Yeah, I can show certainly to you The question I'm surprised that I've not heard is I've shown some performance statistics somewhere Yeah, we have a dancer to wire Pearl six and baila though, but how does it compare to the original dancer in pearl five? The reason why I haven't put it up in the slide is that I don't have the exact numbers anymore I somehow forgot to write them down, but I seem to remember that The pearl six is version is about four point seven times slower than the original profile version Which sounds like a lot, but on the other hand one or two milliseconds per page render is not that bad and The example is is very small and We're measuring probably Almost only the overheads and in a normal web application you would do much more than just do a single database query with two results and Render them in a trivial way So I guess four point seven times slowdown is is the upper boundary of what you would see But someone will have to write the large application so we know it Yes, that is a good question. Any other questions then we may have a short break. Thank you