List Info

Thread: JavaScript::Minifier new version




JavaScript::Minifier new version
user name
2007-05-26 12:58:09
Hi All,

I'm new to Perl and Catalyst. I thought I'd give first
(before the
onslaught of Catalyst questions). I
wrote a new version of
JavaScript::Minifier and since you are web folks I thought
some might
find it userful.

http://peter.mic
haux.ca/article/2242

Peter

_______________________________________________
List: Catalystlists.rawmode.org
Listinfo: ht
tp://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-
archive.com/catalystlists.rawmode.org/
Dev site: http://dev.catalyst.per
l.org/

Re: JavaScript::Minifier new version
country flaguser name
United Kingdom
2007-05-26 14:16:25
On Sat, May 26, 2007 at 10:58:09AM -0700, Peter Michaux
wrote:
> Hi All,
> 
> I'm new to Perl and Catalyst. I thought I'd give first
(before the
> onslaught of Catalyst questions). I
wrote a new version of
> JavaScript::Minifier and since you are web folks I
thought some might
> find it userful.

Get your ass on #catalyst on irc.perl.org then instead of
confusing me in
freenode#perl!

-- mst

-- 
      Matt S Trout       Need help with your Catalyst or
DBIx::Class project?
   Technical Director    Want a managed development or
deployment platform?
 Shadowcat Systems Ltd.  Contact mst (at)
shadowcatsystems.co.uk for a quote
http://chainsawblues.vo
x.com/             http://www.shadowc
atsystems.co.uk/ 

_______________________________________________
List: Catalystlists.rawmode.org
Listinfo: ht
tp://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-
archive.com/catalystlists.rawmode.org/
Dev site: http://dev.catalyst.per
l.org/

Re: JavaScript::Minifier new version
user name
2007-05-26 15:04:19
On 5/26/07, Matt S Trout <dbix-classtrout.me.uk> wrote:
> On Sat, May 26, 2007 at 10:58:09AM -0700, Peter Michaux
wrote:
> > Hi All,
> >
> > I'm new to Perl and Catalyst. I thought I'd give
first (before the
> > onslaught of Catalyst questions). I
wrote a new version of
> > JavaScript::Minifier and since you are web folks I
thought some might
> > find it userful.
>
> Get your ass on #catalyst on irc.perl.org then instead
of confusing me in
> freenode#perl!

The module is not Catalyst specific so I thought #perl was
more appropriate.

Peter

_______________________________________________
List: Catalystlists.rawmode.org
Listinfo: ht
tp://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-
archive.com/catalystlists.rawmode.org/
Dev site: http://dev.catalyst.per
l.org/

Re: JavaScript::Minifier new version
user name
2007-05-26 15:57:48
On 5/26/07, Peter Michaux <petermichauxgmail.com> wrote:
> I'm new to Perl and Catalyst. I thought I'd give first
(before the
> onslaught of Catalyst questions). I
wrote a new version of
> JavaScript::Minifier and since you are web folks I
thought some might
> find it userful.

This is probably something handy to have around. However I
think you
forgot to clean up your SVN working copy before committing
the module
to CPAN.

By the way, I looked at the code and I think I'll make some
suggestions. First of all: don't be afraid to use regular
expressions.
They're fast and can make your code cleaner and shorter.

One example:

  sub isInfix {
    my $x = shift;
    return ($x eq ',' || $x eq '=' || $x eq ';' ||
            $x eq '?' || $x eq ':' || $x eq '&' ||
            $x eq '%' || $x eq '*' || $x eq '|' ||
            $x eq '<' || $x eq '>' || $x eq
"n");
  }

This could be rewritten as:

  sub isInfix_re {
    my $x = shift;
    $x =~ /[,=;?:&%*|<>n]/;
  }

It's shorter and (arguably) cleaner. But it's also faster:

         Rate normal     re
normal 3765/s     --   -48%
re     7189/s    91%     --

