Do you find perl code "messy" ?

Page 2 - Seeking answers? Join the AnandTech community: where nearly half-a-million members share solutions and discuss the latest tech.

glugglug

Diamond Member
Jun 9, 2002
5,340
1
81
Perl is a mess, even "clean" perl is difficult to read. The syntax is quite sadistic.

Contrary to popular belief, C++ is a very clean, easy to follow language if done right, much like Java. The same can not be said for Perl.
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Originally posted by: williamkusumo
Why use Perl when PHP can get all the job done too?

PHP is generally only used for website scripting. perl gets used everywhere.
 

AFB

Lifer
Jan 10, 2004
10,718
3
0
Originally posted by: n0cmonkey
Originally posted by: williamkusumo
Why use Perl when PHP can get all the job done too?

PHP is generally only used for website scripting. perl gets used everywhere.

This man speaks the truth. PHP is generally for the web (It has a CLI ) and Perl is more general purpose.
 

Barnaby W. Füi

Elite Member
Aug 14, 2001
12,343
0
0
Originally posted by: Alternex
Suppose in the future data gets stabilized and everything is in databases or XML - then there wouldn't be as much a focus on regular expressions.
Since when is everything supposed to be in databases or xml? They are hardly appropriate for all data. Only some. And what stops one from using regexps on xml?


Originally posted by: glugglug
Contrary to popular belief, C++ is a very clean, easy to follow language if done right, much like Java.

I disagree. You need to duplicate tons of crap between headers and implementation files. Templates make the problem even worse, with you having to duplicate the template<....> for *every* method in the implementation file. The STL, though powerful and quite fun to monkey with, is not always syntactically fun to decipher.

"const std::string&amp; foo" anyone? mem_fun? bind2nd? transform?

There are probably countless other things I could bring up about how C++ is not a clean, easy to follow language. Is it easy to write cout << "hello world" << endl;? Sure, but who wants to do that all day?

The same can not be said for Perl.

I think notfred's post demonstrated some pretty straightforward perl. It made sense to me, and I am barely familiar with perl (only coded a tiny bit, once).
 

Armitage

Banned
Feb 23, 2001
8,086
0
0
Originally posted by: n0cmonkey
Originally posted by: williamkusumo
Why use Perl when PHP can get all the job done too?

PHP is generally only used for website scripting. perl gets used everywhere.

Well, that and PHP is just a krufty kludge of a language. Maybe it got better in 5.0?
 

Armitage

Banned
Feb 23, 2001
8,086
0
0
Originally posted by: Alternex
Just wondering but how often do you guys use regular expressions? Is everyone doing data mining and/or maintaining old data?

Suppose in the future data gets stabilized and everything is in databases or XML - then there wouldn't be as much a focus on regular expressions.

I'm using regex a fair bit. Mostly for writing validators &amp; parsers for ascii files in preparation for pushing em into a db.
 

Barnaby W. Füi

Elite Member
Aug 14, 2001
12,343
0
0
Originally posted by: Armitage
Originally posted by: n0cmonkey
Originally posted by: williamkusumo
Why use Perl when PHP can get all the job done too?

PHP is generally only used for website scripting. perl gets used everywhere.

Well, that and PHP is just a krufty kludge of a language. Maybe it got better in 5.0?

The standard library has only been expanded (i.e. most of it is the same or only very slightly changed), and most of the new language features are regarding OO. Oh, it has exceptions. That's probably the most notable thing. But no, it's definitely still a crufty kludge. :D
 

notfred

Lifer
Feb 12, 2001
38,241
4
0
Originally posted by: Alternex
Just wondering but how often do you guys use regular expressions? Is everyone doing data mining and/or maintaining old data?

Suppose in the future data gets stabilized and everything is in databases or XML - then there wouldn't be as much a focus on regular expressions.

If databases are supposed to eliminate the need for regexes, why does SQL have the 'regexp' keyword?
 

Descartes

Lifer
Oct 10, 1999
13,968
2
0
Originally posted by: notfred
Originally posted by: Alternex
Just wondering but how often do you guys use regular expressions? Is everyone doing data mining and/or maintaining old data?

Suppose in the future data gets stabilized and everything is in databases or XML - then there wouldn't be as much a focus on regular expressions.

If databases are supposed to eliminate the need for regexes, why does SQL have the 'regexp' keyword?

I think I understand what he's saying, and I believe it's a rather utopian view of data. If all data is structured, then there would be no need to use regular expressions to extrapolate from amorphous sets of data. I think this is the primary use of regular expressions for most people, and it's especially so in my case.

If everything is XML, then all translations occur only between structured formats; this is true, but that's only a holistic view of the entire set of data. You're still left with individual records that contain sets of data that might not necessarily be logically separated, and a regular expression would therefore be used to extrapolate its contents. One might argue that proper normalization of an XML vernacular or database would minimize this need, but we are then again referring back to the utopian view of data.

imo.
 

AFB

Lifer
Jan 10, 2004
10,718
3
0
Blasphemy :|. You can never have too much stucture in programing.








