Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!

 



Forgot your password?
typodupeerror
×

Comment Re:What do you expect? (Score 2) 252

Not really. Factorial practically begs for a recursive implementation and it's very simple.

Then there's fibonacci, qsort, etc.

Well, they can be done recursively, but their usual definitions imply the simpler iterative approach. Using them leads to the problem that you often see, not just with young students, but even with experienced "professional" programmers: They learn that recursion is just a complex, obscure way to do iteration.

If you actually want to get across why recursion is important, you really should use examples in which recursion gives a simpler solution than iteration. One of my favorites, partly because people are usually surprised to discover that it's actually best done recursively, is a task that software does a lot: Given a binary number, generate the decimal representation of the number. The natural (iterative) divide by 10 and output the remainder of each step gives the digits in reverse order. This is fine if you're putting the result in a fixed-width field that you know is wide enough, but it's not fine if you're generating ordinary text with just one space before and after the number or if you don't know how many digits the number will have. To generate the number iteratively in the order we usually say or write the digits requires two passes, one to count the digits, and the other to write them. Or you can generate the digits in little-endian order into a large buffer, then use a second iteration through that buffer to output the digits in big-endian order.

But a faster, more elegant way is to write it recursively, with a routine that saves its remainder digit while it passes the quotient to a recursive call of itself. The bottom-level call finds it has a 1-digit number so it doesn't make the recursive call, but simply outputs its digit, and returns to the caller, which writes the 2nd digit, and so on. Students that understand this now know that recursion can sometimes simplify some (but not all) problems.

There are number of other simple problems that are best solved recursively, but this page's margin is to small to hold the list. ;-)

Comment Re:Yes (Score 4, Insightful) 136

Any fucking distro you want. Pretty much every distro does this.

Well, yeah, they mostly come with most of the pieces you want. But this doesn't help. I've found that trying to find where all the pieces are hidden/renamed in any given distro and then trying to figure out how they've tweaked the config stuff is far too time consuming. While someone else is beating their head against their keyboard over all the frustrations, I can beat them out by downloading the latest stable version of apache and each other package I want, and installing them from scratch. The packages in the repositories tend to not change their UI much, only when they have a good reason to do so. Also, they know that their users will be installing from scratch, so they concentrate in making this easy (which includes being mostly consistent with earlier releases, and providing forums that tend to have useful answers to questions).

So my advice is to just scrap the servers and associated packages that come with the distro. Uninstall them if you can discover how to do that in a reasonable time, or just disable them. Copy the config files from another machine that's close to what you want. You'll get it up in much less time than you'd waste trying to figure out how the distro has tweaked everything.

Comment Re:Block Slashdot (Score 1) 176

One of my favorite cases was a brief panic at a financial hub when all email communication regarding canola prices and futures was blocked by the spam filter - canola is more often known as 'rapeseed oil' outside of the US and Canada. The name canola'was only introduced in the 1970s, because a number of Canadian executives found it too uncomfortable to describe themselves as 'in the rape industry.'

Yeah, and that's a good example of an English word that has several different origins, from several different old languages, and the pronunciations has evolved to the same string of phonemes over the centuries. One of the species by that name have the scientific name Brassica rapa, which came from Latin. The closely-related Brassica napus looks similar to non-farmers, and has similar seeds, so most of the population doesn't distinguish them.

You hear cognates of "rape" used in various other European languages for these plants, in languages where the term has no sexual connotations. I've spent some time over the years in Finland, where in the summer you see lots of bright yellow fields of "rapsi" and "rypsi", though for some reason it's the latter that's B. rapa. Finnish speakers know both words, but I get the impression that most of them can't reliably tell you which is which. The growers can, of course.

In English from before the 20th century, you'll also find the plural "rapes" used for clusters of grapes, and sometimes of other fruit that forms in clusters, but I don't think that term is used any more.

Anyway, it's common for language change to produce homonyms like that have problems like this. Eventually, new terms are adopted for one or more of the meanings. One of the funnier examples is the two Old English words usually spelled "queen" and "quean". The former had the same meaning as today; "quean" just meant "woman", with both vowels pronounced as a diphthong. Eventually the /ea/ dipthong and the long /ee/ were both reduced to just /i/, so they became homonyms, and one of them had to be dropped.

Comment Re:Science,much? (Score 1) 33