In fact, all of your isXXX() functions could be rewritten as
regular
expressions. If you really wanted speed improvements, you
could store
the precompiled regexes (using qr//) and do away with the
function
call. Doing that will earn you another two-fold speed
improvement.

But I'll stop here because this is already way off topic for
a
Catalyst mailing list.

Since you're new to Perl and, according to your blog posts,
you're
wondering if a language could be any uglier than Perl, may I
suggest
you take a look at more modern ways of coding Perl such as
using Moose
or even reading Higher Order Perl (since you seem to like
Lisp). I
won't suggest Catalyst itself (along with DBIx::Class)
because, since
you're here, you're probably already aware of it. 

-Nilson Santos F. Jr.

_______________________________________________
List: Catalystlists.rawmode.org
Listinfo: ht
tp://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-
archive.com/catalystlists.rawmode.org/
Dev site: http://dev.catalyst.per
l.org/

Re: JavaScript::Minifier new version
user name
2007-05-26 17:01:21
Hi Nilson,

Thanks for the feedback.

On 5/26/07, Nilson Santos Figueiredo Junior <acid06gmail.com> wrote:
> On 5/26/07, Peter Michaux <petermichauxgmail.com> wrote:
> > I'm new to Perl and Catalyst. I thought I'd give
first (before the
> > onslaught of Catalyst questions). I
wrote a new version of
> > JavaScript::Minifier and since you are web folks I
thought some might
> > find it userful.
>
> This is probably something handy to have around.
However I think you
> forgot to clean up your SVN working copy before
committing the module
> to CPAN.

I forgot to do export instead of a fresh checkout. Ok. I'll
get that next time.


> By the way, I looked at the code and I think I'll make
some
> suggestions. First of all: don't be afraid to use
regular expressions.
> They're fast and can make your code cleaner and
shorter.

I'll change them in the next version. I didn't realize
regexps are
that much faster.


> Since you're new to Perl and, according to your blog
posts, you're
> wondering if a language could be any uglier than Perl,
may I suggest
> you take a look at more modern ways of coding Perl such
as using Moose
> or even reading Higher Order Perl (since you seem to
like Lisp). I
> won't suggest Catalyst itself (along with DBIx::Class)
because, since
> you're here, you're probably already aware of it. 

Thanks for the suggestions. I just want to keep a little
utility
module like this plain Perl without any dependencies. Just
because I
think Perl if funny looking doesn't affect whether or not
I'll be
using it. With my first Perl adventure I did notice that it
is very
slow to type $s-> instead of s.a like in JavaScript.

Thanks again,
Peter

_______________________________________________
List: Catalystlists.rawmode.org
Listinfo: ht
tp://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-
archive.com/catalystlists.rawmode.org/
Dev site: http://dev.catalyst.per
l.org/

Re: JavaScript::Minifier new version
user name
2007-05-26 17:29:34
On 5/26/07, Peter Michaux <petermichauxgmail.com> wrote:
> Thanks for the suggestions. I just want to keep a
little utility
> module like this plain Perl without any dependencies.
Just because I
> think Perl if funny looking doesn't affect whether or
not I'll be
> using it. With my first Perl adventure I did notice
that it is very
> slow to type $s-> instead of s.a like in
JavaScript.

I don't really think using Moose would fit this specific
example, but
since you seem to be developing using Perl, it might be a
nice
addition to your projects.

If you're using objects instead of hashes it's pretty common
to use
accessor methods (generated using Class::Accessor or some
other
module). So, instead of $obj->, you can use
$obj->property,
which is a bit cleaner.

Perl 6 will take care of making that: obj.property

I also just remembered that there's actually a module called
Acme:ot
for Perl5 which provides dotted syntax for Perl5 but, as the
Acme
namespace indicates, it's not really meant to be used in any
serious
way. But it's nevertheless interesting to see how the
language can be
flexible, though.

-Nilson Santos F. Jr.

_______________________________________________
List: Catalystlists.rawmode.org
Listinfo: ht
tp://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-
archive.com/catalystlists.rawmode.org/
Dev site: http://dev.catalyst.per
l.org/

Re: JavaScript::Minifier new version
user name
2007-05-26 17:35:38
On 5/26/07, Nilson Santos Figueiredo Junior <acid06gmail.com> wrote:
> Perl 6 will take care of making that: obj.property

Oops, missed the dollar sign, it's: $obj.property

-Nilson Santos F. Jr.

_______________________________________________
List: Catalystlists.rawmode.org
Listinfo: ht
tp://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-
archive.com/catalystlists.rawmode.org/
Dev site: http://dev.catalyst.per
l.org/

Re: JavaScript::Minifier new version
country flaguser name
United Kingdom
2007-05-26 18:50:51
On Sat, May 26, 2007 at 01:04:19PM -0700, Peter Michaux
wrote:
> On 5/26/07, Matt S Trout <dbix-classtrout.me.uk> wrote:
> >On Sat, May 26, 2007 at 10:58:09AM -0700, Peter
Michaux wrote:
> >> Hi All,
> >>
> >> I'm new to Perl and Catalyst. I thought I'd
give first (before the
> >> onslaught of Catalyst questions). I
wrote a new version of
> >> JavaScript::Minifier and since you are web
folks I thought some might
> >> find it userful.
> >
> >Get your ass on #catalyst on irc.perl.org then
instead of confusing me in
> >freenode#perl!
> 
> The module is not Catalyst specific so I thought #perl
was more appropriate.

Sigh. Way to take a silly comment seriously.

Go get a beer 

-- 
      Matt S Trout       Need help with your Catalyst or
DBIx::Class project?
   Technical Director    Want a managed development or
deployment platform?
 Shadowcat Systems Ltd.  Contact mst (at)
shadowcatsystems.co.uk for a quote
http://chainsawblues.vo
x.com/             http://www.shadowc
atsystems.co.uk/ 

_______________________________________________
List: Catalystlists.rawmode.org
Listinfo: ht
tp://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-
archive.com/catalystlists.rawmode.org/
Dev site: http://dev.catalyst.per
l.org/

Re: JavaScript::Minifier new version
country flaguser name
United States
2007-05-26 19:06:01
On Saturday 26 May 2007 06:50:51 pm Matt S Trout wrote:

> > >Get your ass on #catalyst on irc.perl.org then
instead of confusing me
> > > in freenode#perl!
> >
> > The module is not Catalyst specific so I thought
#perl was more
> > appropriate.
>
> Sigh. Way to take a silly comment seriously.
>
> Go get a beer 

To be fair to Mr Michaux, your original comment didn't make
much sense.  
One-liners are often funny, but sometimes it's helpful to
step back and 
explain what your sentence is trying to achieve ;)