:)Maybe, but I doubt it.
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Originally posted by: MrChad
Originally posted by: n0cmonkey
I ph33r the day everything becomes XMLized.

Why? XSL has all the data manipulation functions you could ever need! ;) :p

It's fine for some things, but very little of what I do would gain anything by being XMLized. Can you imagine how big log files would get with all of the extra formatting crap?
 

AFB

Lifer
Jan 10, 2004
10,718
3
0
Originally posted by: n0cmonkey
Originally posted by: MrChad
Originally posted by: n0cmonkey
I ph33r the day everything becomes XMLized.

Why? XSL has all the data manipulation functions you could ever need! ;) :p

It's fine for some things, but very little of what I do would gain anything by being XMLized. Can you imagine how big log files would get with all of the extra formatting crap?

But with HDD prices coming down every day, what's the problem ?
 

Barnaby W. Füi

Elite Member
Aug 14, 2001
12,343
0
0
Originally posted by: amdfanboy
Originally posted by: n0cmonkey
Originally posted by: MrChad
Originally posted by: n0cmonkey
I ph33r the day everything becomes XMLized.

Why? XSL has all the data manipulation functions you could ever need! ;) :p

It's fine for some things, but very little of what I do would gain anything by being XMLized. Can you imagine how big log files would get with all of the extra formatting crap?

But with HDD prices coming down every day, what's the problem ?

Heh, have fun parsing a gargantuan log file into a DOM tree. :) I'm pretty sure xml needs to all be loaded into memory to parse it, but I could be wrong. I think that's at least a pretty common approach. With text-processing tools, I can do the same things with/to a log file that you'd do with xml, with less code, less complications, and less resource use.

tail -f /var/log/apache/access_log
grep 'GET /somefile' /var/log/apache/access_log | more

How would xml help with things like these? As far as I can see, it'd just make it worse. xml isn't really meant to be read or written by a human.
 

AFB

Lifer
Jan 10, 2004
10,718
3
0
I don't know, XML parsing is petty fast. (It was on 1&amp;1's shared servers) It took < 2 seconds to parse and rewrite a 4meg XML file in PHP.
 

Templeton

Senior member
Oct 9, 1999
467
0
0
Originally posted by: BingBongWongFooey
Originally posted by: amdfanboy
Originally posted by: n0cmonkey
Originally posted by: MrChad
Originally posted by: n0cmonkey
I ph33r the day everything becomes XMLized.

Why? XSL has all the data manipulation functions you could ever need! ;) :p

It's fine for some things, but very little of what I do would gain anything by being XMLized. Can you imagine how big log files would get with all of the extra formatting crap?

But with HDD prices coming down every day, what's the problem ?

Heh, have fun parsing a gargantuan log file into a DOM tree. :) I'm pretty sure xml needs to all be loaded into memory to parse it, but I could be wrong. I think that's at least a pretty common approach. With text-processing tools, I can do the same things with/to a log file that you'd do with xml, with less code, less complications, and less resource use.

tail -f /var/log/apache/access_log
grep 'GET /somefile' /var/log/apache/access_log | more

How would xml help with things like these? As far as I can see, it'd just make it worse. xml isn't really meant to be read or written by a human.

It depends on what you want to do with xml, it can be read as a stream of data using things like sax - useful if you only care about small amounts of data at a time. (for me anyway) I agree that many things are made more complex with little real benifit when using xml - log files are a good example... at the same time I'd much rather deal with xml data when programming, tends to be easier for me.
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Originally posted by: Templeton
Originally posted by: BingBongWongFooey
Originally posted by: amdfanboy
Originally posted by: n0cmonkey
Originally posted by: MrChad
Originally posted by: n0cmonkey
I ph33r the day everything becomes XMLized.

Why? XSL has all the data manipulation functions you could ever need! ;) :p

It's fine for some things, but very little of what I do would gain anything by being XMLized. Can you imagine how big log files would get with all of the extra formatting crap?

But with HDD prices coming down every day, what's the problem ?

Heh, have fun parsing a gargantuan log file into a DOM tree. :) I'm pretty sure xml needs to all be loaded into memory to parse it, but I could be wrong. I think that's at least a pretty common approach. With text-processing tools, I can do the same things with/to a log file that you'd do with xml, with less code, less complications, and less resource use.

tail -f /var/log/apache/access_log
grep 'GET /somefile' /var/log/apache/access_log | more

How would xml help with things like these? As far as I can see, it'd just make it worse. xml isn't really meant to be read or written by a human.

It depends on what you want to do with xml, it can be read as a stream of data using things like sax - useful if you only care about small amounts of data at a time. (for me anyway) I agree that many things are made more complex with little real benifit when using xml - log files are a good example... at the same time I'd much rather deal with xml data when programming, tends to be easier for me.

Look at a log in XML format with standard unix tools (more, grep, etc). Using a program that imports the log files and puts them in an XML format for display is one thing. But storing the log files for standard review in XML is just a PITA.