we can only see 50% of it's surface on any given night

So which nights can we see the other side? Oh, never.

Actually, on any night other than the one precisely a lunar month from the given night, you can see some of that other side (the 50% you can't see tonight). That's what libration does -- expose some of that other 50% that you can't see tonight. Not all of it, sure, but some. You can only see 50% on any given night, but you can see 59% over time. Thus, 18% of tonight's "other side" will be "this side" on some other night.

We could get even pickier, and note that the question was about when we (i.e., all humans) can see (some part of) the other side. At any given instance, the moon is visible from close to 50% of the Earth, and from the moon's viewpoint, our planet is 2 degrees wide. So people along the great circle where the moon is on the horizon can all see about 1 degree to the side of someone standing in the middle of that great circle (perhaps on a boat at sea). If you do a bit of calculating, you'll find that, depending on just how far away the moon is at the time, those people on the Earth's limb (from the moon's viewpoint) can together see about 51% of the moon total. It probably helps if you do this at a new moon, of course, though the reflection off the Earth often helps illuminate the rest of the moon at times..

But the libration is the big part of the over-50% of the moon that we can see over time, since it raises the coverage to around 59%.

I'll leave to someone else the calculation of the effect the moon's not-quite-circular orbit has on these calculations. And I'm sure there are some astronomers lurking about that can give us the numbers to 3 or 4 decimal places. ;-)

(Hmmm ... I wonder if we can find that on wikipedia? ...)

Comment Re:Block Slashdot (Score 1) 176

I have just witnessed Slashdot featuring right on the front page and article about *both* terrorism and child pornography!

Burn the witch!

We might also note that this isn't at all hypothetical. One of the routine problems for organizations for victim support is that their work is frequently blocked by keyword-based software. One of the best-documented histories is the online sites for support of breast-cancer victims. They are repeatedly classified as "porn" sites, and blocked by pretty much any software intended to block porn. Similar problems have appeared for sites that support victims of domestic abuse, because the blocking software classifies them as advocates of the abuse, or sado-masochism sites.

To see a (rather funny) extreme case of this problem, google "Scunthorpe problem". Wikipedia has a good page on the topic, including an impressive list of examples. E.g., has your job title ever included the word "specialist"? If so, your resume may get classified as spam (or porn) by many filters, because it contains the string "cialis".

This really is how many (perhaps most) computerized text-classification schemes work (or fail, if you prefer).

Comment Re:Blocking is counter productive (Score 5, Interesting) 176

Blocking child pornography will mean that the general audience will not be aware of its existence, hence they will not put pressure on politicians to end child abuse. Blocking child porn is counter productive, that's a fact. This I say as one of the founders of www.meldpunt.org and www.inhope.org.

Such nonsense. There are plenty of TV shows and news that discuss child porn (e.g. Law and Order: Special Victims Unit). ...

