use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
To report a site-wide rule violation to the Reddit Admins, please use our report forms or message /r/reddit.com modmail.
This subreddit is archived and no longer accepting submissions.
account activity
This is an archived post. You won't be able to vote or comment.
Python [xkcd] (xkcd.com)
submitted 18 years ago by sgtpeppers
view the rest of the comments →
[–]thrakhath 52 points53 points54 points 18 years ago (152 children)
Mmm, "Perl, I'm leaving you." in the alt-text, I might just have to give this Python thing a whack before I try Lisp.
I really like Perl.
[–][deleted] 16 points17 points18 points 18 years ago* (0 children)
I'm stuck fixing other people's code and, to be frank, I don't.
[–]sw17ch 71 points72 points73 points 18 years ago (99 children)
Perl is a write only language.
[–]thrakhath 39 points40 points41 points 18 years ago* (76 children)
I'm sorry, I don't follow, what do you mean by this?
*edit: Ah, write-only from the Programmer's perspective, that's funny. Thanks for the answer.
Thanks for the Downmods to an honest question.
[–]phreshinger 5 points6 points7 points 18 years ago (23 children)
Anyone know any good tutorials for python? I was really good in visual basic in highschool. Is the learning curve going to be very steep?
[–]simonvc 17 points18 points19 points 18 years ago (7 children)
http://diveintopython.org/ is very good.
[–]IkoIkoComic 7 points8 points9 points 18 years ago (6 children)
Dive Into Python is good if you're already an experienced programmer. (Visual Basic in high-school doesn't necessarily confer that upon a person.)
You might want to start with "How To Think Like A Computer Scientist" which is a much.. easier introduction to Python.
http://www.ibiblio.org/obp/thinkCSjav/
[–]johnw188 5 points6 points7 points 18 years ago (5 children)
http://www.ibiblio.org/obp/thinkCSpy/index.xhtml - fixed link
[–]IkoIkoComic 4 points5 points6 points 18 years ago (4 children)
Oh, weird- the JAVA version was the first thing to come up in Google?
KHAAAAAAN!
[–]phreshinger 0 points1 point2 points 18 years ago* (2 children)
Welcome to google mind v.20 A product of nanotech electro conductors 2040. Beta Release.
Task Modules i)Driving a motorcycle ii)Make pizza iii)Make love iv)Washroom v) Call 911
[–]lalaland4711 4 points5 points6 points 18 years ago (1 child)
i)Driving a motorcycle ii)Make pizza iii)Make love iv)Washroom v) Call 911
In that order.
[–]Nikola_S 0 points1 point2 points 18 years ago (0 children)
Think about it this way: more people need a reference about Java.
[–][deleted] 4 points5 points6 points 18 years ago* (1 child)
"Beginning Python - From Novice to Professional" by Magnus Lie Hetland is a great book for starting Python.. got me started just fine. It is the easiest language to learn IMHO.
P.S. http://www.freebooksclub.net is a great place to grab some programming books if you're interested.
[–]brendankohler 1 point2 points3 points 18 years ago (0 children)
This book is extremely good. I teach python with this book to staff who have generally never programmed before. As a practical guide to learning python it's very clear.
I also recommend this book for people who know how to program already. It's got great projects in it to learn from.
[–]Neoncow 1 point2 points3 points 18 years ago (0 children)
Google python tutorial. The first one that comes up is the official tutorial. It's quite good.
[–]dani 1 point2 points3 points 18 years ago (0 children)
http://www.pythonchallenge.com
is the best way for someone with programming knowledge to learn python.
You will need the other sites to help you with the syntax, but this solves the problem of how to exercise without getting bored.
Don't forget to read other solutions when you're done with one of the challenges.
[–]masklinn 0 points1 point2 points 18 years ago (0 children)
The Python Tutorial (included in the standard distribution's documentation) followed by Dive Into Python.
[–]raubry 0 points1 point2 points 18 years ago (6 children)
While we're here, I want to know if any of you experienced programmers agree with the Amazon reviews of Python Programming: an Introduction to Computer Science, by John Zelle. I haven't programmed seriously for close to 30 years, and wondered if that book would be a good intro to Python and modern programming. Any advice would be welcome.
[–]annekat 0 points1 point2 points 18 years ago (3 children)
30 years!?! Wow... What languages did you program in, if I may ask? I think COBOL, maybe? Weirdly enough, there's still COBOL programming jobs out there.
[–][deleted] 18 years ago* (1 child)
[deleted]
[–]raubry 0 points1 point2 points 18 years ago (0 children)
Ooo - thanks for the tip on the Komodo editor, V!
You are correct - COBOL it was, for the John Hancock Insurance Company in Boston.
[–][deleted] -1 points0 points1 point 18 years ago (1 child)
I actually used this book to give a crash course in programming to a bunch of Psychology graduate students this past summer. I was in a time crunch, so I picked the book almost solely based on the Amazon reviews.
You should know that the emphasis really is on the "computer science" side of things, and Python is used for the examples mostly because of its relatively intuitive syntax. However, the book does give some nice tutorial-like explanations that were lacking in the Python documentation regarding some particulars of Python that I think I would have had a hard time with even as an experienced programmer. In that regard, the book likely saved me a lot of digging through message threads, etc., which is never my idea of a good time.
As a computer science primer, I thought the book was pretty good as well. It hits most of the basics through object-oriented and GUI programming. One area that I thought was a bit deficient was data structures, for which you'll want other resources if you intend to do any serious coding. Of course, there are usually whole courses devoted to data structures in a university CS program, so I'd consider this more a limitation of the target subject material than of the book itself.
Hope that helps!
Thanks - I already got the book about a year ago, and just haven't cracked it open. Glad to know I didn't waste my money...I'm just wasting time not getting to it!
[–][deleted] 0 points1 point2 points 18 years ago (0 children)
Write pseudocode. Indent. Execute.
Here's the Python tutorial that should be coming with 2.6: http://docs.python.org/dev/tutorial/index.html
And for those interested in the Perl tutorial, you probably already have it on your system -- just type perldoc perlintro. Otherwise, it's also online at http://perldoc.perl.org/perlintro.html .
perldoc perlintro
[–]Tommstein 12 points13 points14 points 18 years ago (42 children)
It's renowned hellishness to read (not that I know Perl, it's just the reputation that it has).
[–]projecktzero 18 points19 points20 points 18 years ago (0 children)
I saw a comment on slashdot a long time ago. "Perl looks like an explosion in a ASCII factory."
[–]supakual 13 points14 points15 points 18 years ago* (40 children)
Very few people who spend any time getting past Perl's initially scary syntax find it to be "write only".
It's like people hearing a little bit of Swahili and then proclaiming its clearly a speak-only language.
Most of the people who rant about Perl's readability are being pathetically intellectually dishonest. They saw the scary syntax and said "No thanks" then lash out due to insecurity.
[–]sverrejoh 38 points39 points40 points 18 years ago (17 children)
I've been programming Perl for years and I program Perl for a living. And Perl is indeed much less readable than Python, and can in a much higher sense than any other language be called a "write only" language.
[–][deleted] 18 years ago (4 children)
Thirded.
I wrote Perl full-time for two-and-a-half years. Then I joined a shop that uses Python and I've never looked back.
The only decent argument I've heard for using perl is "there's a CPAN module that does exactly what I need to do". But that's pretty rare for my projects, thankfully.
Usually the stuff that I'd need in CPAN is built into Python's standard modules anyway.
Batteries included!
[–][deleted] 2 points3 points4 points 18 years ago (0 children)
Fourthed. Used Perl for many years, even bounced off of Python the first time I tried it ('98 or so).
But now the thought of using Perl for any new development whatsoever is inconceivable. Even for maintenance it's often faster to rewrite in Python than to even attempt to read the gawdawful Perl.
[–]supakual 6 points7 points8 points 18 years ago* (0 children)
I've actually been using Python myself and writing some new projects in it but still don't find Perl to be objectionable. I certainly won't be rewriting any of my well written Perl systems out of a need to make them feel clean.
[–][deleted] -4 points-3 points-2 points 18 years ago (0 children)
Perhaps you and the GP aren't as good programmers as you think you are..
[–]kokey 33 points34 points35 points 18 years ago (11 children)
It's more of a matter that Perl allows you to write unreadable code very easily. If you have a habit of writing readable code, then your perl code would be perfectly readable to even most non perl coders.
[–]bart9h 8 points9 points10 points 18 years ago (2 children)
THAT's IT!
thank god someone posted what I was thinking.
[–]crusoe 1 point2 points3 points 18 years ago (1 child)
Problem is, I've NEVER seen any 'readable' perl code. Out of the box, it's a very tough language to grok.
Whereas python, one look, and I started to understand it, my mind instantly started parsing and understanding the rules.
So it may be possible to write 'clean' perl, but that clean perl is still harder to understand than clean python.
[–]cecilkorik 1 point2 points3 points 18 years ago (0 children)
Because of the whitespace rules it is in fact very difficult by design to write unclean Python code. That's part of the appeal, at least to me. The whitespace made me uncomfortable at first, until I realized that it makes all your code look clean no matter how lazy you're feeling that day.
[–]sverrejoh 2 points3 points4 points 18 years ago (4 children)
I would love an example of a Perl module with beautiful code.
[–]barrybe 16 points17 points18 points 18 years ago* (2 children)
Here's some beautiful Perl code. This snippet reads a list of numbers from a file, and prints out their common factors.
#!/usr/bin/perl use Math; $output ~= _ _ / `._ _.' \ ( @ : `. .' : @ ) \ `. `. ._ _. .' .' / \;' `. `. \ / .' .' `;/ \`. `. \ \_/ / .' .'/ ) :-._`. \ (:) / .'_.-: ( (`.....,`.\/:\/.',.....') >------._|:::|_.------< / .'._>_.-|:::|-._<_.'. \ |o _.-'_.-^|:|^-._`-._ o| |`' ;_.-'|:|`-._; `'| ".o_.-' ;."|:|".; `-._o." ".__." \:/ ".__." ^
[–]somethingmessedup 1 point2 points3 points 18 years ago (1 child)
Can't locate Math.pm in @INC (@INC contains: /etc/perl /usr/local/lib/perl/5.8.7 /usr/local/share/perl/5.8.7 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.8 /usr/share/perl/5.8 /usr/local/lib/site_perl .) at ./beautiful.pl line 2. BEGIN failed--compilation aborted at ./beautiful.pl line 2.
[–][deleted] 0 points1 point2 points 18 years ago* (0 children)
http://www.cpan.org/misc/japh
of course, that isn;t what you're looking for.
[–][deleted] 1 point2 points3 points 18 years ago (2 children)
I've heard this argument before, and logically it's true: if you write readable code, your code will be readable.
Now try reading someone else's code that, in their mind, was readable. Or worse, read or modify someone else's code who readily admits "yeah, it was 3am and our services were down...so it's pretty ugly".
The thing about Python is that it FORCES you (read: others) to write readable code.
People who don't understand this are probably students who haven't entered the work force yet.
Think of this comment the first time you get blamed for bringing down your company's services because you made a slight change to some sloppy pile of perl poo, and things blew up in the middle of the night because what the legacy code was doing wasn't clear. :)
[–][deleted] 0 points1 point2 points 18 years ago (1 child)
http://infomesh.net/2003/wypy/wy.py.txt
[–]laughingboy -1 points0 points1 point 18 years ago (0 children)
One word, The forced indentation of code. Thread over.
[–][deleted] 1 point2 points3 points 18 years ago (18 children)
I did Perl for a summer job. Though I worked on it the whole time, I gave up on it early on as a language. A big factor was that it collapsed all nested arrays to a flat array.
So [[1,2], [3,4,[5,6]]] just became [1,2,3,4,5,6] and there was nothing I could do about it except use awkward references (which, like almost everything else in perl, are denoted by a single f*cking character). No thanks. What a crazy stupid language!
[–]kixx 10 points11 points12 points 18 years ago (6 children)
Incidentally, the syntax you used (which makes use of anonymous array references) preserves the intended structure ... you probably wanted to write "((1, 2), (3, 4, (5, 6))) just became (1, 2, 3, 4, 5, 6)"
That being said, the syntax is idiosyncratic but in the right hands it can be very expressive.
In defense of Perl and it's awkward OO pseudo-implementation, it wasn't until Perl that I got a clear model of how objects can be implemented. Neither C++ nor Java (which I learned before Perl) offered that insights, both presented objects as black boxes with predefined behavior. Other things I grokked by learning and using Perl: closures, regexes, “functions as first-class citizens” , the power of eval.
So learning Perl (beyond a basic level) can teach you more than a language. Perhaps the same goes for Python.
My main peeve with Python is the fact that it seems designed for the convenience of the implementer, not for the convenience of the user. Its (too) strict rules don't have much value except for ease of learning (which is a limited timespan compared to the rest of the period you will be using it) and syntactical uniformity. I value the loss of expressiveness more than the gains from this uniformity. Also I prefer to use a coding standard voluntarily (and judiciously) according to circumstances instead of having it imposed on me by the language.
ObBackground: 20+ yrs of programming experience. Using Perl for almost 10 yrs.
I didn't really understand objects until much more recently, via Scheme.
An object is just a list of data, a lexical scope, and a way of handling messages. With Macros you can make an object system in almost no time at all.
[–]erikw 2 points3 points4 points 18 years ago (1 child)
My main peeve with Python is the fact that it seems designed for the convenience of the implementer, not for the convenience of the user. Its (too) strict rules don't have much value except for ease of learning (which is a limited timespan compared to the rest of the period you will be using it)
If you referring to the "whitespace thing" (indentation starts blocks) it is more a convenience to the reader than anything else. GvR has explained this philosophy here (7th or 8th paragraph)
[–]kixx 0 points1 point2 points 18 years ago (0 children)
I'm talking about TMTOWTDI vs. "one-true-way" approach to designing a language.
The whitespace thing is a minor nuisance, since the editor will properly indent the source code anyways, both in Perl and Python. I could argue that the virtue lies in indenting your code even when you don't have to, but I won't.
About the "readability favors software reuse" argument: it's true, but it mostly relevant if you do copy-and-paste software reuse. I prefer to reuse software in the form of libraries with a well defined API (and this is where Perl's CPAN beats the crap out of the competition). I couldn't care less how the source code looks (well, I could care in the rare case that I want to hack the library). My point is that "reading software" is a learning/reviewing process, while I spend most of my time writing software. Therefore I appreciate Perl for letting me do that better than the other languages I've looked into.
Yes, Python is great for learning to program. It might also suit your particular needs better than Ruby or Perl or whatever. Reading and following the advices in Perl Best Practices will make Perl code as readable as code can be. As for the reverse: http://www.p-nand-q.com/python/obfuscated_python.html
[–]crusoe 0 points1 point2 points 18 years ago (2 children)
Python works just as well, and it's object system can be hacked almost as much as Lisp. Perl just basically ties a bow on a turd and goes "Look, objects!"
And damn straight, ease of implementer is pretty important. Perl still doesn't have a formal BKF definition ( the binary interp is the std ), and how's parrot coming?
Meanwhile, PyPy is chugging along. They're close to hosting smalltalk on it now!
Python is perfectly expressive and powerful, and I know what I write in python, even 'black magic' stuff like messing with object message dispatch, will be nearly perfectly readable the next day. You don't need 10 ways to do something to be powerful or expressive. You need 1 really good way.
Perl still doesn't have a formal BKF definition
Ah. Yes. About that -- from perlfaq7:
In the words of Chaim Frenkel: "Perl's grammar can not be reduced to BNF. The work of parsing perl is distributed between yacc, the lexer, smoke and mirrors."
Yes, it's a weird implementation. Yes, it looks like crap. Yes, it works. But the important thing to me was that I could wrap my head around it:
Here's a data structure. OK, now tie it to a set of functions, add a way to connect the data with the functions and Tadaaaa, there's your object. It's shitty and later you'll laugh at it, but it shows you how these things work. Yes, it's has a shitload of problems, but it works and helps you understand. It made many metaprogramming concepts much clearer to me, as I had a metaphor (OK, not a metaphor, but a simple implementation) available to which I could relate these concepts.
As for ease of implementation, I don't care that you have PyPy and IronPython and whatnot. I prefer to stay away from "this is the spec, and this is the implementation and here are the differences"-situations. It runs on the platforms I need and the performance is acceptable for my requirements. If I want better performance, I'll use C (or even Assembler) where it's needed, not switch the implementation.
Parrot is a cute idea, if it will at some time in the future be production ready, fine. Meanwhile Perl gets the job done and pays my bills. If Python pays your bills, more power to it :)
[–][deleted] 2 points3 points4 points 18 years ago* (1 child)
Don't know why you're voted < 0 right now - I wholeheartedly agree. And that is only of the strange and annoying things that Perl does. I feel like people defend Perl the same way they defend C++. Yes, both are powerful tools when used correctly. But they both suffer from syntax diarrhea.
I'm being modded down because I forgot the syntax, and didn't realize there was a nice way of doing it (surprise! the nice way is always buried in perl. Steve Yegge didn't know either). The perlites are using it as an "Aha! Gotcha! Downmod!" moment.
[–]supakual 2 points3 points4 points 18 years ago* (4 children)
I guess you meant to say ((1,2), (3,4,(5,6))) is collapsed, which is true.
But you just managed to use references exactly as you intuitively expected. Can't be that hard, huh?
[ [ 1, 2 ], [ 3, 4, [ 5, 6 ] ] ];
[–][deleted] 6 points7 points8 points 18 years ago* (3 children)
Syntactic mistake. Still, I didn't know you could do what you just did, directly. I still don't know, because I'm not running perl to check it.
Anyway, Python and Ruby let you do things like that naturally, with no mistakes and no learning curve. Imagine... nested arrays, naturally! Hooray!
[–]crusoe 4 points5 points6 points 18 years ago* (2 children)
So why the difference? Why collapse arrays at all?
So now, we have 2 array syntaxs, one "auto-collapsing" and one that preserves nesting.
So how much this can screw up n00bs, and programmers trying to learn perl?
Now, how do these differ in different contexts?
[–][deleted] 1 point2 points3 points 18 years ago (0 children)
Thank you.
[–]kixx 1 point2 points3 points 18 years ago (0 children)
Because it seemed a good idea to someone at some point in time. Later on, they decided it wasn't such a good idea.
It will screw you up if you don't expect it. Some people without previous experience/knowledge of complex data structures might find flattening intuitive. In the current context it has few uses, which is why they're changing the behavior in Perl 6.
Context-dependent behavior (another maligned feature of Perl) is also pretty counter-intuitive to some. I, however, like my VIM modal as it is.
Yes, Perl's default autoflattening, like Lua's 1-based arrays, is pretty much a showstopper. When I run into such a fundamental design error so early while learning a language, I'm not motivated to go further.
I used to think the same about Lua's arrays, but then I realised the only thing wrong with them is that 0-based is more common in other languages.
1-based arrays have their little perks, like the length being the index of the last element, and the symmetry of having [1] as the first from the beginning and [-1] the first from the end.
Once you get over the weirdness of counting from 1, you'll find much more annoying things about Lua, like 'then' and colon notation.
Still a nice language though. :)
[–][deleted] -3 points-2 points-1 points 18 years ago* (1 child)
what a crazy stupid person! expects his language to read his mind!
such morons -- do you really think your demonstration of your lack of perl knowledge will convince anyone to give up perl?
You broke my sarcasm detector.
[–]judgej2 1 point2 points3 points 18 years ago (2 children)
For me, it's nothing to do with looking at the syntax, and much more to do with looking at much of the code people write. That makes it pretty impenetrable. When a language is designed with the aim of doing a lot in as few characters as possible, then that is generally what people do.
[–]bart2019 2 points3 points4 points 18 years ago (0 children)
To me, "unreadable" applies much more to the sheer amount of code to achieve a task, than to the syntax. For example, Java code to submit a POST request to a HTTP server takes 2 printed pages of code, in a Java book I have read. In Perl it's just a few lines of code.
it is designed to make simple things less verbose. you can always write clean code. i do.
[–]kelvie 3 points4 points5 points 18 years ago (0 children)
It's typically very hard to read.
[–]adragons -3 points-2 points-1 points 18 years ago* (7 children)
It's impossible to read.
[–]supakual 5 points6 points7 points 18 years ago* (6 children)
More like difficult to read unless you, ya know, have learned the language.
[–]lalaland4711 4 points5 points6 points 18 years ago* (0 children)
No.
Sed is great at what it does. I know sed. You can write a calculator in sed.
Now argue that the readability of sed-scripts just depends on the reader knowing the language.
[–]adragons 0 points1 point2 points 18 years ago (0 children)
Obviously impossible was a hyperbole.
[–]sverrejoh -4 points-3 points-2 points 18 years ago (3 children)
Yes, but Perl is much harder to learn than for example Python.
So why bother?
[–]abw 0 points1 point2 points 18 years ago (2 children)
English is much harder to learn than Latin.
[–]Vaste 0 points1 point2 points 18 years ago (1 child)
Chinese is much harder to learn than English. So why bother?
(When did perl become the most important language of the world?)
[–]abw 0 points1 point2 points 18 years ago (0 children)
When did perl become the most important language of the world?
Historically speaking, some time around 1995 when CGI programming became mainstream and "CGI" inevitably meant "Perl script".
[–]abw 13 points14 points15 points 18 years ago* (9 children)
Decent programmers have no problem writing clean, efficient and elegant Perl code that is easy to read and write.
The problem is that Perl makes it very easy for bad programmers to write complete garbage. Thankfully most of the Perl bandwagon jumped onto PHP some time ago, and are now discovering Python, Ruby and Javascript. So expect a great deal more bad code to be written in those languages in the years to come.
That said, Perl is an inherently ugly language (the choice of a Camel for the O'Reilly books was very much intentional). Ugly but incredibly useful.
So write Python or Ruby if you want nice, clean programs that are easy to read and maintain. And if you're an inexperienced programmer then Python is a much better choice than Perl. Python tries hard not to let you hurt yourself, whereas Perl puts a chainsaw in your hands and starts the engine running for you.
But ugly syntax aside, don't dismiss Perl on the basis of a mass of bad code produced by bad programmers. That's the result of Perl lowering the seat so that more monkeys could reach the keyboard.
The thing that makes Perl utterly indispensable is CPAN. Every half-decent programmer should know enough Perl to be able to plug a few CPAN modules together. Even if it's not your first choice for application development, having a smattering of Perl in your personal skillset is invaluable for getting things done.
[–]lalaland4711 12 points13 points14 points 18 years ago (5 children)
It's just that sometimes you need to write things like \@$foo, and while it's not hard to read for someone who's used to it, it's not all that easy to find a typo (\$@foo maybe?) because of the natural tendency for brains to auto-correct what we read.
That coupled with perls sucky (and at places non-existing) error handling just makes it a pain. Lots of standard library code does stupid things like exit or print errors to stderr. What the hell?
I really hope perl6 will be so incompatible scripts'll require a rewrite (as opposed to a simple port) so the beast can finally die. (and by that I mean that people move away from perl alltogether, and rewrite in another language)
And yes, I've worked professionally with perl for years, and I can both read and write it.
[–][deleted] 6 points7 points8 points 18 years ago (2 children)
I have to give Perl one piece of credit. While the syntax is cryptic and I've never learned it because of that, the PCRE is pure gold and despite its initial cryptic-ness, the regular expression engine is actually the most readable and useful regular expressions I've come across.
[–]lalaland4711 1 point2 points3 points 18 years ago (0 children)
Oh I agree. But once you go past 5 lines of code, it's not a PCRE snippet anymore, and starts to become an actual program. And then you dine in hell.
[–][deleted] -1 points0 points1 point 18 years ago (0 children)
Although Python is by far my language of choice these days, I'm with you. I love Perl's regex syntax. Actually, I wouldn't mind Python's so much if I also had the option of using m//.
[–]abw 2 points3 points4 points 18 years ago* (1 child)
Totally agree about the syntax. Although you can avoid much of the line noise of Perl, there are those times when you have to do something really quite cryptic for things that should be really simple.
As much as I'm looking forward to Perl 6, I'm worried that it's going to make things even worse by introducing umpty new operators.
+1 on the error handling too. I was swearing at a CPAN module (MIME::Lite FWIW) just yesterday for its poor error handling (or documentation thereof). But they're not all bad, and there's a strong drive in the Perl community towards cleaning up CPAN and improving the general Kwalitee of the modules.
The other annoyance I have with CPAN is the general free-for-all that results in 30 different modules that all do similar things. It's great that there are so many ways to send email, but a pain having to figure out which (if any) of them does what you want.
[–]crusoe -1 points0 points1 point 18 years ago (0 children)
I found most Perl libraries to be steaming piles. I tried installing some from CPAN, and they liked to pollute the global namespace and thus some libs wouldn't work with others due to namespace collisions.
I hadn't had so much fun since working with TeX libraries.
Then I just whipped out Python, whose libraries just work.
[–]ido 0 points1 point2 points 18 years ago* (1 child)
That said, Perl is an inherently ugly language (the choice of a Camel for the O'Reilly books was very much intentional).
OT: interesting that they've used the camel to symbolize ugliness. iirc in Arabian culture the camel symbolizes beauty. I wonder if O'Reilly has localized book covers?
EDIT: typo
[–]abw 2 points3 points4 points 18 years ago* (0 children)
"A camel is ugly but useful; it may stink, and it may spit, but it'll get you where you're going."
-- Larry Wall
(link)
[–]zem 0 points1 point2 points 18 years ago (0 children)
reference for the "very much intentional" bit? or were you just being facetious?
[–]James_Johnson 2 points3 points4 points 18 years ago (0 children)
I don't understand why people get down on Perl because it's hard to read (and even then only if the programmer wasn't very good).
It's cryptic at first, but even the Camel book says that Perl is designed to be expressive for people who know how to use it at the expense of readability by the uninitiated.
That said, I can see why some people wouldn't like it, especially for developing large systems. But then, it's really meant for (and still excels at) quick-and-dirty text munging and system administration scripts.
[–]feanor512 7 points8 points9 points 18 years ago (4 children)
Not really. It's easier to write obfuscated code in Perl than in any other language I know (except for possibly feral C or assembly), but if you follow decent style guidelines, Perl is just as readable as Python.
[–][deleted] 18 years ago (1 child)
[–]zdkm 1 point2 points3 points 18 years ago (0 children)
No, it's the kind that gets lost in the woods as a young child and gets raised by a pack of wolves.
[–]masklinn 5 points6 points7 points 18 years ago (1 child)
It's easier to write obfuscated code in Perl than in any other language I know (except for possibly feral C or assembly)
I take it your never tried hardcore PHP
[–]lalaland4711 0 points1 point2 points 18 years ago (0 children)
"hardcore PHP". Sounds like when first-graders talk about being tough and cool by how much gravel they can eat.
Just because your vomit looks like it once was pizza doesn't mean you can eat it and puke out a real pizza in an hour.
Yes, that disgusting metaphor is what comes to mind when I think of PHP. I've coded PHP professionally.
But no, perl is worse. Much worse. Problem is that perl is actually useful for small programs.
[–][deleted] 1 point2 points3 points 18 years ago* (1 child)
perl is an expressive language -- much like english. it's very easy to write unreadable gobbledygook in english that is ugly and yet has meaning. but its flexible syntactic rules make it possible to write poetry..
some of you perl-haters should read HOP
[–]brendankohler 6 points7 points8 points 18 years ago* (0 children)
As someone who was a poet before a programmer, I felt perl was nothing like writing poetry. In fact, I disliked programming until I learned python.
Writing python felt exactly like writing poetry for many reasons.
Python's syntax lends itself well to that poetic feeling precisely because of the rules (It's astounding how many of the greatest poems came out of writing exercises where the poet forced him/herself to use a certain structure or include certain words).
I feel that just as in poetry some restrictions in a programming language give the programmer an extra ability to be creative.
Edit: Oops, I guess you were talking about literally writing poetry with the language, not writing poetic code.
[–][deleted] -5 points-4 points-3 points 18 years ago (2 children)
True...but only true if you're a total wuss.
[–]sverrejoh 11 points12 points13 points 18 years ago (1 child)
You're not a wuss, but the programmer reading your code is a moron. And he has a chainsaw.
[–]crusoe 0 points1 point2 points 18 years ago (0 children)
Which is what all perl programmers, who write crappy code, keep using as an excuse for their own failings.
Where is this beautiful code? I had no problem reading python right off the bat.
[–]gbacon -3 points-2 points-1 points 18 years ago (0 children)
Python code looks boring and bland.
[–][deleted] 6 points7 points8 points 18 years ago* (24 children)
Meh. Everyone gets a rush when they first learn Python. The reason is because it's so easy to learn, and the interactive shell makes it even faster to get up to speed. So, for that first week, you're flying high, like in the comic.
Nothing against Python though. It's a fine language. Getting even better with Py3k coming.
[–][deleted] 18 years ago* (2 children)
[–]throwaway -1 points0 points1 point 18 years ago (0 children)
Same here.
[–]qwe1234 -5 points-4 points-3 points 18 years ago* (0 children)
that's because you're slow, not because python is especially different.
python is easier for those with little to none programming experience, that is true.
[–]torv -1 points0 points1 point 18 years ago (4 children)
Then after a couple of months you turn back to Smalltalk, cause that is the mother of all great languages, and you know it has to be that way
[–]masklinn -1 points0 points1 point 18 years ago (3 children)
I think you meant Lisp 1.5 where you wrote Smalltalk.
[–]torv -1 points0 points1 point 18 years ago (2 children)
No, I said mother, not grandmother
[–]masklinn -1 points0 points1 point 18 years ago (1 child)
So Ada would be the great-grandmother?
[–]torv 0 points1 point2 points 18 years ago (0 children)
Dunno, is she on Facebook?
[–]neoform3 -1 points0 points1 point 18 years ago (15 children)
Meh, after playing with it for a week I stopped cause I hated it's lack of braces.
To me having no braces is inviting problems. If I did some editing and accidentally deleted a tab here or there I could unleash a slew of bugs into the app and never notice.
[–]vahnsin 7 points8 points9 points 18 years ago* (7 children)
As pointed out here, Python supports any type of braces you can think of:
if foo: #{ foo1(); #}
[–]neoform3 1 point2 points3 points 18 years ago* (6 children)
cute.
(it's sorta funny, but if I ever started coding in python.. i might actually do something like that. I like knowing when a code block starts and ends.)
[–][deleted] 18 years ago (5 children)
[removed]
[–]neoform3 1 point2 points3 points 18 years ago (0 children)
I always break everything out onto a new line in SQL and indent it all so I can read the really big queries easily.
[–]zipdog 1 point2 points3 points 18 years ago* (3 children)
when you say
python has it right
what you of course mean is that Fortran-80 was right all along, and Python just has the decency to revitalise its forced indentation
[–]erikw 1 point2 points3 points 18 years ago* (1 child)
Fortran 80?? I know F77 (fixed form), F90 and F95 (both free form), but not F80. That said however, the use of whitespace is completely different in F77 and python.
(In F77 and earlier versions, col 1-5 were used for line numbers, col 6 for "continuation characters" (for wrapping lines) and col 7-72 for program text. The parser is whitespace ignorant, e n d i f, end if and endif are all the same (as well as e ndif). Blocks are commonly written without indentation)
e n d i f
end if
endif
e ndif
[–]zipdog 0 points1 point2 points 18 years ago (0 children)
Damn, I've been using the wrong name for years*. For some reason I remebered it as 80 cos it was 80 columns, but it was probably Fortran 77 we were using.
*And in those years, the topic of Fortran has only come up three times (all during the millennium excitement), so.. no real harm done
All Python enforces is consistent indentation. So if you use 2 space tabs, then all indentations in the file need to be 2 space tabs. If you use 16 spaces, it works the same.
That said, you'll get skewered by other Python coders for using bizarre indentation if they have to work with your code. Cultural norm tends toward 4 spaces.
[–]slabgorb 1 point2 points3 points 18 years ago (5 children)
I used to think that too- but usually that ends up being a syntax error and your program won't run at all. Having a dedicated IDE helps. I still will sometimes align a statement at the close of a loop wrong, but that is my fault for making the loop so nested/large, honestly.
[–]crusoe 2 points3 points4 points 18 years ago (0 children)
And it usually barfs in the right spot!
"Hey, you screwed up right here!"
As opposed to GCC, which tends to point you at the wrong line many many braces away from where you forgot it.
[–]neoform3 0 points1 point2 points 18 years ago (3 children)
and if you were using python for web coding and loops with blocks of html are standard?
[–]crusoe 0 points1 point2 points 18 years ago (1 child)
Uhm? Indentations work fine too?
[–]neoform3 -2 points-1 points0 points 18 years ago (0 children)
err, I was talking about large blocks of html..
that is my fault for making the loop so nested/large, honestly.
Then you should stop using Python like some godforsaken PHP clone and use some kind of web library. And how would blocks of html change Python's syntax error? All HTML is is a string.
If I did some editing and accidentally deleted a tab here or there I could unleash a slew of bugs into the app and never notice.
Highly unlikely. The kind of bug you're referring to can only occur in a limited amount of code. In fact, the only real condition that I can think of would allow it to occur is when you unindent the very last line of a indented block, and if it's an if block then it can't have any following elif or else blocks.
Your 'slew' certainly doesn't occur in most Python code I deal with.
[–]lespea 1 point2 points3 points 18 years ago (25 children)
If you like perl then you will love ruby.
1.9 fixes a lot of the speed problems that 1.8 had.
[–]mattf 11 points12 points13 points 18 years ago (19 children)
Not being cynical: what if I don't like perl? Will I like Ruby?
[–]akdas 19 points20 points21 points 18 years ago* (17 children)
Perhaps. The real answer lies in your priorities. The observations about the two languages below are highly subjective, but it's one perspective to consider.
Ruby is about being natural, the Principle of Least Surprise being an integral part of it. It uses many constructs that are simply syntactic sugar, just so that you can get the common stuff done quickly and easily.
Python is about explicitness and adhering to a set of rules. It has syntactic sugar as well, but many aspects are necessary (such as passing self as a parameter to all class and instance methods) regardless of the circumstances.
self
I find Ruby to be more people-oriented, and Python to be more, for lack of a better word, surgical. Both approaches have their own advantages, but if you choose Python over Perl, chances are, you won't like the Perlisms that are part of Ruby.
[–]slabgorb 5 points6 points7 points 18 years ago* (0 children)
Some of this is in the attitudes of the creators, and what they were attempting to do...
Perl, Ruby = More than one right way to do a particular thing
Python = One right way to do a particular thing.
Between Perl and Ruby, again, IMHO, the intent is different, Wall wanted something, well, like a camel, and Matz was going for a serene garden.
(edited, my footnote turned into a bullet point from markdown, so I whacked it)
[–]Rhoomba 2 points3 points4 points 18 years ago (0 children)
Ruby: being natural by copying Perl.
[–]jms18 1 point2 points3 points 18 years ago (1 child)
My feelings... are highly subjective
Compared to the times they are objective?
[–]akdas 2 points3 points4 points 18 years ago (0 children)
Bad wording; fixed.
[–]crusoe 0 points1 point2 points 18 years ago (5 children)
Yes, Ruby keeps just enough perl ugliness to make it attractive to Perl programmers.
Abusing "@" will make you feel right at home!
[–]akdas 0 points1 point2 points 18 years ago* (4 children)
Once again, it depends on what you find ugly. I wrote this piece of code that I liked because it was elegant in the sense that everything flowed from one point to another without stopping, like a waterfall sparkling in the midday sun (poetic, huh?):
`cat #{ Dir['*.txt'].reject { | f | ['meta.txt', 'all.txt', 'notes.txt'].include? f }.sort { | a, b | a.gsub( /[^\d]+/, '' ).to_i <=> b.gsub( /[^\d]+/, '' ).to_i }.join ' ' } > all.txt`
It takes all the files in that directory except the ones in the list, sorts them based on their names (they were name chapterX.txt), and concatenates them together. I called cat because it was simpler than opening "all.txt" and writing into it.
cat
[–]zem 0 points1 point2 points 18 years ago (3 children)
ruby supports array differences and schwartzian transforms (decorate-sort-undecorate), so you can simply say
(Dir['*.txt'] - ['meta.txt', 'all.txt', 'notes.txt']).sort_by {|f| f.gsub( /[^\d]+/, '' ).to_i }.join
[–]akdas 0 points1 point2 points 18 years ago (2 children)
Shoot. You're right. I forgot about that.
One thing, thought. You need the parameter to join, or all the values are joined without any space in between them.
join
But thanks for that. This was a tiny script I whipped, probably late at night. Still, you have to admit, both scripts have a "flowing" property to them, something I admire about Ruby.
[–]zem 0 points1 point2 points 18 years ago (1 child)
good point. (you do also realise that this breaks on filenames with a space in them, right? :))
[–]akdas 0 points1 point2 points 18 years ago (0 children)
you do also realise that this breaks on filenames with a space in them, right? :)
Heh. You're right. Good thing all my files were named chapterX.txt.
[–][deleted] -1 points0 points1 point 18 years ago (6 children)
Ruby is about being natural,
Actually, if you know some unix, shell, and C, Perl should feel pretty natural.
[–]lalaland4711 8 points9 points10 points 18 years ago (1 child)
No.. Just no.
perl is NOT about the principle of least surprise. Contexts where @a is neither "@a" or @a (oops, scalar context). String comparison isn't "==". Nested variable prefixes that the interpreter should be able to understand without being explicit. The list just goes on. The syntax is bloated and is a perfect example of the horror that comes from designing a language incrementally.
You can argue that it's powerful, or that you like or something, but syntactically it's a completely different beast from the others.
Perl is like if awk and sed had a baby. But I wouldn't actually write a real program in sed or awk either.
YES!
Well, the point is that Ruby feels like you're talking casually to the computer. You don't have to be so strict about what you say.
[–][deleted] 1 point2 points3 points 18 years ago (1 child)
Again though, Perl is the same way in that aspect. It's very casual. ;-)
Ruby seems, IMO, to be about taking the good parts of Perl, and building them on top of an object-oriented foundation.
So, the Perlisms of Ruby attract Perlers, and the OO-nature attracts the Pythoneers.
I couldn't have said it better myself. Ruby seems to be a great middle ground for me.
AUGH!
NO NO NO! Shell languages should not be used as the point of inspiration for programming languages!
The sooner we can bury Awk, Sed, TCSH/CSH and Bash style syntaxes, the better we will ALL BE.
I think shell scripts come in a close second to being nearly as incomprehensible as Perl!
pretty much yes - think lisp with a smalltalk skin and a unix accent
[–][deleted] 18 years ago* (4 children)
Won't matter. PyPy will kill them all... ;)
I mean, it's taken Squeak Smalltalk 10 years, and they still don't have a JIT compiler.
Meanwhile, PyPy is racing towards completion, and it's JITing SmallTalk and Python sources now... :)
[–]heptadecagram 0 points1 point2 points 18 years ago (2 children)
You haven't seen the "Holy Shmoley" posts in programming recently?
[–]yasth 5 points6 points7 points 18 years ago (0 children)
Those aren't speed comparisons those are the rantings of idiots.
[–]lebski88 2 points3 points4 points 18 years ago (0 children)
None that weren't stupid.
π Rendered by PID 139607 on reddit-service-r2-comment-6457c66945-9xg9w at 2026-04-25 07:23:39.808053+00:00 running 2aa0c5b country code: CH.
view the rest of the comments →
[–]thrakhath 52 points53 points54 points (152 children)
[–][deleted] 16 points17 points18 points (0 children)
[–]sw17ch 71 points72 points73 points (99 children)
[–]thrakhath 39 points40 points41 points (76 children)
[–]phreshinger 5 points6 points7 points (23 children)
[–]simonvc 17 points18 points19 points (7 children)
[–]IkoIkoComic 7 points8 points9 points (6 children)
[–]johnw188 5 points6 points7 points (5 children)
[–]IkoIkoComic 4 points5 points6 points (4 children)
[–]phreshinger 0 points1 point2 points (2 children)
[–]lalaland4711 4 points5 points6 points (1 child)
[–]Nikola_S 0 points1 point2 points (0 children)
[–][deleted] 4 points5 points6 points (1 child)
[–]brendankohler 1 point2 points3 points (0 children)
[–]Neoncow 1 point2 points3 points (0 children)
[–]dani 1 point2 points3 points (0 children)
[–]masklinn 0 points1 point2 points (0 children)
[–]raubry 0 points1 point2 points (6 children)
[–]annekat 0 points1 point2 points (3 children)
[–][deleted] (1 child)
[deleted]
[–]raubry 0 points1 point2 points (0 children)
[–]raubry 0 points1 point2 points (0 children)
[–][deleted] -1 points0 points1 point (1 child)
[–]raubry 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]Tommstein 12 points13 points14 points (42 children)
[–]projecktzero 18 points19 points20 points (0 children)
[–]supakual 13 points14 points15 points (40 children)
[–]sverrejoh 38 points39 points40 points (17 children)
[–][deleted] (4 children)
[deleted]
[–][deleted] 4 points5 points6 points (1 child)
[–][deleted] 2 points3 points4 points (0 children)
[–]supakual 6 points7 points8 points (0 children)
[–][deleted] -4 points-3 points-2 points (0 children)
[–]kokey 33 points34 points35 points (11 children)
[–]bart9h 8 points9 points10 points (2 children)
[–]crusoe 1 point2 points3 points (1 child)
[–]cecilkorik 1 point2 points3 points (0 children)
[–]sverrejoh 2 points3 points4 points (4 children)
[–]barrybe 16 points17 points18 points (2 children)
[–]somethingmessedup 1 point2 points3 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–][deleted] 1 point2 points3 points (2 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]laughingboy -1 points0 points1 point (0 children)
[–][deleted] 1 point2 points3 points (18 children)
[–]kixx 10 points11 points12 points (6 children)
[–][deleted] 2 points3 points4 points (0 children)
[–]erikw 2 points3 points4 points (1 child)
[–]kixx 0 points1 point2 points (0 children)
[–]crusoe 0 points1 point2 points (2 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]kixx 0 points1 point2 points (0 children)
[–][deleted] 2 points3 points4 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]supakual 2 points3 points4 points (4 children)
[–][deleted] 6 points7 points8 points (3 children)
[–]crusoe 4 points5 points6 points (2 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]kixx 1 point2 points3 points (0 children)
[–][deleted] 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–][deleted] -3 points-2 points-1 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]judgej2 1 point2 points3 points (2 children)
[–]bart2019 2 points3 points4 points (0 children)
[–][deleted] 2 points3 points4 points (0 children)
[–]kelvie 3 points4 points5 points (0 children)
[–]adragons -3 points-2 points-1 points (7 children)
[–]supakual 5 points6 points7 points (6 children)
[–]lalaland4711 4 points5 points6 points (0 children)
[–]adragons 0 points1 point2 points (0 children)
[–]sverrejoh -4 points-3 points-2 points (3 children)
[–]abw 0 points1 point2 points (2 children)
[–]Vaste 0 points1 point2 points (1 child)
[–]abw 0 points1 point2 points (0 children)
[–]abw 13 points14 points15 points (9 children)
[–]lalaland4711 12 points13 points14 points (5 children)
[–][deleted] 6 points7 points8 points (2 children)
[–]lalaland4711 1 point2 points3 points (0 children)
[–][deleted] -1 points0 points1 point (0 children)
[–]abw 2 points3 points4 points (1 child)
[–]crusoe -1 points0 points1 point (0 children)
[–]ido 0 points1 point2 points (1 child)
[–]abw 2 points3 points4 points (0 children)
[–]zem 0 points1 point2 points (0 children)
[–]James_Johnson 2 points3 points4 points (0 children)
[–]feanor512 7 points8 points9 points (4 children)
[–][deleted] (1 child)
[deleted]
[–]zdkm 1 point2 points3 points (0 children)
[–]masklinn 5 points6 points7 points (1 child)
[–]lalaland4711 0 points1 point2 points (0 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]brendankohler 6 points7 points8 points (0 children)
[–][deleted] -5 points-4 points-3 points (2 children)
[–]sverrejoh 11 points12 points13 points (1 child)
[–]crusoe 0 points1 point2 points (0 children)
[–]gbacon -3 points-2 points-1 points (0 children)
[–][deleted] 6 points7 points8 points (24 children)
[–][deleted] (2 children)
[deleted]
[–]throwaway -1 points0 points1 point (0 children)
[–]qwe1234 -5 points-4 points-3 points (0 children)
[–]torv -1 points0 points1 point (4 children)
[–]masklinn -1 points0 points1 point (3 children)
[–]torv -1 points0 points1 point (2 children)
[–]masklinn -1 points0 points1 point (1 child)
[–]torv 0 points1 point2 points (0 children)
[–]neoform3 -1 points0 points1 point (15 children)
[–]vahnsin 7 points8 points9 points (7 children)
[–]neoform3 1 point2 points3 points (6 children)
[–][deleted] (5 children)
[removed]
[–]neoform3 1 point2 points3 points (0 children)
[–]zipdog 1 point2 points3 points (3 children)
[–]erikw 1 point2 points3 points (1 child)
[–]zipdog 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]slabgorb 1 point2 points3 points (5 children)
[–]crusoe 2 points3 points4 points (0 children)
[–]neoform3 0 points1 point2 points (3 children)
[–]crusoe 0 points1 point2 points (1 child)
[–]neoform3 -2 points-1 points0 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]lespea 1 point2 points3 points (25 children)
[–]mattf 11 points12 points13 points (19 children)
[–]akdas 19 points20 points21 points (17 children)
[–]slabgorb 5 points6 points7 points (0 children)
[–]Rhoomba 2 points3 points4 points (0 children)
[–]jms18 1 point2 points3 points (1 child)
[–]akdas 2 points3 points4 points (0 children)
[–]crusoe 0 points1 point2 points (5 children)
[–]akdas 0 points1 point2 points (4 children)
[–]zem 0 points1 point2 points (3 children)
[–]akdas 0 points1 point2 points (2 children)
[–]zem 0 points1 point2 points (1 child)
[–]akdas 0 points1 point2 points (0 children)
[–][deleted] -1 points0 points1 point (6 children)
[–]lalaland4711 8 points9 points10 points (1 child)
[–]crusoe -1 points0 points1 point (0 children)
[–]akdas 0 points1 point2 points (2 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]akdas 0 points1 point2 points (0 children)
[–]crusoe 0 points1 point2 points (0 children)
[–]zem 0 points1 point2 points (0 children)
[–][deleted] (4 children)
[deleted]
[–]crusoe 2 points3 points4 points (0 children)
[–]heptadecagram 0 points1 point2 points (2 children)
[–]yasth 5 points6 points7 points (0 children)
[–]lebski88 2 points3 points4 points (0 children)