is Perl used in the Java middle-tier

A

andrew_nuss

Hi,

I'm a newbie at regexes and a professional java programmer. I've ready
Friedl's book and see that
java.util.regex is missing code assertions and overall can't solve the
complexity of matching, transformation
problems that Perl can solve. Therefore, I'm wondering if there are
companies that are integrating Perl
solutions into their enterprise java applications. Or do they just
struggle with java.util.regex.

Andy
 
C

Charlton Wilbur

an> Therefore, I'm wondering if there are companies that are
an> integrating Perl solutions into their enterprise java
an> applications. Or do they just struggle with java.util.regex.

I don't know of any; generally, any company that's smart enough to
comprehend that Perl can be more expressive than Java generally isn't
using Java for enterprise applications.

Charlton
 
J

Joachim Pense

Am 5 Jan 2007 06:49:02 -0800 schrieb (e-mail address removed):
Hi,

I'm a newbie at regexes and a professional java programmer. I've ready
Friedl's book and see that
java.util.regex is missing code assertions and overall can't solve the
complexity of matching, transformation
problems that Perl can solve. Therefore, I'm wondering if there are
companies that are integrating Perl
solutions into their enterprise java applications. Or do they just
struggle with java.util.regex.

Andy

Use C#. Then you have regexes with Perl's complexity (of course
without Perl's elegance, but you're used to that being a Java
programmer).

Joachim
 
A

andrew_nuss

Use C#. Then you have regexes with Perl's complexity (of course
without Perl's elegance, but you're used to that being a Java
programmer).

Does C# have code assertions?
 
J

Joachim Pense

Am 5 Jan 2007 09:42:27 -0800 schrieb (e-mail address removed):
Does C# have code assertions?

I'm not an expert, but googling leads me to the answer "yes".
 
B

brian d foy

I'm a newbie at regexes and a professional java programmer. I've ready
Friedl's book and see that
java.util.regex is missing code assertions and overall can't solve the
complexity of matching, transformation
problems that Perl can solve.

Have you run into a situation where you needed the missing features?
Perl's regex engine has a lot of nifty tools, but if you don't need
them it doesn't really matter if they are missing from Java. :)
 
J

James Willmore

Therefore, I'm wondering if there are
companies that are integrating Perl
solutions into their enterprise java applications. Or do they just
struggle with java.util.regex.
<snip>

I started out using Perl as my language of choice and switched to
Java about 2 years ago. Partly to obtain a programming position in
the company I work for and partly because Java is more accepted in
the field today (think Oracle applications).

Anyway ...

A more senior programmer in my department at work and I had a
discussion on the use of regular expressions in Java. He didn't
really see a need to use regular expressions in Java as it is used
in Perl. Why? Because there are other ways to parse Strings in
Java that have been included in the language since version 1.0. For
example, the String methods startsWith, endsWith, substring or the
StringTokenizer class.

However ...

Since this is a Perl newsgroup :), this question may be better
asked in a Java newsgroup.

OTOH ...

I think, after using Java for a while now, that there can be over
use of regular expressions in any language that supports them. For
example, in Perl, there are other ways to parse data (ex. split,
pack, unpack, substr, etc). Yet, I see scripts that will use a
regex versus a function to split up a line. Of course, since Perl
doesn't have a "startsWith" method, you're stuck using a regex to
find something at the start of a line or scalar value.

In the end, if you see you're using a lot of regular expressions to
accomplish a task in any language, get someone else to look over
your code ... someone who is unfamiliar with regular expressions (or
hates using them). You'll find that there's a happy medium between
the regular expressions being used and alternative approaches to the
problem(s) at hand.

HTH
 
U

Uri Guttman

JW> I think, after using Java for a while now, that there can be over use
JW> of regular expressions in any language that supports them. For
JW> example, in Perl, there are other ways to parse data (ex. split, pack,
JW> unpack, substr, etc). Yet, I see scripts that will use a regex versus
JW> a function to split up a line. Of course, since Perl doesn't have a
JW> "startsWith" method, you're stuck using a regex to find something at
JW> the start of a line or scalar value.

you are not using perl if you only use regexes to do string
stuff. startswith can be done like this:

substr( $string, 0, length $begin ) eq $begin ;

but why would you if

$string =~ /^$begin/ ;

does the job?

the issue with java vs perl is more than regexes, it is the verbosity of
java to get anything done. i don't want to type all those extra methods
and lines and whatnot to get the job done. and i do fine in the work
environment with just perl. you just need to not work for stupid large
corps that have no clue. and there are plenty of large shops that do
perl. check out jobs.perl.org for many perl jobs from all over the world
and in all sorts of companies.

JW> In the end, if you see you're using a lot of regular expressions to
JW> accomplish a task in any language, get someone else to look over your
JW> code ... someone who is unfamiliar with regular expressions (or hates
JW> using them). You'll find that there's a happy medium between the
JW> regular expressions being used and alternative approaches to the
JW> problem(s) at hand.

not likely unless they are using regexes for absolutely everything.

and btw, split IS a regex function in perl. so using split on a line is
still using a regex.

uri
 
T

Tad McClellan

James Willmore said:
Of course, since Perl
doesn't have a "startsWith" method,


.... then you can just write one:

sub startsWith {
my($str, $search) = @_;

return 1 if substr($str, 0, length $search) eq $search;
return 0;
}
you're stuck using a regex to
find something at the start of a line or scalar value.


No you're not.

Somebody recently said people think of regexes too often, to the
exclusion of alternatives.

Oh, that somebody was you! :)
 
D

David Lee Lambert

Am 5 Jan 2007 06:49:02 -0800 schrieb (e-mail address removed):
[...] that
java.util.regex is missing code assertions and overall can't solve the
complexity of matching, transformation
problems that Perl can solve. Therefore, I'm wondering if there are
companies that are integrating Perl
solutions into their enterprise java applications. Or do they just
struggle with java.util.regex.
Use C#. Then you have regexes with Perl's complexity (of course
without Perl's elegance, but you're used to that being a Java
programmer).

Speaking of that, I recently wrote J# code to expose the .NET regex
engine as java.util.regex-compatible classes:

http://www.lmert.com/bb/modcp.php?mode=split&t=613

On a more serious note, I doubt anyone "struggles" with
java.util.regex; the missing features are so obscure that they can
easily be worked around in code. However, it's really easy to spawn a
perl interpreter in Java; something like

Process p = System.getRuntime().exec("perl", new String[] { "-e",
"exit((" + perlquote(arg) +
")=~/really(wierd)pattern/ ? 0 : 1 ) " });
p.waitFor();
boolean matches = (p.exitValue()==0);

where perlquote() quotes its argument appropriately.
 
A

Arved Sandstrom

Does C# have code assertions?

Most languages do (sort of), if you can duplicate the effect of an assert
using native constructs. Frequently, "if" statements (or their equivalent)
are the same thing: "if" something is true/not true, then barf/don't barf.

Asserts do have value in that they can be more easily divorced from your
real code.

AFAIK, C# has asserts, through Debug.Assert.

AHS
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,015
Latest member
AmbrosePal

Latest Threads

Top