A lot of people have also noticed the occasional reports of people being arrested for having photos of their newborn child, or for taking photos at a family gathering that included a (nearly-)naked infant wandering by in the background. The idea that there's a "slippery slope" leading to the criminalizing of all infant photos isn't quite correct; we're already at the bottom of that slope. If you're not aware or this, you might consider not taking any pictures whenever there are children in the vicinity (and it's warm enough for them to not be completely covered). Some infants can be pretty good at slipping out of their clothes and running around.

The terrorism part is also widely understood to mean "any activity that the government doesn't like at the moment". In the US, we even have the story of Senator Ted Kennedy being blocked at the airport because his name was on the government's list of terrorist. That one was funny, yes, but it doesn't take a genius to understand what that really means for the rest of us who aren't in powerful government (or industry) positions. Such programs are easily converted into tools that can be used against anyone, as was well illustrated by the victims of the "Red Hunt" back in the 1950s and 1960s.

Comment Re:So if they Ate? (Score 1) 74

...originated as "ingested" bacteria that...

This is probably one of the most exciting, new insights we have achieved in recent decades; but aren't there two equally possible routes for this ingestion? One being that a predatorial cell feeding on these cells at some point stopped completely digesting them, the other being that the mitochondria and chloroplasts were once parasites. I'm not sure which one I think is more likely - perhaps I'd go for the parasite scenario, but it could well be that both routes could have been employed, or that the distinction between predation and parasitism isn't all that clear.

Indeed. And we have lots of examples in the modern world where such mixed symbioses are visible. We're part of a lot of them. Consider that many of our domesticated species are far more "successful" than their wild relatives, but their price for teaming up with the world's top predator (us) is that we eat most of them. We let enough of them survive and reproduce that, biologically speaking, it's worth the price.

I wouldn't be at all surprised if it does turn out that our mitochondria started off as both food and parasites for the amoeba-like critters that eventually "domesticated" them and converted them into internal organs. This seems also seems possible for chloroplasts, who could have started as parasites on the larger cells, then eventually adapted to the "you give me minerals and water and hold me up to the sun and I'll give you sugars" role, and had no good reason to ever leave their hosts again.

But it's possible that we'll never be able to fully sort out how these adaptations happened. There's no natural law saying that they had to leave the evidence behind.

Comment Re: Kind of.. Big dig (Score 1) 481

Good point and I amend my statement to include, "Do NOT use the Big Dig model as your reference or as your influence. Also, don't be cheap, pay for proper studies, vet them, and use good engineers who have done this work before."

As for rail? I can now drive down to Portland and hop a train to Boston to catch a Bruins game. It is, by no means, high speed though. The Big Dig was a horrific project and, yeah, I suppose you may be right in that that's what government projects will result in. We *can* do better though.

Comment Re:Kind of.. (Score 1) 481

California had subways. Their inclusion will be no more catastrophic than without when the big one hits so that is a moot point. Seriously, they had them. I don't recall if it was the automobile companies or the oil companies that bought them and closed them (watched a documentary on it once but it was quite a while ago) but they had them then. That and we've gotten pretty good at making things withstand quite a bit of abuse. They have subways in Japan which is more tectonically active than California. So, yes, put in subways but be smart about it and don't be cheap.

Comment Re:So if they Ate? (Score 4, Informative) 74

It might be pointed out that plants' chloroplasts and our mitochondria are now well-understood to have originated as "ingested" bacteria that, rather than being broken down and digested, ended up first as internal symbionts, and were over time transformed into the cells' internal organs. What these slugs are doing is somewhat similar to this, though on a somewhat smaller scale. The slugs apparently only nab a few chromosomes from the algae, and transfer them into their own digestive-system cells.

But the "first" in the article is a bit different from this: They describe it as the first-known such transfer between two multi-cellular species. Our mitochondria seem to have originated in a single-cell ancestor similar to an amoeba, which incorporated an entire living bacterium as an internal resident. Similarly, plant chloroplasts are believed to have originated as photosynthetic bacteria that were incorporated whole into early algae. In both of these cases, there has been gene transfer from the internal bacteria into the eukaryotic cell's nucleus, leaving the mitochondria and chloroplasts with mostly just the genes needed to do their job, and unable to survive outside their host cell.

But the slugs took a different route, of separating out the photosynthesis genes from their food's cells, moving the DNA into the slugs' cells, and digesting the rest of the algal cells as food.

It could be interesting to stick around and see how this works out. Eventually, they might be able to incorporate the photosynthetic mechanism into their own genome, so that when a slug cell divides, it'll get copies of of these genes and won't have to steal them from algae. Plants never never did this, because they maintained their chloroplasts' ability to divide within the plant cell (with a bit of help from the host cell). The slug's approach might turn out better than the plants'. Or maybe it won't. Or maybe it'll just be two different approaches to photosynthesis that both work well enough.

But we might not know about this for a few more millennia ...

Comment Re:Just learn C and Scala (Score 2) 192

I never got why employers are so obsessed about people having worked in language whatever.

In my experience, this is because "employers" in this context means the people who are either doing the hiring process, or are the top management. That is, they are people who have no concept of what a programming language is. So they make the obvious connection based on the terminology: It's like a (written, probably) human language. This means that it's so complex, inconsistent, and full of special cases that it takes years for anyone to become fluent.

I've experimented in a few interviews, and tried to get across what learning a programming language is really like. One of the example I like to bring up is my introduction to C. I borrowed a colleague's "C bible", took it home for the weekend, and read through it. On Monday morning, I sat down at a terminal at work and tried writing a few programs. One of my self-assigned programs was a functional sort routine, which I had running and correctly sorting some available multi-Mbyte datasets by noon. After lunch, I coded up another half dozen sort routines, wrote an inteface routine that took pointers to a data set and a sort function and churned out the results. I tested all the sort routines on all several dozen available datasets, and printed out the sort speed for each routine on each dataset. (The results of this surprised a lot of people, who knew the usual estimated speeds of sorts on random data, but of course none of our datasets were anywhere close to random. Some were really upset when the winner on several of our - very non-random - datasets was the bubble sort. ;-)

Inevitably, though, the interviewers decided that I was lying. Nobody could learn a language that fast, y'know. They were clearly puzzled about why I would even try to pass off such a blatant lie, when anyone would know it couldn't be possible. My colleagues in the DP department weren't surprised, of course; they'd all done similar things to learn other languages. Sorting is a well-defined subject with lots of well-defined algorithms that they could mostly code up in a few hours, and C is a logical, well-defined language that was (almost;-) completely described in a rather small book. But the HR and manager types that did the hiring all judged the difficulty by imagining how long it would take them to learn to explain a sort algorithm fluently in a strange human language, and by that misunderstanding, I had to be lying, because nobody can learn a language that well in only a weekend.

(Actually, I've only tried this sort of thing after I've already decided I don't want the job. Making them thing you're lying during the interview isn't really a good idea if you want a job. ;-)

Anyway, if you understand this, you understand why employers might not want to hire someone who doesn't know a language. They're thinking of examples like opening a sales organization in Pakistan or Thailand, and what would happen if they hired people who weren't fluent in the local languages to run the sales campaigns. The computer folks' use of the term "language" makes them think that hiring a programmer who doesn't know language X to write software in language X will be that sort of disaster, and they can't wait the years it'd take to develop the sort of fluency they need. There's nothing you can do to teach them about their serious lack of understanding. If you try, you'll just be labelled a liar, so don't bother trying to educate them.

Comment Re:Kind of.. (Score 2) 481

You do know that we have invented machines that dig tunnels at various depths, yes? That is just one solution. That one can be done with little bother to the traffic above even. It CAN be done but will take time and cost money. Those are two things the little people and the politicians hate.

Comment Re:0 hours to 0 hours (Score 1) 244

Pretty much the same here though I don't rent DVDs as I have yet to find anyone renting the material I want to watch. I pretty much only watch educational material and usually in the form of documentaries. The Red Box machine thingy didn't appear to have a single educational DVD in it. It was the same at the (now long closed) rental stores in the area. I do watch, I tend to binge watch, some television that's entertaining but I normally just stick to something that's going to make me a little more in touch with the world around me. I like science and history documentaries best so I frequent YouTube and Netflix. I can't deal with the ads - even with a paid account - from Hulu so I don't give them money any more. I did for two months as I recall and found it worthless.

Businesses

How, and Why, Apple Overtook Microsoft 458

HughPickens.com writes James B. Stewart writes in the NYT that in 1998 Bill Gates said in an interview that he "couldn't imagine a situation in which Apple would ever be bigger and more profitable than Microsoft" but less than two decades later, Apple, with a market capitalization more than double Microsoft's, has won. The most successful companies need a vision, and both Apple and Microsoft have one. But according to Stewart, Apple's vision was more radical and, as it turns out, more farsighted. Where Microsoft foresaw a computer on every person's desk, Apple went a big step further: Its vision was a computer in every pocket. "Apple has been very visionary in creating and expanding significant new consumer electronics categories," says Toni Sacconaghi. "Unique, disruptive innovation is really hard to do. Doing it multiple times, as Apple has, is extremely difficult." According to Jobs' biographer Walter Isaacson, Microsoft seemed to have the better business for a long time. "But in the end, it didn't create products of ethereal beauty. Steve believed you had to control every brush stroke from beginning to end. Not because he was a control freak, but because he had a passion for perfection." Can Apple continue to live by Jobs's disruptive creed now that the company is as successful as Microsoft once was? According to Robert Cihra it was one thing for Apple to cannibalize its iPod or Mac businesses, but quite another to risk its iPhone juggernaut. "The question investors have is, what's the next iPhone? There's no obvious answer. It's almost impossible to think of anything that will create a $140 billion business out of nothing."

Slashdot Top Deals

Real Programmers don't eat quiche. They eat Twinkies and Szechwan food.

Working...