public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Programming Anti-patterns in Shell and Perl Scripts
@ 2011-06-28 18:54 Sravan Bhamidipati
  2011-06-28 19:21 ` Ryan Johnson
  2011-06-29  2:37 ` Sravan Bhamidipati
  0 siblings, 2 replies; 3+ messages in thread
From: Sravan Bhamidipati @ 2011-06-28 18:54 UTC (permalink / raw)
  To: cygwin

Hello Cygwin. :-)

I have been working on static code analysis from a performance
perspective, and I recently applied the concept to Shell and Perl
scripts. The most basic idea was to look for usages of Unix commands,
their combinations with pipes, and stuff like that to which
alternatives using Shell built-ins (or Perl functions) could be
possible. e.g. Using ((num++)) instead of `expr $num + 1`. In examples
where I had "fixed" anti-patterns, there was often a noticeable
improvement (mostly realized in the form of faster runtime). I have
also written a dirty parser and put together basic "guides" to go
about this: http://bsravanin.blogspot.com/search/label/anti-patterns.

Among Cygwin packages, bash-completion has some of the highest
programming anti-patterns, but there are various others as well. Does
this seem like a useful idea? If it is, what could be a good way of
going about implementing it?

Thanks,
Sravan

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Programming Anti-patterns in Shell and Perl Scripts
  2011-06-28 18:54 Programming Anti-patterns in Shell and Perl Scripts Sravan Bhamidipati
@ 2011-06-28 19:21 ` Ryan Johnson
  2011-06-29  2:37 ` Sravan Bhamidipati
  1 sibling, 0 replies; 3+ messages in thread
From: Ryan Johnson @ 2011-06-28 19:21 UTC (permalink / raw)
  To: cygwin

On 28/06/2011 2:53 PM, Sravan Bhamidipati wrote:
> Hello Cygwin. :-)
>
> I have been working on static code analysis from a performance
> perspective, and I recently applied the concept to Shell and Perl
> scripts. The most basic idea was to look for usages of Unix commands,
> their combinations with pipes, and stuff like that to which
> alternatives using Shell built-ins (or Perl functions) could be
> possible. e.g. Using ((num++)) instead of `expr $num + 1`. In examples
> where I had "fixed" anti-patterns, there was often a noticeable
> improvement (mostly realized in the form of faster runtime). I have
> also written a dirty parser and put together basic "guides" to go
> about this: http://bsravanin.blogspot.com/search/label/anti-patterns.
>
> Among Cygwin packages, bash-completion has some of the highest
> programming anti-patterns, but there are various others as well. Does
> this seem like a useful idea? If it is, what could be a good way of
> going about implementing it?
I don't use bash-completion myself, but my understanding is that it can 
be very slow, if for no other reason than fork() is slow in cygwin. If 
your de-anti-pattern transformation causes fewer calls to fork() -- and 
the above expr example suggests it does -- it could be very worthwhile.

Implementation-wise, you probably want to start here: 
http://www.cygwin.com/contrib.html

Ryan


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Programming Anti-patterns in Shell and Perl Scripts
  2011-06-28 18:54 Programming Anti-patterns in Shell and Perl Scripts Sravan Bhamidipati
  2011-06-28 19:21 ` Ryan Johnson
@ 2011-06-29  2:37 ` Sravan Bhamidipati
  1 sibling, 0 replies; 3+ messages in thread
From: Sravan Bhamidipati @ 2011-06-29  2:37 UTC (permalink / raw)
  To: cygwin

On 28/06/2011 3:21 PM, Ryan Johnson wrote:
> I don't use bash-completion myself, but my understanding is
> that it can be very slow, if for no other reason than fork() is
> slow in cygwin. If your de-anti-pattern transformation causes
> fewer calls to fork() -- and the above expr example suggests
> it does -- it could be very worthwhile.

That's the basic underlying principle to start with, Ryan. That in
general: Accessing memory << Calling a function << Forking a process.


> Implementation-wise, you probably want to start here:
> http://www.cygwin.com/contrib.html

You mean directly making those changes? I've never done that before,
so I was hoping to catch the attention of a few of the package
owners/contributors and give/take their help.

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-06-29  2:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-28 18:54 Programming Anti-patterns in Shell and Perl Scripts Sravan Bhamidipati
2011-06-28 19:21 ` Ryan Johnson
2011-06-29  2:37 ` Sravan Bhamidipati

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).