Become a fan of Slashdot on Facebook

 



Forgot your password?
typodupeerror
×
Perl Programming

Mojolicious 2.0: Modern Perl For the Web 132

Kvorg writes "After a year of rapid development, newly released version 2.0 of Mojolicious, the new generation real-time Perl web framework written by Sebastian Riedel and many others, offers a versatile and elegant web framework that is as good at web scraping and simple scripts as it is at building complex, interactive real-time applications with HTML5 and websockets. It supports easy 0-dependency installs, excellent developer mode, multiple deployment scenarios, many CPAN modules and plugins."
This discussion has been archived. No new comments can be posted.

Mojolicious 2.0: Modern Perl For the Web

Comments Filter:
  • by arth1 ( 260657 ) on Tuesday October 18, 2011 @01:04AM (#37747080) Homepage Journal

    Don't avoid $_ and @_; use them when they are useful, even in implicit form. Perhaps especially in explicit form.

    What's more elegant?

    # Declare variable $mystring
    my($mystring);
    # Get rid of $_
    $mystring = $_;
    # Strip line endings from string
    # We use chomp because it will only delete CR and LF,
    # unlike chop which will delete any character.
    $mystring =~ chomp($mystring);
    # We do it twice in case the string ended in CR+LF
    # which is common in MSDOS
    $mystring =~ chomp($mystring);

    or

    require 5.9.0; # avoid ugly $foo =~ chop $foo
    my $mystring = $_;
    # Strip newlines
    while ($mystring =~ m/[\r\n]$/) {
      # String has CR or LF at end, strip it
      chop $mystring;
    }

    or

    # chop any number of CR and LF from end of string:
    chomp while chomp;

    I have seen far too much misguided code of the first and second type.

    Have the comments explain what the purpose of the code is, not how it does it. The way to fix perl code isn't to read and understand the actual code, but replace the part that doesn't work as expected with code that does. If you understand your comment and know how to write perl, you don't really need to understand how a cryptic line does something - it's faster to rewrite it from scratch to do what you want.

  • by Anonymous Coward on Tuesday October 18, 2011 @01:05AM (#37747088)

    I don't really get the desire to use Perl. I haven't touched Perl for a long time and can't think of any jobs where it would be the best tool. It's ugly.

    It's still _the_ tool for quick one-off type stuff. I know of no other tool that lets you just mash data together and produce something useful as easily and quickly as perl. That said, I'd never use it for a serious application or anything that had to be maintained for more than a few weeks. Those days are gone.. maintainability and reliability are king.

    Well the really smart guys that figure out DNA started using it. Many startups use it. I've used it pretty much everywhere I've gone and it's leaps and bounds above what I find in use in most places. It's huge in Japan. It was the favorite language of the guy who created Ruby, he just wanted more.

    So yeah no serious application or anything that had to be maintained, no never that, because how could anyone possibly write maintainable Perl. Instead you should use a programming language where maintainability and reliability are king, that language of course is ...???

    By the way Slashdot the not so serious site you are on is written in Perl.

  • Re:Yet Another (Score:5, Informative)

    by MadMartigan2001 ( 766552 ) on Tuesday October 18, 2011 @08:25AM (#37748602)
    Mojolicious is a complete HTTP 1.1 stack. No mod_perl required. It has its own built in webserver, hypnotoad which can be used in production. You can install Mojolicous with a single curl command

    sudo sh -c "curl -L cpanmin.us | perl - Mojolicious"

    And three lines can make a complete "hello world" application....

    use Mojolicious::Lite;
    get '/' => {text => 'Hello World!'};
    app->start;

    Part of what make Mojolicous so powerful is Perl's syntax and expressiveness. I know it's hip to beat up on Perl these days, but perl is still way ahead of most languages in its ability to be expressive. The author of Mojolicous is a really good programmer and insanely picky about well structured code, consistency and test driven development. Hence, the framework is very easy to use and understand. This framework is definitely worth a look.

There are two ways to write error-free programs; only the third one works.

Working...