As in the words of the famous cfmdobbie
“Erk. Learning Perl is less fun than gouging your eyes out with a spoon. ;)”
http://www.java-gaming.org/cgi-bin/JGNetForums/YaBB.cgi?board=Offtopic;action=display;num=1049054236;start=1#1
my last job had me working completely in Perl. I was indifferent to it at first, but after about a month or so I came to really like it. It’s really, really not that bad and I honestly think people who say it is just never bit the bullet and learned it. There is a method to the madness and once you see it, Perl becomes very logical (and elegant, believe it or not).
And regular expressions are not so bad once you get a feel for them. I always assumed they were as cryptic as can be, but there’s only a few constructs that form them. For particularly complex ones, the ‘/x’ modifier can be used to comment them. The up side is they make writing programs that parse lots of text incredibly succint, dozens if not hundreds of fewer lines than equivalent Java or C code. Perl can really be quite beautiful in the right situation.
IMHO, regexp’s are very easy and clever and wonderful; the standard perl5 encoding of the regexp symbols is evil, horrible and stupid.
Hand-written regexp’s e.g. in a mathematical text describing finite automata are generally trivial to read and understand. But to:
[] Use alphanumerics (amongst others) as special symbols
[] Use arbitrary rules of when a symbol is itself, and when it’s escaped
[] Make the escaping very very difficult to follow without a suitably intelligent char-by-char color-coding text editor
[] Make the whole thing case-sensitive!
seems deliberately evil.
Basic perl’s pretty good, but I’ve never had any faith in making it OO and such-like; a language which massively simplifies itself to the point that your 3 basic datatypes are “string, list and map” seems not really suited to anything complex enough to require OO. If you just perl to do simple (and very fast to create) programs it’s good; once upon a time it was “great” (when it was v.effective at e.g. making up for the crap UI deficiences in lots of shell apps), but now that far more mature and carefully planned things have appeared (python, bsh, php etc) that can handle the simplicity and the complexity it’s not really got a purpose any more, IMHO. Why code something in perl if you can do it with the same number of lines of code in python or beanshell?
…sure; excepting only that “perl5-compatible regexps” have been available for Java and C++ for years (e.g. I was definitely using OROinc’s java regexp’s 3 years ago…)
I think “Perl is a write only language”. Powerful but usually unreadable by others (who didn’t programm the script).
Personally I’d add: No need for PERL when there’s (GNU) AWK.
[quote]…once you see it, Perl becomes very logical
[/quote]
Where as most other languages start out logical and get better. I believe that people with a mind for programming can understand most of C/C++, Java, BASIC, Pascal, Python, etc… just by looking at code that has been written in it, without knowing ANY of those languages ahead of time. It is clear enough that you can just figure most of it out by looking at it. Perl is not like that, at leazt not for me. I am sure that I could “learn” perl and in time read it and understand it with relative ease… but I would consider that a tremendous waste of time. I would rather learn assembler, well I know assembler already, I learned it when I was about 13 years old after learning BASIC… that was relatively easy… Perl I had to force myself to learn… just barely enough to do what I needed (make Bugzilla emailing work on Windows). I was stunned by its cryptic “elegance”. Every time I figured out what a particular set of “instructions” was supposed to do my jaw would drop and I would say “Why don’t they just SAY SO, instead of encoding it into an almost incomprehensible mess?”, Then I would show the code snippet to a friend along with the equivalent Java or C code and we would have a good laugh at how utterly stupid Perl was. I even considered porting all of Bugzilla to Java… but only because looking at Perl had drivin me insane
sigh
You never took a compiler theory course, did you?
== is a single token. That you cannot split a single token with whitespace has NOTHING to do with significance of whitespace.
The term significance has a very specific meaning in compiler theory.
The issue with is you have THREE tokens <, STRING, and >. That whitespace BETWEEN the tokens matters is what makes it significant. In C, Pascal, Java et al tokens need to be delimited, which sometimes requires whitespace and sometimes doesn’t but the existence of whitespace between tokens does NOT change the meaning of the tokens.
There are many good books on language theory and context free grammers in particular. The “Dragon Book” is a classic. “Crafting a Compiler” is one of my personal favorites.
Agreed 100%. Can be very convenient to write but is VERY hard to read.
Isn’t this all opinion based? Just depends on how your mind works and what you find easy to work with?
Kev
Yes it is all opinion based. Same as Ford vs. Chevy, Toyota vs. Honda, do those “As seen on T.V.” products really work?, magnetic braclets to help circulation, and herbal remadies
As with any language, product or car YMMV.
Yeah… this nonsense is filed under Off Topic for a reason :).
Besides, only My opinion matters ;D
[quote]Isn’t this all opinion based? Just depends on how your mind works and what you find easy to work with?
Kev
[/quote]
Yes, to a degree its religious though I think there are good arguments that can be reasonably made. (Such as, to humans used to natural language, whitespace is a delimiter not a token and thus it is hard to read in environments where it is treated as a token.)
BTW, Jeff’s definition of religion:
“Relgion is an opinion or belief into which you invest emotion.”
I really don’t see it. Perl is basically C after it’s had a few drinks. You can use it exactly like C, all if/else, do while, while, for, ++, etc contructs are there (except Perl lacks switch), in the exact same form. Add in regular expressions, a looser structure, and a lot of shortcuts and that’s it. You can very easily ramp up to more advanced Perl, and until you’re comfortable with it just use Perl as a looser C with some nice conveniences. Nobody is suggesting Perl in its monstrous entirety needs to be used in all scripts.
This Perl phobia (not just you, it’s quite common) is like a child taking his cough medicine. It’s not that bad!
Perl saved me immense time. So much so that Java or C or even Python would have literally been impossible, the number of things I had to implement in the time I had. There’s a time and place for everything, and chances are CPAN’s already done it for you
qsort [] = []
qsort (x:xs) = qsort elts_lt_x ++ [x] ++ qsort elts_greq_x
where
elts_lt_x = [y | y <- xs, y < x]
elts_greq_x = [y | y <- xs, y >= x]
The Haskell community declares this quicksort program to be learnable from just looking at it, “You should be able to understand the program without any previous knowledge of either Haskell or quicksort.” (from the official “Intro to Haskell”, http://www.haskell.org/aboutHaskell.html). I really disagree. That program’s also nothing, Haskell gets much more bizarre. It makes Perl seem like reading a children’s book. Yet Haskell is an excellent choice for certain situations. There’s no such thing as a one size fits all language, they’ve all got their strengths. Including Perl. They’ve all got their weaknesses. Including Java.
[quote]I really don’t see it. Perl is basically C after it’s had a few drinks…
[/quote]
Of everclear, maybe. (Everclear == 199 proof alcohol).
The primary thing that makes PERL unreadable is the idea of “context”. A single variable has differnt values and meanings depending on where and how it is used.
You have to effectively run a light-weight PERL parser in your head to understand the context and thus meaning of the code.
It was an interesting idea, and it can be very convenient to WRITE but it does make it hard to read.
[quote]There’s no such thing as a one size fits all language, they’ve all got their strengths. Including Perl. They’ve all got their weaknesses. Including Java.
[/quote]
Sure, I’m of the opinion that Perl’s weaknesses GREATLY outweigh it’s strengths. I fully admit that there are a few things that CAN be expressed easily and neatly in Perl… though the reality is that every Perl program I’ve seen is a mess. Of course that made me stop looking at Perl so I haven’t seen all that much.
So, after seeing how awful the code was that was produced by people that actually knew Perl it was clear that there was no point in learning it… Why spend the effort so I know how to write ugly un-maintainable code?
I find your Haskel example easier to understand than Perl, but I fully admit it still sucks. People may say that it fits certain problems very well… so does Prolog and other languages that never get used in “real life”.
my favorite part is:
Can Java have inline assmebly?
well it could do a call to:
private native Object randomUnmaintainableCodeAcceptingAllArguments(Object data);
which was implemented in pure asm ;D
How about a class that stores its bytecode in a byte[] array, and creates its own classloader to load & resolve the embedded class, and then delegates all its private internal workings to the embedded class by using reflection?
Cas
hmm, you upped the ante - that code should ofcourse embed somekind of quine to make it even more fun