 Okay, so thank you everybody for coming along. This is the first session of the Open Programming MiniConf at Linux.conf.au 2011. This is the second time we've run this particular MiniConf. We ran it in Wellington last year as a way of encouraging more developers to attend and present their code at LCA. One order of business that I want to draw to your attention is that we'll be running Lightning Talks in the last hour of today's MiniConf. MiniConf Lightning Talks will be done via the wiki, so if you go to the Monday schedule on the LCA website and follow the link through to the Open Programming MiniConf Lightning Talks, you can just put your name and your topic there. We'd love to get as many of you talking as possible. So let's get to our first presentation. I'm reliably informed that our first presenter is a pearl hacker. He also provided me with an extensive biography, which assures me is entirely true. Please welcome Michael Schwern, who is presenting on Pearl Five Eye. Hello. So, yeah, thanks for starting this off. And I guess I'll start the language MiniConf with a kind of mini-language. Now first, a poll. How many people will raise their hand? Not bad. All right, two. Making up, excellent. Going the extra mile. How many people here are or were pro-programmers? All right, a good amount, I guess. Got the fan club. I was a little unexpected because I wrote this talk for pro-programmers. As I was rewriting the slides, I was like, oh yeah, I don't have to explain exceptions to the audience. So, Pearl Five Eye. So, Pearl Five is perpetually stuck in 1998 and 95, and it has to be because it's backwards compatible, and everything new has to be supported forever, and they're very, very conservative, and they cannot experiment. And one of the grand things is that Pearl Five has no way to trim the white space off the front and back of the string. Everybody does it. It gets proposed every year. It's the simplest thing in the universe, and it never gets in, because they can never agree on the exact details, and they have to agree on the exact details. Now, but Larry gave pro-programmers a lot of power, and this power is expressed and the language is advanced through CPAN modules. The problem is which ones do you use, and what we're just supposed to use and what you're not supposed to use is changes over time, and this becomes tribal knowledge that is not known to a new programmer. Out of the box, it's still 1995. On CPAN, it may be the 21st century. The docs don't keep up. The books don't keep up. So, I wrote this thing called Pearl Five Eye, starting with the idea that I wanted to encode this tribal knowledge. I wanted to have this standard practice all in one line. It's the best of CPAN. It shares a good quality, and they play nice together. It also takes advantage of synergies that they can't take advantage alone. Now, like every project of mine, it's a pun, not a particularly good one. I think Damien Conway came up with it. This is the imaginary version of Pearl. The retro name is now improved, or as somebody said, oh, God, you made it more complex. The way you think about it is that Pearl is heading this way up towards Pearl Six, and we're kind of going in our own direction, taking ideas from Pearl Six and using new Pearl Five features as they come in and enabling them, because a lot of times they're turned off by default. So, we're taking the onion, and we're improving it. Pearl Five is a bit embarrassing. For example, here is how you write a timestamp to a file in Pearl Five. You have to open the file, and then check to make sure it opened, and then you print to the file, but oh wait, there's no ISO 8601 date function built into Pearl, so you've got a right one. Our date processing is horrifying. It's just embarrassing, and so you have to write all this stuff just to write an ISO timestamp to a file with Pearl out of the box. Or you can write this. So, it's really small, and it's supposed to be small, because it's... So what is that? What's going on here? There's a lot going on here. The first thing is it's loading Pearl Five I, and I'll talk about why it's two in a little bit. We've got function signatures. So, okay, what don't you see? You don't see use strict and use warnings. Those are now on by default, like every sensible programmer should. We've got lexical file handles. We've got no error message there, because that's done for you, like every sensible programmer should. We've got function signatures. Hey, welcome to 1982. We've got say, which is the print that puts the new line on the end, and we've got an actual date object coming in here. That's kind of like the synergy that I was talking about, what's going on, makes things so much more easier to write. So, I want to go through the major concepts as quickly as possible, because this is really an hour talk. So, let's start with exceptions. So as I said, in Pearl Five, makes you write out your own error handling, even with those mundane things like writing a program, opening a file. Now, as every Klingon programmer knows, I can't pronounce that. Anybody? And Paul is not here. Damn. The rough translation is, it is better to die than to return in failure. I don't have to explain why that's a good idea to this audience, I hope. So, Pearl Five I turns all of these things, well, and I actually have more to explain, it makes that all implicit. It makes all the file functions just throw an error when they fail. An error message is probably better than what you would write in the first place. It actually tells you all the information you want to know, what the file was, what you were doing with it, and so on and so forth. All just by default. That's the right thing, by default, and it's more convenient. Doing the right thing does not have to be hard. It doesn't just work on open. It works on all of the file stuff, which is very important sometimes. That's all based on a module called Autodive, which is Paul Fenwick's thing, and Pearl Five I just sort of brings in these pre-existing modules. So we don't just use exceptions, we kind of embrace them. Pearl Five I tries to make as many of its functions, as many of Pearl functions as possible, throw exceptions when that is the right thing to do, as opposed to returning a false value and having you check it. Which, as I said, pro programmers don't really understand this still. And we add an exception handler, a real exception handler. Normally, eval is used, but eval has all sorts of issues, and if you don't know them, I won't bore you with them. Let's just say that that fixes them. It gives you try, catch, and finally. And then the other cool thing that's up here is that it's using the new Pearl Five switch statement, the given when stuff, which you get for free, because we actually turn it on. It's all available in Pearl Five Ten, but nobody thinks it turned it on. So it's both convenient and correct. So there's no reason to do it the sloppy way, because the sloppy way is actually now harder. It's fixing the defaults. Questions before I move on to the next section? On the switch statement? Can I elaborate on it? No. But it was quite a hack. Yeah, now it's built in. As a Five Ten, it's built in. You turn it on with use feature, and there you go. Sorry, I said no, because it's just tangent. Not much time. Right, so objects. Pearl is technically speaking an object-oriented language, but it's still a procedural language, really. So Pearl Five I embraces objects. Again, finally. Welcome to, I'm a small talk invented, 1960 something. Yeah. So here is how you get the year in Pearl Five, right? It's, yeah, embarrassing. This is a legacy. This is a legacy of how C does it. And it's actually worse than how C does it, because C actually has a structure for this. Instead of just returning it to you, it's this big blot of nine arguments. C was designed in 1970. We can do this better. And so now the built-in just return a date object. You ask it, what's the year? And then print yourself. The time function returns the same thing. And they're all overloaded to maintain compatibility. So they still do what they used to do. Stating a file, same thing. Just return a blot of a dozen things. Who knows which one of them is a modified time. Caller, same thing. Here is how, in Pearl Five, you, is there a question? Okay. In Pearl Five, you make a file handle flush itself on every right. Yeah. Here's how you do it in Pearl Five I. File handles an object. You call them that then on it. It's called Auto Flush. Last night, I realized that this functionality has been in Pearl Five for 13 years. And nobody uses it because it's not turned on. You do? Hey, Sam. Yeah. Right. You just turn out, you load one module and it's done in the language. It even automatically uses it for you. But now that it's there by default, you can actually start using it. Right. Objects. Great. Any questions? On that? Not really revolutionary. We've known about them for a while. So every Pearl programmer for a while was drilling over Ruby. And one of the things Ruby does is help it everywhere. And now Pearl does too. And actually, Pearl has had this again for years. Nobody was using it. In Pearl Five I, everything is an object. Strings are objects. Arrays are objects. Hashes are objects. And as any Ruby or, I guess, Python programmer knows and as Java programmers don't, this is a huge thing to have everything be an object. Everything in the language. Be able to call methods on it. And so on and so forth. Because from a language design perspective, methods are really cheap to add. Keywords are not. So as a procedural language, whenever Pearl Five decides, I'm gonna add a new keyword to the language. I'm gonna add a thing called trim. This suddenly means that Pearl Five gets a pony called trim, but you don't. You can no longer use the trim keyword as a function name or a method name or anything else in the language. Pearl Five takes that away from you. So if Pearl Five wants to have, say, a universal object identifier and call it ID, all of a sudden you can't have a function called ID. Name-space pollution is a big problem in Pearl Five, not in Pearl Five I. Because if I wanna add a trim method, I add it to the scalar class. And then it just affects scalars, which nobody else is using anyway. There, what's that? Say again. If you have a keyword called trim, sorry, then you give it a number. You have to do something sensible with that number. Oh yeah, Pearl already does that. Pearl already has the number string thing. My point was more along the lines of if you add a keyword called trim, suddenly you have to have it do something sensible with arrays. Oh, the keyword, the keyword, yeah, yeah, yeah. Oh, or you just make it puke. But yeah, yeah, you have to think about that. No, no, they would argue about things like, well, what about unicode white space? Well, what if I wanna change the trim character? What if I wanna trim for the left or from the right? What if I want to, it's like, oh, God, guys, just pick something and do it. Yeah, huge debate. So, right, so trim. We also have L trim and R trim, if you wanna go from the left to the right. And it does take options to say what characters I do wanna trim because, again, it's cheap, it's a method. We have all of these, the arguments to the method are all available, so we can throw options on the end. Alliasing in Perl is extremely scary. It's extremely, you have to know, turning off strict and civil table hacking and all this kind of stuff. And even the concept is a little scary. But the idea that I wanna make, I wanna generate a code reference and I don't wanna name it this is actually very, very powerful. It's very, very powerful if you want to generate classes and everything else. And traditionally, it's extremely scary. Well, now it's not. You can alias pretty much anything in Perl5i. So you take a, you make a code ref, you call alias on it, you give it a class and a name and there you go, boop, it exists. And this was like hidden power that only the masters could know how to use and it was kind of passed down from person to person. It's never really documented how to do it in the Perl documentation. So now let's just take it and encapsulate it and now everybody can use it. This, and this leads into the fact, the Perl5i fact. So having objects everywhere and having these cheap utility methods finally allows us to write better fact answers. So because Perl is so stingy with its key words it doesn't write things unless things are really important. So for an innocent question like, how do I determine if a scalar is a number and what type of number is it, right? Is it an integer, is it a float, is it a decimal, is it not a number at all? Well, here's what the Perl fact will tell you to do. First it starts out with a caveat. Like let's assume that you don't care about these special things over here and then cut and paste these regular expressions into your code. And yeah, it's a problem. And into categories that really only sum them with a double major in CS and math would care about. How many of you have a double major in CS and math? All right, yeah. You care? No. No. Perl5i is just gives you methods for it. What else do we have? Everybody hates references in Perl because the dereferencing syntax sucks. But now they're all objects you can call, just call the methods right on them. All the built-ins are available. We even have a meta object so that you can do introspection and things on any object. Instead of, these are the things that I want to be available to any object at all whatsoever, rather than polluting the top level of namespace with these things. I kind of created a side namespace by having everything return a meta object. And it's a little hack for Perl. It also means that we don't pollute the top. We have our own little universal thing on the side. This allows you to take any object and dump it out as Perl or as JSON, if you really want to. Or take a checksum of it. In MB5, the basics were formatted. It's all very handy stuff. Everything now is in the universal object identifier. You can check to see if two complicated data structures are equal. And it'll even work on overloaded objects in a sensible fashion. This was hard, but now it's done. That's all located in the meta documentation, the stuff that works in every single object. Questions? We're moving on? Wow, five minutes. OK, introspection. Always been possible in Perl. The other languages are Java would always bag on us, because we can introspect. Well, we can, too. But it's really scary. This is how you find what the parents of a method is in Perl. And here is in Perl 5i. Just what are your parents? What's your iso right? Here is a linear walk of the complete tree. Here is asking what methods you have available. And then we jump into function signatures. Hello? Minicom. You don't want the Perl talk? OK, bye. So functions, this actually compiles down. It's not a source filter into something like this. You can do it for methods as well. You can do it for anonymous. Joe's pizza. I have no idea. In the middle of a talk, so I'll have to go. Bye. It works with anonymous functions. It means you don't have to use dollar underscore anymore if you don't want to. Really cool thing is you can introspect on these and ask how many parameters you have. So this works, and this works, and this works. I'll iterate. This iterates through the array three at a time. And it just knows it because the function wants three parameters. We fix Perl. 2038 bug is fixed. That Blutcher's error message that you get when you can't find a file is now something nicer. Unicode is turned on, which means you can have Unicode function names and Unicode regular expressions. And you can put smart quotes in your regular expression if you want to. Let's see. So it has a backwards and compatibility plan. I guarantee you every major release of Pro5i will be incompatible with the previous one. Absolutely guaranteed or triple your free software back. And this is because they actually work together. The major versions work together in the same process. So if you write code a library that uses version one, it can work together with one that uses version two without clashing. So this allows us to upgrade and change our minds, basically, without breaking old code. So we're backwards compatible because the old version will still be there. And we're future compatible. We don't have to maintain our mistakes forever and ever. And this allows us to basically be really agile because we can throw out features there that are 90% done and then see how they're used and then make small tweaks to it later when we do a major rev. It's fairly efficient. It's a little bit slow loading right now. We try to only make you pay for what you use. But it's no worse than moose. It's a little slow. Like this is when it has to load in date time, which is a big, fat pig. We're working on that. It's no slower than using any of those modules like you would normally. Is it stable? Yes, it actually is stable. Because the incompatibility plan, the API is safe. I have a lot of experience doing really stable software. The dependency tree is enormous. But as you can see, this is the test results for it. It's very, very, very green all the way down. We watch that. If any of those starts to go red, we're right on the author. There are docs and facts. There's discussions. We kind of live in the issue tracker. Working on it is not scary, despite the idea, especially adding new methods and things. It's just like any other method, writing any other function. That's if you were to write something to turn a string on a title case. It's normal Perl. I take care of all the scary stuff, or the people take care of all the scary stuff. So some things to see also. There's now finally a book that's about how Perl programmers actually write Perl in the 21st century called Modern Perl. It's free. Or you can buy it in Dead Tree by Chromatic. There's a module called Task Encho that kind of has this huge list of good Perl modules to have. And they're kind of a parallel thing. I haven't talked about Moose. Moose is the new object system derived from Perl 6. And it does everything and more than you ever thought you wanted to know. It's a post-modern object system. It's fantastic. And then Jacinta is talking later today, or later on Tuesday? Thursday about Modern Perl best practice techniques. Oh, my god, I got through it. These are the contributors. And are there any questions in that one minute that I have left? We've actually got plenty of time for questions. Oh, you did? Do you want to change over? So does anybody have any questions for Schwern? Yeah. Mr. Moment. The test suite that you showed us earlier on our Perl 5i, who wrote that? The test suite. Oh, all the dependency stuff? That's a project of the CPAN testers. This has been around for a long time, years and years, or even a decade. And they've been tracking. They've been doing automated testing for a long time. And that dependency tree was written by Dave Cross or Dave Cantrell, one of the London Dave's. And it's just you go to search.cpan.org. You look at a module. There's a link called Dependencies. You click on that, and it'll show you all that. And there, yeah, modules are just constantly. There's just volunteer smoke testers. They see something go to CPAN. They hit it with half a dozen different machines and different versions of Perl. And they send you the report right back. And you don't even have to lift a finger. You just upload to CPAN. It's fantastic. Any other questions? No? There's one down here. Michael, would you like to tell us about your shoes? Oh, Jesus. No, because there is somebody else at the conference that has the issues. There are two people at these conferences. I know, at least, that there are three of us. Amongst people at the conference, yeah, so normally, sometimes, when I give this talk, somebody winds up asking about my shoes. I put a slide in the front because it happens. These are called the Vibram Five Fingers. I do not work for Vibram, but goddamn, I wish I did, because I could make them give me a sales commission. It's like being barefoot. There's no sole to it whatsoever. And they take a really long time to dry. And yes, they are comfortable. And they cost about $80 an American. How do you do the function signatures? Devel Declare. OK. So the function signatures are done. Use the thing called Devel Declare, which coerces the pro parser into doing what you want. Essentially, you say, I want to take a, when you see this thing, this keyword, a keyword called funk, it tells the parser, just hold on a moment. Just stop. Let me take over. Let me take that string you were about to parse. Rearrange it. So in this case, it takes funk name signature and turns it into sub name, brace, and then the pro code. And then goes, all right, look at it again. Yeah, yeah, but as the part of the parser is doing it. So I'm not writing my own parser. The parser actually gets the point. It says, hey, there's a keyword here called funk. And what do I do with it? And Devel Declare goes, stop. Let me rewrite that line. OK, go again. So it's OK as long as you're doing very, very small things like that. It's very different, much more safe than the old source filters that actually had to scan the entire code. So you can wind it back to going into a string or regular expression or something. They're very safe. And they happen to compile time. No further questions? Excellent. Everybody please thank Schwerin. Thank you. We'll just wait a minute or two for our next presenter to get his slides up.