- 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
(Appropriately enough, it's at a stack depth of four, as well...)
Admin
Or you could just use a while loop and move the subdirs into the directory to delete. No recursion, no stack.
Admin
Samuel = hire FAIL
Captcha: jumentum (a fast moving Jew)
Admin
Admin
Admin
Seriously now, all the people who mentioned recursion as a solution to this, should be fired on principle.
If you don't expect that your framework provides a simpler way to do such a trivial task and you don't rtfm to find out what that way is, you better stay home tomorrow.
Admin
The real WTF is th ehiring manager. Try and find the retarded cabbage that hired this developer, and get him to explain exactly why he deserves to keep his job having demonstrated that he is utterly incompetent to lead the team.
Oh, wait, that would be the "I hired this guy and call him my best developer, and he's terrible, let's all laugh at him and ignore the fact that I consider him to be a 'strong' developer" guy.
Admin
Of course it would run out of memory, so why are you saying this is the way to go?
If you use the underlying INode, INode Pointing, tree structure of a filesystem to traverse and delete files then you never have to get a folders name, don't have to worry about string memory, you don't have to implement recursion, you don't have to emulate recursion with a stack, your routine will be generalized to any future limit increase on file names or nesting depth, and it won't be exploitable.
I'm going to site a source: http://www.linux-tutorial.info/modules.php?name=MContent&pageid=278
Admin
Admin
Admin
Admin
@GB: Are you suggesting that everyone should avoid using any system interface that involves names of files, just on the off-chance that someone introduces an unlimited-depth file system without also introducing a suitable compatibility layer for the thousands of applications that used the intuitive and reasonable "get file by name" interfaces instead of the arcane and unnecessarily awkward "get file by id" ones?
Admin
As any Freudian will tell you, getting a file via the ego or super-ego is far superior.
According to Wikipedia:
'uncoordinated instinctual trends are the "id"; the organised realistic part of the psyche is the "ego," and the critical and moralising function the "super-ego."'
That sounds remarkably similar to this debate. Nodes are analogous to the id, filenames are analogous to the ego, and WTFers are the super-ego, criticising and moralising away.
Admin
Quoted for hilarity.
Admin
On the bright side, at least it won't enter an infinite loop while processing circular directory references.
Admin
Ah, yes, the ol' manyary (a.k.a. base-many) number systems. My favorite.
Admin
Seriously. Are you implying that calling the shell to execute a command-line has less overhead then a recursive solution?
It never ceases to amaze me how people have no clue whatsoever.
Admin
I think you mean:
Or perhaps even:
I couldn't be bothered looping over every drive...
Admin
Nah, if you don't know recursion and are working as a software developer, you should learn it.
If you don't love software development and learning, you shouldn't be working at it.
Admin
Don't be an anal retentive dork. No one is going to be impressed by you unless you are funny; either brush up on the stand up lines, or learn to be helpful.
You could just say "no dude, the command line program may use a recursive solution itself, and there is overhead in launching the process."
Admin
Oh, it's super important to get inside the box.
Admin
Oh, it's super important to get inside the box.
Admin
No and please paste the section where I suggested that. The only path a user would enter is the top path. To traverse every part of the directory structure below that path you don't need to pass around strings, that's what file handles are for, and I mean file node id's not the file handles your CS101 teacher told you about. fjf is suggesting that the OS be rewritten with entirely ID specified filename without realizing that the file system is already entirely ID driven with a textual representation attached to it. I don't understand how this is hard. No one has ever browsed a directory structure by handle or iterator in their code before?
Admin
Admin
Is that a euphemism for something?
Admin
Admin
Incredibly, four pages of comments in, almost nobody has hit on the only non-WTF solution:
Let the Operating System do it!
Back in the Good Old Days an operating system would do system stuff, like managing the file system, leaving programmers free to do the stuff that interacts with users.
Now we have moronic excuses for operating systems that are all about cartoons and zooming swishy effects and dazzling eye candy and oh yes it still can't properly support two users on the same computer -- or one monitor making use of two computers.
(To those who say a call to the OS is "inefficient" I'd ask where most of your money goes -- to programmer salaries, or to another few nanoseconds of CPU time?)
Admin
Knuth's Lament: http://reprog.wordpress.com/2010/03/03/whatever-happened-to-programming/
Admin
Admin
Admin
Admin
Not everybody knows recursion
Admin
Or he was referring to odor ...
Admin
Archimedes suggested naming large numbers by constructing a series of powers of ten, i.e. 1, 10, 100, 1000, etc. He was just one step away from inventing place notation. He did this in a book in which he discussed what the largest number might be to which one could attach physical meaning. He thought of trying to calculate how many grains of sand it would take to fill the universe. He discussed both the theory that the Earth is the center of the universe and that the Sun is the center. He estimated the universe to have a diameter of 10 billion stadia, or 6 trillion feet. This is, of course, very much smaller than modern estimates, but quite interesting. He ended up estimating that it would take 10^63 grains of sand to fill such a universe.
Whether Archimedes was the "only" Greek-speaking person to have an interest in large numbers is another question. The book I mentioned above is addressed to King Gelon and mentions discussions of large numbers he had with Zeuxippus, which implies there where at least two other Greeks interested in the subject. The Greeks did a lot of work in mathematics, so while it may well be true that the average Greek on the street wasn't interested in the subject, the same could surely be said for the average modern person.
Admin
Hmm, the oldest known languages have had words for "none" or "nothing". What didn't come until much later was the idea of positional notation.
Admin
No no no... you are all wrong. The sequence is one, two, many, one-one, one-two, one-many, two-one, two-two, two-many, many-one, many-two, many-many, one-one-one
It was simple base-3 number system without the 0 so, they had also create new ways to calculate with than number system
CAPTCHA: nulla Funny, I just got null-pointer to
Admin
Hi - I don't understand the premise to this article, since it's hard to find a coding job NOT near a big city.
I'm a competant programmer and currently job hunting, so maybe you could consider me for one of your positions. My email is [email protected]
Admin
HAHA!
Admin
But maybe it's a WTF to use a 6805 in an application where you would even think about using recursion.
Admin
So...
Admin
RecursionJoke() actually made me laugh; RecursionJoke() too; RecursionJoke() not so much.
Admin
Almost any "radio" frequency can be measured by a frequency counter, perhaps with a prescaler (divider) on the input. Methinks they have measured frequency of light by heterodyning in an optically nonlinear medium with something "well known" from a laser/maser perhaps -- this is about as close to a direct measurement as it would get. We're a bunch of orders of magnitude away from having off-the-shelf logic elements that can switch at the frequency of light ;)
As for cell phones and other digital transmitters: the only way to measure them is by using a spectrum analyzer. Those usually use three internal clocks in the heterodyne chain (frequency conversion chain), and those clocks are low enough in frequency (<10GHz) to allow direct measurement with a frequency counter. The "problem" with digital transmission is that it comes in bursts, and that there are multiple channels in simultaneous use. A frequency counter takes averages over relatively long periods of time, so the output from a typical cellphone during talking may measure ridiculously low since the transmitter is off most of the time.
A spectrum analyzer is a rather interesting beast. Here's how they do them.
The input signal gets mixed with 1st LO (1st local oscillator) to upshift the frequency to somewhere above the maximum input frequency. Say a 3GHz analyzer will have a local oscillator that runs at 3.5-6.5GHz. The mixed output is bandpass-filtered to cut down the bandwidth to 100MHz or so. That way a 100MHz frequency window from anywhere between 0-3GHz in the input is moved to 3.5GHz. This output is the 1st IF (intermediate frequency).
The 2nd LO runs around 3.5GHz, and gets mixed with the 1st IF to produce the 2nd IF, usually around 100MHz or so. The output is filtered, again. The 2nd IF can be directly digitized, if a dynamic range of 90dB or so is all you need. There are 16 bit A/D converters that can do 250Msamples/sec, no sweat.
2nd IF can be mixed with the 3rd LO to produce 3rd IF around 10MHz or so. That again can either be directly digitized, or is fed to a power meter with logarithmic output.
All of the local oscillators can be phase-locked together, and since they operate continuously you can calibrate them using a frequency counter.
As for frequency counters you calibrate those with a frequency standard. Such standards use atomic oscillators (rubidium or cesium). Nice thing about atomic oscillators is that their frequency of oscillation can be theoretically calculated. That's the beauty of time-related measurements: time is something that we can measure the best of all things. By "best" I mean several orders of magnitude better than the nearest contender.
That's it, in a nutshell. You can make a reasonably performing spectrum analyzer from scratch -- just google the callsign S53MV. If you have access to a better 1st LO (a YIG -- yttrium iron garnet oscillator), it will perform even better. Or you can buy one on eBay for cheap -- say Tektronix 7L13 will run you about $300 or so, and works from 10kHz to 1.8GHz.
PS. For a while they have also figured out how to link voltage to time -- the Josephson junction is an ideal (literally!) voltage-to-frequency converter. So now we can measure voltage about as well as we do time, with the minor snag being that voltage measurements to accuracy better than 0.1ppm or so are almost useless in "real life" -- it's very, very hard to make an actual circuit that will maintain such accuracy under any realistic conditions. Even measuring voltages to 1ppm is painful: putting the whole apparatus in a box with baffles to mitigate airflow and related temperature drifts, etc. It's a royal pain, IOW.
PPS. F*ck Akismet.
Admin
Thanks for the very comprehensive answer. I was more or less asking a rhetorical question, but I enjoyed your response nonetheless. BTW- Agilent makes a line direct reading frequency counters to 26.5 GHz:
http://www.home.agilent.com/agilent/product.jspx?nid=-33890.536880966.00&cc=US&lc=eng
There are a couple of newer oscilloscopes (I think Lecroy makes one) that can measure well into the GHz as well. Obviously, a scope would not be a very precise time measurement, maybe ~ 0.1%.
But the spectrum analyzer method is far more common. I also suspect Agilent makes use of LOs in a similar way to a spectrum analyzer for that product line--much like a measuring reciever.
Do you work in the Test & Measurement field? I've been working in different aspects of it for over a decade, myself.
Admin
Ok, in four pages of comments nobody's hit on the obvious discussion: this is the quality of developer you will get, if you pay a salary connsumate with the area described here.
I live in an area similar to the one described in this story, but I work in the closest big city (where "closest" > 40 miles away). Why? Whenever I've interviewed at companies in this area, the pay scale is always 30%-50% less than what I'm making, and I make below market for my abilities. Conversely, when I talk to some of the developers in the area it's evident they don't know much beyond VB and Access, because that's the kind of developer you get when you pay what these places pay.
The obvious answer is to allow full or part time telecommuting for developers who live relatively close but in the big city... and pay them what they're worth.
Admin
A scope has no reason to be poor in time measurement, at least a good scope. The trigger is usually detected at the sampling frequency, so will be as accurate as the sampling clock. You can usually lock the sampling clock to an external source. So it can be quite accurate, in fact. Any decent scope these days should be a drop-in replacement for a frequency counter.
You get 0.1% "accuracy" if you try to measure things graphically, and even then a decent scope should let you acquire more than a few kilosamples at once. For a good old CRT scope, 5% overall time accuracy is OK. For a digital scope and when doing things graphically, you should get a few ppm easy, assuming you can store 1M samples at once or thereabouts. For a digital scope when using trigger logic, you should be no worse than a frequency counter. I can get 5 digits frequency out of an old (and I mean old!) LeCroy 9354AL, at say 50ppm or so of accuracy. 0.1% is 1000pm ;)
The "line direct" reading to me means that there is a real digital counter in the unit that can run at 26.5GHz or whatnot. That's of course possible, but not very cheap.
Many digital scopes have analog bandwidths exceeding their sampling frequency, and they can pretend to acquire signals that are faster than the Nyquist frequency. This is fine and dandy when the signals to be measured are well controlled and repetitive. If there's any sort of intermittent glitches going on, you may well never find them, yet they will of course affect your equipment.
Admin
Admin
I'd get in her box.
Admin
I wanted to say this should be using recursion, but I don't want to think how bad THAT code would be.
Admin
Of course, some of this depends on how much value you put on different things. Salary isn't the only criterion used by many people when looking for jobs, and different people place different relative values on the other criteria.
Some people would prefer to save a few hours travelling time each day, and put up with a lower salary because of this.
Also, it does depend on the quality of the job. It can be much better working for a lower salary where you are treated well, than for a higher salary where you are treated like crap.
Admin
But that has nothing to do with actually having the number zero. It's easy to have "nothing" as a concept... largely in the sense that if that's what you have of something then you have no number of them and math is irrelevant. Essentially, "nothing" is just a concept to that sort of mathematically system (like infinity), its not actually a number, but a point where your math ceases to exist. This is why zero is not in the set of what we call Natural numbers.