New cross-language web development framework called Jasper

Discussion in 'Perl Misc' started by biggus, Apr 20, 2006.

  1. biggus

    biggus Guest

    Hi,

    I've just finished a new cross-language web developement framework
    called Jasper. It supports several (four, in fact) platforms and
    languages, Perl amongst them.

    I am posting this new thread since I want others to have a go with
    Jasper, and hopefully provide some helpful comments.

    It is a while since I've developed a purely Perl driven website
    commercially but I felt a Perl implementation was essential. For this
    reason, I'm particularly interested in feedback from active Perl web
    programmers.

    http://jasper.sourceforge.net/

    Kind regards,

    Jim
    biggus, Apr 20, 2006
    #1
    1. Advertising

  2. "biggus" <> wrote in
    news::

    > I've just finished a new cross-language web developement framework
    > called Jasper. It supports several (four, in fact) platforms and
    > languages, Perl amongst them.
    >
    > I am posting this new thread since I want others to have a go with
    > Jasper, and hopefully provide some helpful comments.


    Based on a cursory look, I would stay away from this module.

    You have re-written a lot of fundamental Perl functionality, which
    results in obscurity and (completely unnecessary) performance penalties.

    For example,

    package ArrayUtils;

    sub size
    {
    my $arr = shift;

    return ( scalar @$arr );
    }

    or

    sub keyExistsAndNonEmpty
    {
    my $arr = shift;
    my $key = shift;

    return ( exists($arr->{$key}) && !StringUtils::equals( $arr->
    {$key}, "" ) );
    }

    The naming of this method is completely misleading. And, a simple

    length $str

    is enough to check if $str is empty or not.

    You have basically written Java in Perl. There is a reason we program in
    Perl. If I wanted to program in Java, which I still occasionally do, I
    would just go ahead and program in Java.

    package RegEx;

    sub new
    {
    my $class = shift;
    my $this = {};

    bless ($this, $class);

    my $re = shift;
    my $ignore = shift;

    if ( !$ignore )
    {
    $this->{re} = qr/$re/;
    }
    else
    {
    $this->{re} = qr/$re/i;
    }

    return $this;
    }

    sub find
    {
    my $this = shift;

    my $line = shift;

    if ( $line =~ $this->{re} )
    {
    my $left = $`;
    my $right = $';
    my $middle = $&;
    my $match = $1;

    my @matches = ( $middle );

    for ( my $i = 1; $i <= 9; $i++ )
    {
    if ( my $mi = eval("\$$i") )
    {
    $matches[ $i ] = $mi;
    };
    }

    return ( RegExResult->new( $left, $right, $middle, $match,
    \@matches ) );
    }

    return ( undef );
    }


    Once again, you have obscured a whole bunch of crucial things going on,
    introduced a completely unnecessary string eval, incurred unnecessary
    performance penalties etc.

    In other notes, you trample all over the namespace. For example, you put
    stuff in package Config. You should read

    perldoc perlmod

    to learn how to partition the name space, and write proper modules.

    There are too many hidden bugs, bad programming practices, and plain old
    crap in your code to even begin to think about making it better. You are
    better off deleting all existing copies, and going over to CPAN.

    There are a whole bunch of great frameworks, such as Catalyst and
    Maypole, or a bunch of modules such as CGI::Application, CGI::prototype,
    HTML::Template, Template.pm, Class::DBI so on and so forth for writing
    web applications.

    Sinan



    --
    A. Sinan Unur <>
    (remove .invalid and reverse each component for email address)

    comp.lang.perl.misc guidelines on the WWW:
    http://augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
    A. Sinan Unur, Apr 20, 2006
    #2
    1. Advertising

  3. "A. Sinan Unur" <> wrote in
    news:Xns97AB6D0551C4Dasu1cornelledu@127.0.0.1:

    > package ArrayUtils;


    ....

    > sub keyExistsAndNonEmpty


    ....

    > The naming of this method is completely misleading.


    s/method/package/;

    Sinan

    --
    A. Sinan Unur <>
    (remove .invalid and reverse each component for email address)

    comp.lang.perl.misc guidelines on the WWW:
    http://augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
    A. Sinan Unur, Apr 20, 2006
    #3
  4. "biggus" <> wrote in
    news::

    > I've just finished a new cross-language web developement framework
    > called Jasper. It supports several (four, in fact) platforms and
    > languages, Perl amongst them.
    >
    > I am posting this new thread since I want others to have a go with
    > Jasper, and hopefully provide some helpful comments.


    It is like an accident, I can't stop looking.

    package Log;

    sub getTimeStamp
    {
    my ( $second, $minute, $hour, $tmp, $tmp, $tmp, $tmp, $tmp, $tmp
    ) = localtime time;

    return ( sprintf( "%02d:%02d:%02d", $hour, $minute, $second ) );
    }

    Hmmm ...

    D:\Dload> cat t.pl
    #!/usr/bin/perl

    use strict;
    use warnings;

    sub getTimeStamp
    {
    my ( $second, $minute, $hour, $tmp, $tmp, $tmp, $tmp, $tmp, $tmp
    ) = loc
    altime time;

    return ( sprintf( "%02d:%02d:%02d", $hour, $minute, $second ) );
    }

    print getTimeStamp(), "\n";


    D:\Dload> t
    "my" variable $tmp masks earlier declaration in same statement at D:
    \Dload\t.pl line 8.
    "my" variable $tmp masks earlier declaration in same statement at D:
    \Dload\t.pl line 8.
    "my" variable $tmp masks earlier declaration in same statement at D:
    \Dload\t.pl line 8.
    "my" variable $tmp masks earlier declaration in same statement at D:
    \Dload\t.pl line 8.
    "my" variable $tmp masks earlier declaration in same statement at D:
    \Dload\t.pl line 8.
    10:50:09

    sub timestamp {
    sprintf q{%2.2d:%2.2d:%2.2d}, reverse( (localtime) [0 .. 2] );
    }

    Also:

    sub getDateStamp
    {
    my ( $tmp, $tmp, $tmp, $day, $month, $year, $tmp, $tmp, $tmp ) =
    localtime time;

    return ( sprintf( "%02d,%02d,%d", $day, $month + 1, $year + 1900
    ) );
    }

    You should use an unambiguous date string.

    sub datestamp {
    my ($d, $m, $y) = (localtime)[3 .. 5];
    sprintf q{%4.4d%2.2d%2.2d}, $y + 1900, $m + 1, $d;
    }

    *SIGH*

    --
    A. Sinan Unur <>
    (remove .invalid and reverse each component for email address)

    comp.lang.perl.misc guidelines on the WWW:
    http://augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
    A. Sinan Unur, Apr 20, 2006
    #4
  5. "biggus" <> wrote in
    news::

    > I've just finished a new cross-language web developement framework
    > called Jasper. It supports several (four, in fact) platforms and
    > languages, Perl amongst them.
    >
    > I am posting this new thread since I want others to have a go with
    > Jasper, and hopefully provide some helpful comments.


    package StringUtils;

    sub chomp {
    my $str = shift;
    $str =~ s/[\n\r]+$//;
    return ( $str );
    }

    Read perldoc -f chomp to see what chomp actually does.

    sub toLower {
    my $str = shift;
    $str =~ tr /A-Z/a-z/;
    return ( $str );
    }

    sub toUpper {
    my $str = shift;
    $str =~ tr /a-z/A-Z/;
    return ( $str );
    }

    Perl builtins lc and uc should be used in preference.

    sub equals {
    my $first = shift;
    my $second = shift;

    return ( $first eq $second );
    }

    You should directly use the eq operator in your code as opposed to
    relagating the comparison to a silly subroutine.

    sub len {
    my $str = shift;
    return ( length( $str ) );
    }

    Again, directly call the Perl builtin.

    sub split {
    my $str = shift;
    my $divider = shift;
    return split( /$divider/, $str );
    }

    Ditto.

    In summary, most of the code you have written is completely unnecessary.
    Most of the code which is not necessary is either wrong, or bug-prone.

    I use frameworks and modules written by others to make it easier to
    solve *new* problems, not to experience the same problems over and over
    again.

    Sinan


    --
    A. Sinan Unur <>
    (remove .invalid and reverse each component for email address)

    comp.lang.perl.misc guidelines on the WWW:
    http://augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
    A. Sinan Unur, Apr 20, 2006
    #5
  6. biggus

    biggus Guest

    Sinan, hi,

    thanks for the feedback.

    I accept many of your comments, of all the languages that Jasper is
    written in, I confess Perl is my weakest. I was determined to write a
    Perl implementation however, not just because Perl provides the 'er' in
    Jasper but out of my own fondness for the language. I wish I had more
    time to spend on Perl, really.

    The main point you make I think in all of this is that Jasper hides
    many native Perl functions in what appears to be pointless
    functionality of its own.

    I agree, but it was unavoidable. I wanted to force web developers to
    think about web programming in a way that went beyond language
    specifics, to encourage debate, mainly. I also have to write code
    snippets to express my ideas so that everyone can read them, hence some
    of Jasper's API seems pointless. Developers in any language can level
    the same critism at me and all I can do really is to hold my hands up
    and point to the fact that when trying to reason across languages, such
    generalisations are just unavoidable.

    I have taken your specific language points on board, you're right about
    the ArrayUtils class, I missed the internals of these methods and if I
    drone on about the need to abstract from language specifics for the
    sake of demonstration, I should at least take this no further than
    absolutely necessary. The two offending methods now look as they
    should:

    sub keyExistsAndNonEmpty
    {
    ...

    return ( exists($arr->{$key}) && (length($arr->{$key})>0) );
    }

    sub keyExistsAndEquals
    {
    ...
    return ( exists($arr->{$key}) && ($arr->{$key}eq$val) );
    }

    Also the two date related functions of the Log class:

    sub getTimeStamp
    {
    my ($second,$minute,$hour) = (localtime)[0..2];

    return ( sprintf( "%02d:%02d:%02d", $hour, $minute, $second ) );
    }

    sub getDateStamp
    {
    my ($day,$month,$year) = (localtime)[3..5];

    return ( sprintf( "%02d,%02d,%d", $day, $month + 1, $year + 1900 ) );
    }

    And the case functions of the StringUtils class, I've really shown my
    relative ignorance here, I had no idea 'lc' and'uc' existed, so, of
    course:

    sub toLower
    {
    my $str = shift;

    return ( lc($str) );
    }

    sub toUpper
    {
    my $str = shift;

    return ( uc($str) );
    }

    If you have any other comments or want to press home the ones I have
    omitted to reply to here, please feel free to mail me directly, my
    email address is _sf_AT_aleph-one_DOTcom, replace the underscores and
    uppercase but keep the hyphen.

    Kind regards,

    Jim
    biggus, Apr 20, 2006
    #6
  7. "biggus" <> wrote in
    news::

    > Sinan, hi,


    ....

    > If you have any other comments or want to press home the ones I have
    > omitted to reply to here, please feel free to mail me directly, my
    > email address is _sf_AT_aleph-one_DOTcom, replace the underscores and
    > uppercase but keep the hyphen.


    I think the case is closed for me: There is no reason for the Perl version
    of Jasper to exist.

    I do recommend that you actually learn Perl before writing Perl. Perl ships
    with excellent documentation, and there are great Perl books out there.

    Sinan
    A. Sinan Unur, Apr 20, 2006
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. biggus
    Replies:
    0
    Views:
    352
    biggus
    Apr 20, 2006
  2. biggus
    Replies:
    0
    Views:
    400
    biggus
    Apr 20, 2006
  3. DC
    Replies:
    5
    Views:
    942
  4. Pankaj Jain
    Replies:
    1
    Views:
    800
    Duncan McC
    Jun 11, 2008
  5. VK
    Replies:
    1
    Views:
    89
Loading...

Share This Page