- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
It never ceases to amaze me how many people don't know the constructs that are available to them in the programming language and are too lazy to google what they need.
Edit: fist
Admin
Long live Fortran and COBOL
Edit: Finger
Admin
Admin
Yep:
That is the beauty of C++ - you get C's stuff with it. :)ANY performance improvement is a performance improvement. Not to mention the reduction of overall system overhead incurred by starting external processes, etc.
Admin
Admin
Psh. Unix. Whatever, its OK I guess, if you don't have access to an IBM System i. OS/400 FTW.
Admin
As someone who is just learning Python (as in I just found the man pages and am reading the introduction), it's not always obvious what to look for.
Of course, if you have half a brain, you can always enter a couple of combinations of: "How do you <x> in <Language>?" into Google...
Admin
Did you even bother to look at the article?
Admin
scratches head I'm not getting what you're trying to rant about here. He's simply saying that -75mins cannot be converted to a percentage improvement without a total mins...i.e. -75m/80m vs. -75m/2,000,000m so without that reference point he doesnt know how good of an improvment that is...
so what are you arguing about??
Admin
I think the Perl philosophy 'TIMTODI' can leave some bad examples too.....
Admin
I'd prefer '$my_filesize = (stat($file))[7]'
Admin
I must confess that I have written similar code and deployed it in 'production' once. It was because the Perl we had was compiled without large-file support while the Solaris binutils did.
It was supposed to be temporary until we upgraded Perl, but it's still there for all I know.
Admin
I think many programs has a 'man page' for this very purpose. If you're stupid enough not to read it, you better don't start scripting without knowing any possibilities left.
I comes down to know wich path to check first. RTFM, ask a co-worker, read the homepage of the program (maybe updates of the manual), google for specific howto's (and test them first), ask in forums, pray....
Admin
Bleh. That's what happens when you force some guy who does bash to do Perl.
This is common. What bothers me is that everyone seems to say it's the fault of the Unix design, which is not true. It's just to fault of people who don't use it correctly, just like the old Java rants, etc etc etc.
Admin
Python:
os.stat('somefile').st_size
Admin
Oh, I get it, that's what makes perl so 'powerful', it's non-intuitive use of shorthand whenever and wherever possible.
How would one EVER guess that the supplied code solved that problem. Where would you look to find the '-s' operator (or whatever perl twinks call it.)
What the hell is wrong with
$filesize = size_on_disk(filename); or some equally intuitive and easily remembered (or guessed) function name ?
perl sucks - get over it.
Admin
!first
Admin
I couldn't agree more. Perl's shorthands are horribly difficult to understand. I much prefer Ruby short hands. They make so much more sense.
Admin
Yea perl sucks...hence why it is still in use by some of the largest websites (and highly popular to date).
Admin
I hate perl 5 (perl6 may turn out okay) as much as anyone, especially weird stuff like -s.
But.... it is using sed instead of perl's built in regex stuff that is so lame of this code. That and doing in system calls what the language was designed to replace. :)
edit : also, as for the timing - 75 mins is quite a big improvement no matter how long the program takes. I mean no program is going to take 20,000 hours is it? So 75 mins must be quite a chunk of time.
Admin
http://docs.python.org/lib/os-file-dir.html
Admin
Perl has stat, but part of Perl's job is to function as a functional superset of shell scripts, awk, and sed, which is where all the weird filetests come from. In fact, I would never have even considered using a filetest like that, and most Perl scripts don't.
Considering the alternatives (shell scripting, sed, and awk) Perl sucks the least!
Admin
Ha! I want that on a t-shirt - "If you look at the alternatives, I suck the least!" :)
Admin
The best part is if the file size ever takes up less than 8 digits, you'll get characters from the file name in the output. Or if it runs over 8 digits, the file size gets truncated.
The run time of the calling script is nowhere near as offensive as the fact that the pipe doesn't even work.
Admin
You could try looking for the tutorials, then work through some examples, then get used to scanning reference pages on python.org then try to convert some of your old code to python for a bit of a laugh then try a few small projects using python instead of bash or C...
It's a shame that so many people these days confuse "knowing how to find the answer" with "asking google", let alone "asking a BB".
s/python/perl/g s/python/C/g
Admin
Admin
Admin
Was the university so prestigious that they even taught spelling?
pirates of Penzance!
Admin
If that's the only set you consider, then yes. There are (other) scripting languages that don't suck, that aren't cryptic, that don't inherently lend themselves unreadable, unmaintainable code.
Admin
This meme has been around a while. A number of years ago I remember a quote from nugget or jwz or some similar programmer/pundit: "X Window is the second worst windowing system but all the others are tied for first."
Admin
Had something similiar with a C/Java programmer writing some perl to copy a file by reading it into memory and then printing it out to another filehandle.
I was really shocked to read it until I started programming in Java and saw that's the way you do it.
Admin
Admin
Grow up.
Google is still your friend, even if you piss off everyone else.
Admin
Sure, but do they have the advantages perl has? -regular expressions -C-like syntax for easy adoption -large user base -large installed base on random machines
The only one that comes close is Python, which isn't any more maintainable or readable than Perl.
I've been programming in Perl for close to 10 years and I have yet to see code that I can't read except for an obfuscation contest.
Admin
Admin
...Even in the first year of learning?
Admin
I work with people who to this day think the best way to get the system time in perl is:
Admin
I'm not saying this in an attempt to attack or defend Perl...but, just because a lot of big sites use it doesn't necessarily mean it doesn't suck. I'm sure we could all identify heavily deployed applications/operating systems/programming languages that suck in one way or another. For example, I've spent a lot of time with (and enjoy working with) PHP. Everyone knows how badly that sucks (just check out then function names. WTF?!) but there are a large number of big sites that use it....
Admin
As an added bonus, both parameters can be either a filehandle or a path.
Admin
Yes, because copying what BASH HAS ALREADY DONE FOR YEARS is what makes PERL stupid and unreadable.
snicker
Admin
Admin
Admin
Though it's PROBABLY pretty good. I don't think there are many applications where shaving an hour off runtime would be considered insignificant. Especially for a change this small.
Admin
(perldoc, give me info on the functions (-f) of the form -X. actually, you can do -f on any of the things listed here and -X.)
Anyone who's been programming Perl more than two or three weeks should know there's a bunch of file tests like this. Take a look at the Camel book. Or a cheat sheet. Or a tutorial, somewhere, for the love of God! It's not like they're trying to hide these things. DO WE NEED TO SPOON-FEED YOU? TAKE SOME INITIATIVE!!!
Addendum (2007-04-05 10:53): Hey, try PHP! You not only get neat functions like
you get ones like as well!cough cough hack hack
Admin
Because that's how you do it in a shell script, and Perl was designed to appeal to people whose previous experience was mostly shell scripting.
Well, you could always use the stat($filename) function.
Or if you prefer something object oriented, you could look into the File::stat module for an OO interface to the same thing.
Or you could realize that Perl has a number of very serious flaws, chief among them are morons like yourself, Smitty.
Admin
Admin
(this line is a workaround for weird bug where the first line after a quote appears in the quote)
yeah, they should be using 'chomp'!
just kidding. although I've seen this done a lot around here, too. I even do it occasionally if I"m in a hurry and I need to do something in perl that was already done in bash.
am I totally weird for loving perl AND bash? they both have their strong points. I have to say I get all excited when I realize I have a little repetitive job that would be much better as a bash script. sometimes my bash scripts even have perl in them!
Admin
Ack! They're supposed to chomp! ;)
Admin
Well on one hand yes & on the other no. You do not have to read the entire file into memory, just have a little byte[] buffer (4k is more than adequate) in the middle to fire it off to the output stream. Or if you are feeling very lazy then use commons-io's FileUtils.copyFile() method. Thanks to that method (well the IOUtils equivalent) I can copy/move files all over the place in Java just as fast as anything else.
Admin
The supercilious superior tone of many of the comments here really bugs me.
It's not as if we weren't all newbies at one time in our lives. Perhaps some of use learned Perl and C++ at our father's knee but many of use came to these things later along in life.
As I mentioned before in another comment, sometimes, when you're new to a programming language or even a whole new software environment (such as making the transition from a Windows box to Unix, which is a pretty radical jump), sometimes you don't know how to frame the right question because you don't have all of the vocabulary down.
Yes, Google and other search engines make life much easier these days (think of those of us who learned to program with a copy of the FORTRAN Language Manual, a Programmer's Guide, and the IBM System/360 Principles of Operation as our only guides) but Google also produces a lot of noise, chaff, and downright wrong answers, too.