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: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:No it is a combo of 2 factors (Score 1) 351

Precisely. The study asked a question that results in an expected answer 80% of the time. So why would such a study be conducted in the first place?

Well, duh, they did it to verify that the people did give the "expected" answer most of the time. There are lots of scientific studies showing that something the "everyone knows" isn't actually true, so such beliefs are often worth actually testing. In this case, a number for what fraction of the people haven't a clue about DNA is interesting and potentially useful. It does put a lot of other such surveys in an "interesting" light.

Comment Re:I still think Pluto is a planet (Score 1) 170

The most likely result will be that astronomers will eventually reject the term "planet" entirely. Sorta like how, a few centuries back, they rejected the older term "astrology", due to all its baggage and mis-use by pseudo-scientists and charlatans.

You realize that you are implying that the astronomers who voted in the current astronomical definition of planet are all either psuedo-scientists or charlatans?

That raises some very serious thought-provoking questions. IMHO, using only common sense and no optical assistance mechanisms, it looks to me like they are probably pseudo-scientists, and not charlatans.

Well, they apparently spent some time in meetings of an international organization discussing the definition of "planet", when they could have been doing actual scientific work. ;-)

Of course, sometimes terminology is important scientifically, and it's worthwhile spending time to get it right. But they were mocked by other actual astronomers pointing out that any term that includes both Mercury and Jupiter but not some objects with intermediate properties must be an absolutely worthless term for any scientific purposes. So, at least during the time they spent in such discussions of the definition of "planet", they weren't functioning as scientists. But they were pretending that the terminology involved had scientific value, so it probably did qualify for the term "pseudo-science", in at least one of its common meanings.

Comment Re:I still think Pluto is a planet (Score 2) 170

It has not cleared it's orbit of debris and Eris is in the same boat yet LARGER than Pluto.... how is Pluto a planet then?

Neither has Earth; there's a rather large, bright rock visible in our sky about half the time. ;-)

Seriously, though, it's probably just a matter of time before a rock bigger than Earth is discovered out in the Kuiper belt and/or the Oort Cloud, and chances are pretty slim that its orbit will be "cleared" of rubble. This will either put an end to the current (somewhat bogus) definition of "planet", or it will cause the debate over what's a planet and what's not to bumble on indefinitely.

The most likely result will be that astronomers will eventually reject the term "planet" entirely. Sorta like how, a few centuries back, they rejected the older term "astrology", due to all its baggage and mis-use by pseudo-scientists and charlatans.

In any case, the big rocks in the sky don't really care how we classify them. They just go about their orbiting, occasionally bashing into each other (and occasionally us) at widely-spaced intervals.

Comment Re:call me skeptical (Score 2) 360

Is it monthly averages that they average for the year? Is it daily data that is averaged for the whole year?

Are you really not aware that those are the same number?

If so, well it's good that you seem to realize that you truly do not belong in this discussion.

Actually, it's quite common for local weather data to play fast-and-loose with the concept of "average" in ways that produce such anomalous results.

Thus, it's common to record the "average" temperature for a day by averaging the high and low temperature. It should be fairly obvious how this can produce days that are mostly below (or above) average, like when a front moves through and produces a peak high or low that's very different from most of the day. Similarly, I've seen the "average" monthly highs and lows calculated by taking four numbers (the min/max of the daily highs/lows) and doing similarly misleading averaging.

Actually, meteorologists typically record such things on an hourly basis, and do averaging across all of them. You still run into questions like whether the results are means or medians. But it's not unusual for the politically inclined to ignore such data (which is often only available by grovelling through the databases), using an "average" of only a small set of highs and lows.

Yes, these should average out over the long run. But we've seen so much "cherry picking" in this subject area that one should be skeptical of all the data until you've verified that the writers aren't trying to pull a fast one to support their religious/political/economic theories.

Comment Re:Interesting to note... (Score 1) 360

Last winter was the coldest one on record around here, in over 100 years of record keeping... Pipes were freezing everywhere

Well, which was it... "around here", or "everywhere"? You do know there is a difference, right?

You must speak a rather restrictive dialect of English. In my native dialect (US West Coast), the phrase "everywhere around here" is quite normal, and you can figure out its meaning by inserting "that's" in the right place. The first quote above used the two halves of the phrase in a common way, and speakers of such dialects will automatically carry the "around here" over to the second sentence.

So what dialect do you speak, for which this isn't true. Online linguists studying English dialects are curious ...

Slashdot Top Deals

It's a naive, domestic operating system without any breeding, but I think you'll be amused by its presumption.

Working...