-- 
package JAPH;use Catalyst
qw/-Debug/;($;=JAPH)->config(name => do {
$,.=reverse qw[Jonathan tsu rehton lre rekca
Rockway][$_].[split //,
";$;"]->[$_].q; ;for
1..4;$,=~s;^.;;;$,});$;->setup;

_______________________________________________
List: Catalystlists.rawmode.org
Listinfo: ht
tp://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-
archive.com/catalystlists.rawmode.org/
Dev site: http://dev.catalyst.per
l.org/

Re: JavaScript::Minifier new version
user name
2007-05-26 19:12:21
On 5/26/07, Matt S Trout <dbix-classtrout.me.uk> wrote:
> On Sat, May 26, 2007 at 01:04:19PM -0700, Peter Michaux
wrote:
> > On 5/26/07, Matt S Trout <dbix-classtrout.me.uk> wrote:
> > >On Sat, May 26, 2007 at 10:58:09AM -0700,
Peter Michaux wrote:
> > >> Hi All,
> > >>
> > >> I'm new to Perl and Catalyst. I thought
I'd give first (before the
> > >> onslaught of Catalyst questions). I
wrote a new version of
> > >> JavaScript::Minifier and since you are
web folks I thought some might
> > >> find it userful.
> > >
> > >Get your ass on #catalyst on irc.perl.org then
instead of confusing me in
> > >freenode#perl!
> >
> > The module is not Catalyst specific so I thought
#perl was more appropriate.
>
> Sigh. Way to take a silly comment seriously.
>
> Go get a beer 

It is hard to tell on the internet when people are serious
or sarcastic. 

Peter

_______________________________________________
List: Catalystlists.rawmode.org
Listinfo: ht
tp://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-
archive.com/catalystlists.rawmode.org/
Dev site: http://dev.catalyst.per
l.org/

[1-10] [11-19]

about | contact  Other archives ( Real Estate discussion Medical topics )