Friday, December 21, 2007
Tuesday, December 18, 2007
Wednesday, November 21, 2007
Drug Dealers vs. Software Developers
| Drug Dealers | Software developers |
| Refer to their clients as "users" | Refer to their clients as "users" |
| "The first one's free!" | "Download a free trial version..." |
| Have important Southeast Asian connections (to help move the stuff) | Have important Southeast Asian connections (to help debug the code) |
| Strange jargon: stick, rock, dime bag | Strange jargon: SCSI, ISDN, VLSI |
| Realize that there's tons of cash in the 14- to 25-year-old market | Realize that there's tons of cash in the 14- to 25-year-old market |
| Job is assisted by the industry's producing newer, more potent mixes | Job is assisted by the industry's producing newer, more faster machines |
| Often seen in the company of pimps and hustlers | Often seen in the company of marketing people and venture capitalists |
| Their product causes unhealthy addictions | DOOM. Quake. SimCity. Duke Nukem 3D. Nuff said |
| well, and you can sleep with sexy movie stars who depend on you | Damn! Damn! DAMN!!! |
| Get caught and spend the rest of your life in a cell. | You anyway are spending your life in a cell! Have fun! |
Monday, November 19, 2007
HELL EXPLAINED BY CHEMISTRY STUDENT
The following is an actual question given on a University of Washington chemistry mid term.
The answer by one student was so "profound" that the professor shared it with colleagues, via the Internet, which is, of course, why we now have the pleasure of enjoying it as well :
Bonus Question: Is Hell exothermic (gives off heat) or endothermic (absorbs heat)?
Most of the students wrote proofs of their beliefs using Boyle's Law (gas cools when it expands and heats when it is compressed) or some variant.
One student, however, wrote the following:
First, we need to know how the mass of Hell is changing in time. So we need to know the rate at which souls are moving into Hell and the rate at which they are leaving. I think that we can safely assume that once a soul gets to Hell, it will not leave. Therefore, no souls are leaving. As for how many souls are entering Hell, let's look at the different religions that exist in the world today.
Most of these religions state that if you are not a member of their religion, you will go to Hell. Since there is more than one of these religions and since people do not belong to more than one religion, we can project that all souls go to Hell. With birth and death rates as they are, we can expect the number of souls in Hell to increase exponentially. Now, we look at the rate of change of the volume in Hell because Boyle's Law states that in order for the temperature and pressure in Hell to stay the same, the volume of Hell has to expand proportionately as souls are added.
This gives two possibilities:
1. If Hell is expanding at a slower rate than the rate at which souls enter Hell, then the temperature and pressure in Hell will increase until all Hell breaks loose.
2. If Hell is expanding at a rate faster than the increase of souls in Hell,then the temperature and pressure will drop until Hell freezes over.
So which is it?
If we accept the postulate given to me by Teresa during my Freshman year that, "It will be a cold day in Hell before I sleep with you," and take into account the fact that I slept with her last night, then number two must be true, and thus I am sure that Hell is exothermic and has already frozen over. The corollary of this theory is that since Hell has frozen over, it follows that it is not accepting any more souls and is therefore, extinct......leaving only Heaven, thereby proving the existence of a divine being which explains why, last night, Teresa kept shouting "Oh my God."
THIS STUDENT RECEIVED AN "A"
Saturday, August 25, 2007
The Gender of My Brain ...
Your Brain is 40% Female, 60% Male |
![]() You have a total boy brain Logical and detailed, you tend to look at the facts And while your emotions do sway you sometimes... You never like to get feelings too involved |
Monday, August 06, 2007
A short history of structured flowcharts (Nassi-Shneiderman Diagrams)
http://www.cs.umd.edu/hcil/members/bshneiderman/nsd/index.html
Ben Shneiderman is a top researcher on software visualization.
He invented things like the tree-map, and of course "the structured flowcharts".
In particular,
http://www.cs.umd.edu/hcil/members/bshneiderman/nsd/rejection_letter.html
I wish every graduate student or young inventor would have the pleasure of seeing his/her ideas spread so far and influence the work of so many people. I also hope that the story of the bold rejection of our novel idea and its eventual international success, is an inspiration for anyone whose new ideas are rejected by some respected authorities.
-- Ben
Wednesday, July 25, 2007
Dearly Departed: Companies and Products That Didn't Deserve to Die
They missed Netscape ...
http://www.cio.com/article
Tuesday, July 24, 2007
Monday, July 23, 2007
PIN number reversal for robbers
My dear friends; I received the message below a few weeks ago. I personally verified this information with the Royal Bank of Commerce where I do my personal banking in Toronto. They informed me that this is both true and accurate. So I am fully convinced that it in your best interest to know this and to pass it along to all your friends. I trust and pray you will never need this information, but if you should ever find yourself in such a situation I pray it will send you angels of protection and assistance. Blessings, David Quackenbush Pass this on to everyone you know and care about.
PIN NUMBER REVERSAL (GOOD TO KNOW) If you should ever be forced by a robber to withdraw money from an ATM machine, you can notify the police by entering your Pin # in reverse. For example if your pin number is 1234 then you would put in 4321. The ATM recognizes that your pin number is backwards from the ATM card you placed in the machine. The machine will still give you the money you requested, but unknown to the robber, the police will be immediately dispatched to help you. This information was recently broadcasted on TV and it states that it is seldom used because people don't know it exists. Please pass this along to everyone possible.
Sunday, July 22, 2007
IMAGINE THE POSSIBILITIES ...
-- http://custom.despair.com/
In particular, all the annotated pictures are worth to take a look: http://custom.despair.com/viewall.html
Saturday, July 21, 2007
Thursday, June 14, 2007
Tuesday, June 12, 2007
Simplicity Sells
Seems like he is a pretty animated guy, but his points are well-delivered.
http://www.ted.com/index.php/talks/view/id/7
Sunday, June 10, 2007
Doing research without precise data
http://www.nytimes.com/2007/06/10/magazine/10wwln-freakonomics-t.html?pagewanted=1&_r=1&adxnnl=0&ref=magazine&adxnnlx=1181498983-M/DfRMQBz0oRr67Plq0QWQ
It shows how people in the social sciences (in this case finance) try to understand a system that they have not control upon. In this case, the real estatemarket.
The Cash-Back Mortgage
Imagine for a moment that you are looking to buy a first home for yourself, your spouse and your 1-year-old darling. Now imagine that you are doing this in Italy.
The housing market in Italy is quite different from ours. It’s harder to get mortgage credit, and you can typically borrow only 50 percent of the purchase price. Moreover, the loan might have to be repaid in just 10 years. So before buying your first house, you’ll probably have to spend a lot of years saving up your salary for a down payment. As a result, you may well end up living with your parents (or — gulp — your in-laws) until you are deep into your 30s.
In the United States, meanwhile, mortgage credit flows like milk and honey. By putting down just a fraction of the purchase price, you can move your family right in, with 30 years to pay off the mortgage.
But what if you can’t scare up the cash for even a small down payment? Without it, you fall firmly into the category of what are now infamously known as subprime borrowers. There are plenty of options for subprime customers, but most of those options, as noted in the small type on the contracts the borrowers sign, aren’t very good.
As is the case with any worthwhile goal, some people employ the most time-honored solution for getting what they don’t quite deserve: they cheat. In some cases, the cheating involves an illegal sleight-of-hand maneuver known as the cash-back transaction. As one of the trickiest forms of mortgage fraud — there are many others — the cash-back transaction is hardly unknown among real estate insiders, but it has largely escaped academic scrutiny. Until now.
Itzhak Ben-David, a Ph.D. candidate in finance at the University of Chicago Graduate School of Business, fell into the subject while pursuing a drier one: the degree to which housing prices efficiently incorporate anticipated tax increases. (Disclosure: one of this column’s authors, Steven Levitt, sits on Ben-David’s dissertation committee.) A 36-year-old Israeli, Ben-David had served for four and a half years in the Israeli Army, studied industrial engineering and accounting and worked at a real estate company in Britain. He thought he knew pretty well how the world operated. But as he immersed himself in Chicago real estate for his dissertation research, he came to wonder how well he and his fellow academics truly understood the market.
For instance, as he interviewed mortgage brokers, real estate agents and bank loan officers, he heard regular mention of a mysterious kind of deal in which the seller gave the buyer a cash rebate without noting this transaction in the mortgage paperwork. (It is illegal for buyers and sellers to transfer cash or assets without properly notifying the lender.) Of course, none of the people that he interviewed copped to this practice. But sometimes the signs of a cash-back transaction were, quite literally, out in the open for all to see, on banners hanging from for-sale properties or in printed real estate ads.
How does this kind of deal work?
Pretend that you want to buy a house that costs $200,000 but don’t have $20,000 to make the 10 percent down payment that would get you a decent mortgage. The seller’s real estate agent offers a solution: let’s make the official purchase price $220,000 instead of $200,000, he says — but in return, the seller will give you $20,000 in cash. This rebate will be a separate transaction, the agent explains, which doesn’t need to be written into the mortgage paperwork. (A seller can legally offer a cash-back incentive, but it would have to be reported to the bank — which would negate the advantage of having the bank think that the buyer already has the cash.)
VoilĂ ! Suddenly you have the $20,000 in cash necessary to get a good mortgage, and the seller still nets his original price of $200,000. The only difference is that the bank records the sale of the house at an inflated $220,000. And, instead of borrowing 90 percent of the value of the house, you have in fact borrowed 100 percent. “In short,” Ben-David writes, “a buyer can purchase the property with no down payment.”
It was all well and good for Ben-David to have learned, anecdotally, how cash-back transactions work — but how could he isolate such behavior in the data? Since the transactions were illegal, they wouldn’t be recorded. So using the data from nearly 300,000 Chicago-area home sales, he began to play detective, seeking out telltale signs of the scam.
First he built a dictionary of 150 keywords in real estate ads — “creative financing,” for instance — that might signal a seller’s willingness to play loose. He then looked for instances in which a house had languished on the market and yet wound up selling at or even above the final asking price. In such cases, he found that buyers typically paid a very small down payment; the smaller the down payment, in fact, the higher the price they paid for the house. What could this mean? Either the most highly leveraged buyers were terrible bargainers — or, as Ben-David concluded, such anomalies indicated the artificial inflation that marked a cash-back deal.
Having isolated the suspicious transactions in the data, Ben-David could now examine the noteworthy traits they shared. He found that a small group of real estate agents were repeatedly involved, in particular when the seller was himself an agent or when there was no second agent in the deal. Ben-David also found that the suspect transactions were more likely to occur when the lending bank, rather than keeping the mortgage, bundled it up with thousands of others and sold them off as mortgage-backed securities. This suggests that the issuing banks treat suspect mortgages with roughly the same care as you might treat a rental car, knowing that you aren’t responsible for its long-term outcome once it is out of your possession.
At first glance, these cash-back transactions, while illegal, might seem a victimless crime. After all, the seller gets his house sold and the buyer gets to move in with his family. The real estate agent, the mortgage broker, the attorney and the appraiser are all paid their commissions or fees. Even the bank that made the loan comes out ahead, since it earned its fees on the transaction before passing along the mortgage to investors.
But Ben-David argues that there are at least two potential losers. The first is the honest buyer who won’t take a cash-back offer and therefore can’t buy a house — all while the illegal cash-back transactions are artificially driving up home prices in his neighborhood.
The second loser is the investor who bought the mortgage-backed securities. If a house purchased with a cash-back transaction goes into foreclosure, it is soon discovered that the home is worth less than the value of the loan. This, plainly, is not good for the shareholders of such assets. While people who hate rich people may get a thrill from the idea of wealthy shareholders being swindled by a bunch of small-time mortgage hustlers, keep in mind that mortgage-backed securities are the sort of conservative investment widely held by pensioners and other regular folks.
There’s a third potential loser as well: the subprime buyer who does accept the cash-back payment but still ends up defaulting on the loan. Although his criminal act will probably never be prosecuted, he stands to face an even harsher sentence: moving back in with the in-laws.
Wednesday, June 06, 2007
Monday, June 04, 2007
"I'm iFedup"
I'm iFedup
LEAH McLAREN
From Saturday's Globe and Mail
June 2, 2007 at 12:00 AM EDT
Here's the awful truth about me: I am a Mac girl.
I live downtown in a North American city in a neighbourhood with Starbucks and sushi joints on every corner. I shop vintage and get premium haircuts. My trainers are old school, my values are new school and my iPod selection is (I like to think) eclectic. I'm not really a car person, but I bought a car – on credit. I eat organic and drink whatever's going. I listen to CBC and watch The Office and develop short-lived obsessions about certain things (pulled pork, for instance, or Japanese toy fish), which may or may not be ironic – I'm not even sure any more. Like I said, I'm a Mac girl.
I say this in the interest of full disclosure. With the exception of a couple of minor technological blips – my mother's hand-me-down Epson in high school and a surprisingly plucky Sony Vaio in London – I have never used any personal home computer that was not a Mac, Apple or “i” something.
And now the world's most trendy pronoun is filling up my life – and the lives of those around me – with “i” everything. There's iKaraoke for parties, iPhoto for family portraits, iWeb for the Internet, iTunes for music, iMovies for entertainment and iPods for light listening. All this comes complete with upgrades from the handy iLife package – mandatory software for any self-respecting hipster. Is that awesome, or what?
Problem is, iOverit. And I'm not the only one.
Last week, an ad appeared on YouTube for the latest “i” product. The iGasm is a handheld vibrator you can sync to an iPod for artfully scored self-abuse. The ingeniously directed 35-second commercial features the typical Mac babe model silhouette dancing and rubbing her crotch in front of the iconic kaleidoscope backdrop. While the product is real (part of an icky trend of iPod-friendly sex toys), the ad is a spoof. And it's about time. Lord knows Apple needs a good hard spoofing. After a year of basking in the glow of its unbelievably smug “Hello, I'm a Mac” campaign, the backlash is finally beginning.
Last week, it was reported that a group of MacBook users in the United States has launched a class-action lawsuit against Apple, alleging that its notebook screens don't work as advertised (i.e. where are the “millions of colours?”). And earlier this month Reuters reported that iPods may cause implantable pacemakers to malfunction by interfering with their delicate electromagnetic equipment. The discovery was made by Jay Thaker, a 17-year-old high-school student who conducted the study at the Thoracic and Cardiovascular Institute at Michigan State University as part of a science project. So much for cornering the gullible youth market.
Unlike Thaker, I feel I have not been sufficiently skeptical where Mac is concerned. Like many young women in my postal district, when my last laptop conked out, I simply wandered, zombie-like, to the nearest Apple store and purchased a new one. I had my reasons. I liked the zippy design and the user-friendliness. Plus I'm too lazy for market research.
But even a slovenly Mac girl like me can reach her breaking point. Where Apple was once the technological underdog, paddling along in the wake of the monolith IBM, today it seems more like a smug slacker twit sneering from the sidelines.
Ironically, it is Apple itself that has promoted this new image with its ad campaign featuring the adorably nerdy PC guy (John Hodgman) in a suit and retro glasses sparring with an irritating Gap-clad alterna-guy (Justin Long). Mac guy, in the words of the Slate ad critic Seth Stevenson, is “just the sort of unshaven, hoodie-wearing, hands-in-pockets hipster we've always imagined when picturing a Mac enthusiast. … It's like Apple parodying its own image while also cementing it.”
And while I'm not one to mix up spokespeople with their TV personas, a personal missive from Justin Long on his website responding to the rumour that he had been cut from the ads confirms the irritating hipster stereotype he projects.
“I don't know where the report came from that said I wasn't going to do any more – I'm literally setting my alarm right now to wake up for a Mac shoot tomorrow … but yeah, we're doing some holiday spots now which I think will be pretty funny – not nearly funny enough to justify the money they're paying me though, I'll be honest with you.” (He later took out the line about how much he was being paid.) These days, when I see a Mac commercial, I find myself identifying with the overloaded, overworked, insecure PC guy. I'm trading in my hoodie for an ill-fitting suit. No more Mac girl – I'd rather geek out.
Monday, May 21, 2007
Wednesday, May 02, 2007
Student Arrested for “Suspected Terrorist Activity”
A Chinese student has been arrested in Texas, charged with “Suspected Terrorist Activity”. This student was apprehended after parents discovered that he had used plans of his High School in the creation of a map for an online first person shooter. The authorities were notified after parents learned of the map from their children, who had downloaded it off of the internet.
.They arrested him,. Chen said of FBISD police, .and also went to the house to search.. The Lin family consented to the search, and a hammer was found in the boy.s room, which he used to fix his bed, because it wasn.t in good shape, Chen said. He indicated police seized the hammer as a potential weapon.
While no charges have been filed against the student, he has been removed from Clements High School and will not be allowed to graduate with his former classmates.
I don’t know what to say. For most of us who have ever designed a 3d environment, using familiar surroundings is very commonplace. With no sinister motive, designers use plans for all sorts of different areas to add variety to their designs. I don’t understand the punishment given to this student, who has been cleared of any premonitions for violence.
He has been convicted of no crime but then the school expels him? I guess “innocent until proven guilty” has no merit with the school board. Even with the authorities finding no evidence of gaming-related causes for the Virginia Tech shootings… It seems that we, as gamers, still are targeted as warped killers.
Monday, March 26, 2007
Crocodiles in denial!
JERUSALEM (AP) - A woman with three crocodiles strapped to her waist was stopped at the Gaza-Egypt border crossing after guards noticed that she looked "strangely fat," officials said Monday.
The woman's shape raised suspicions at the Rafah terminal in southern Gaza, and a body search by a female border guard turned up the animals, each about 50 centimetres long, concealed underneath her loose robe, according to Maria Telleria, spokeswoman for the European observers who run the crossing.
"The woman looked strangely fat. Even though she was veiled and covered, even with so many clothes on there was something strange," Telleria said.
The incident, which took place on Thursday, sparked panic at the crossing.
"The policewoman screamed and ran out of the room, and then women began screaming and panicking when they heard," Telleria said. But when the hysteria died down, she said, "everybody was admiring a woman who is able to tie crocodiles to her body."
In her defence, the woman said she "was asked" to carry the crocodiles, said Wael Dahab, a spokesman for the Palestinian guards at the crossing.
The reptiles, which had their jaws tied shut with string, were returned to the Egyptian side of the border.
Dahab said the animals were likely meant for sale to Gaza's small zoo or to private owners. The crocodiles would fetch "good money," even in the impoverished territory, he said. In Gaza, the animals can fetch about C$580 - roughly two months' salary for a low-ranking policeman.
The woman was not the first to try to smuggle exotic wildlife through the Rafah crossing, Dahab said: Another woman tried to bring in a monkey tied to her chest, and other travellers tried to smuggle in exotic birds and a tiger cub. Border guards more frequently confiscate cigarettes, prescription drugs and car parts.
The crossing is the only way in and out of Gaza for residents of the crowded coastal strip.
Since Israel pulled out of Gaza in 2005, the crossing has been subject to a complex system of control: Egypt and the Palestinians are responsible for the crossing, with European monitors are stationed at the terminal and Israeli inspectors watch from a distance over closed-circuit TV.
Israel retains final say over whether the crossing can open, and has kept it closed over 80 per cent of the time since an Israeli soldier was captured by Hamas-linked militants in Gaza nine months ago, charging that the crossing is being used to smuggle money and weapons to militants.
Thursday, March 22, 2007
Monday, March 19, 2007
"You need the willingness to fail all the time"
John W. Backus, who assembled and led the I.B.M. team that created Fortran, the first widely used programming language, which helped open the door to modern computing, died on Saturday at his home in Ashland, Ore. He was 82.
His daughter Karen Backus announced the death, saying the family did not know the cause, other than age.
Fortran, released in 1957, was “the turning point” in computer software, much as the microprocessor was a giant step forward in hardware, according to J.A.N. Lee, a leading computer historian.
Fortran changed the terms of communication between humans and computers, moving up a level to a language that was more comprehensible by humans. So Fortran, in computing vernacular, is considered the first successful higher-level language.
Mr. Backus and his youthful team, then all in their 20s and 30s, devised a programming language that resembled a combination of English shorthand and algebra. Fortran, short for Formula Translator, was very similar to the algebraic formulas that scientists and engineers used in their daily work. With some training, they were no longer dependent on a programming priesthood to translate their science and engineering problems into a language a computer would understand.
In an interview several years ago, Ken Thompson, who developed the Unix operating system at Bell Labs in 1969, observed that “95 percent of the people who programmed in the early years would never have done it without Fortran.”
He added: “It was a massive step.”
Fortran was also extremely efficient, running as fast as programs painstakingly hand-coded by the programming elite, who worked in arcane machine languages. This was a feat considered impossible before Fortran. It was achieved by the masterful design of the Fortran compiler, a program that captures the human intent of a program and recasts it in a way that a computer can process.
In the Fortran project, Mr. Backus tackled two fundamental problems in computing — how to make programming easier for humans, and how to structure the underlying code to make that possible. Mr. Backus continued to work on those challenges for much of his career, and he encouraged others as well.
“His contribution was immense, and it influenced the work of many, including me,” Frances Allen, a retired research fellow at I.B.M., said yesterday.
Mr. Backus was a bit of a maverick even as a teenager. He grew up in an affluent family in Wilmington, Del., the son of a stockbroker. He had a complicated, difficult relationship with his family, and he was a wayward student.
In a series of interviews in 2000 and 2001 in San Francisco, where he lived at the time, Mr. Backus recalled that his family had sent him to an exclusive private high school, the Hill School in Pennsylvania.
“The delight of that place was all the rules you could break,” he recalled.
After flunking out of the University of Virginia, Mr. Backus was drafted in 1943. But his scores on Army aptitude tests were so high that he was dispatched on government-financed programs to three universities, with his studies ranging from engineering to medicine.
After the war, Mr. Backus found his footing as a student at Columbia University and pursued an interest in mathematics, receiving his master’s degree in 1950. Shortly before he graduated, Mr. Backus wandered by the I.B.M. headquarters on Madison Avenue in New York, where one of its room-size electronic calculators was on display.
When a tour guide inquired, Mr. Backus mentioned that he was a graduate student in math; he was whisked upstairs and asked a series of questions Mr. Backus described as math “brain teasers.” It was an informal oral exam, with no recorded score.
He was hired on the spot. As what? “As a programmer,” Mr. Backus replied, shrugging. “That was the way it was done in those days.”
Back then, there was no field of computer science, no courses or schools. The first written reference to “software” as a computer term, as something distinct from hardware, did not come until 1958.
In 1953, frustrated by his experience of “hand-to-hand combat with the machine,” Mr. Backus was eager to somehow simplify programming. He wrote a brief note to his superior, asking to be allowed to head a research project with that goal. “I figured there had to be a better way,” he said.
Mr. Backus got approval and began hiring, one by one, until the team reached 10. It was an eclectic bunch that included a crystallographer, a cryptographer, a chess wizard, an employee on loan from United Aircraft, a researcher from the Massachusetts Institute of Technology and a young woman who joined the project straight out of Vassar College.
“They took anyone who seemed to have an aptitude for problem-solving skills — bridge players, chess players, even women,” Lois Haibt, the Vassar graduate, recalled in an interview in 2000.
Mr. Backus, colleagues said, managed the research team with a light hand. The hours were long but informal. Snowball fights relieved lengthy days of work in winter. I.B.M. had a system of rigid yearly performance reviews, which Mr. Backus deemed ill-suited for his programmers, so he ignored it. “We were the hackers of those days,” Richard Goldberg, a member of the Fortran team, recalled in an interview in 2000.
After Fortran, Mr. Backus developed, with Peter Naur, a Danish computer scientist, a notation for describing the structure of programming languages, much like grammar for natural languages. It became known as Backus-Naur form.
Later, Mr. Backus worked for years with a group at I.B.M. in an area called functional programming. The notion, Mr. Backus said, was to develop a system of programming that would focus more on describing the problem a person wanted the computer to solve and less on giving the computer step-by-step instructions.
“That field owes a lot to John Backus and his early efforts to promote it,” said Alex Aiken, a former researcher at I.B.M. who is now a professor at Stanford University.
In addition to his daughter Karen, of New York, Mr. Backus is survived by another daughter, Paula Backus, of Ashland, Ore.; and a brother, Cecil Backus, of Easton, Md.
His second wife, Barbara Stannard, died in 2004. His first marriage, to Marjorie Jamison, ended in divorce.
It was Mr. Backus who set the tone for the Fortran team. Yet if the style was informal, the work was intense, a four-year venture with no guarantee of success and many small setbacks along the way.
Innovation, Mr. Backus said, was a constant process of trial and error.
“You need the willingness to fail all the time,” he said. “You have to generate many ideas and then you have to work very hard only to discover that they don’t work. And you keep doing that over and over until you find one that does work.”
Saturday, March 17, 2007
Extra, Extra - Read All About It: Nearly All Binary Searches and Mergesorts are Broken
http://googleresearch.blogspot.com/2006/06/extra-extra-read-all-about-it-nearly.html
Posted by Joshua Bloch, Software Engineer
I remember vividly Jon Bentley's first Algorithms lecture at CMU, where he asked all of us incoming Ph.D. students to write a binary search, and then dissected one of our implementations in front of the class. Of course it was broken, as were most of our implementations. This made a real impression on me, as did the treatment of this material in his wonderful Programming Pearls (Addison-Wesley, 1986; Second Edition, 2000). The key lesson was to carefully consider the invariants in your programs.
Fast forward to 2006. I was shocked to learn that the binary search program that Bentley proved correct and subsequently tested in Chapter 5 of Programming Pearls contains a bug. Once I tell you what it is, you will understand why it escaped detection for two decades. Lest you think I'm picking on Bentley, let me tell you how I discovered the bug: The version of binary search that I wrote for the JDK contained the same bug. It was reported to Sun recently when it broke someone's program, after lying in wait for nine years or so.
So what's the bug? Here's a standard binary search, in Java. (It's one that I wrote for the
java.util.Arrays): 1: public static int binarySearch(int[] a, int key) {
2: int low = 0;
3: int high = a.length - 1;
4:
5: while (low <= high) {
6: int mid = (low + high) / 2;
7: int midVal = a[mid];
8:
9: if (midVal < key)
10: low = mid + 1;
11: else if (midVal > key)
12: high = mid - 1;
13: else
14: return mid; // key found
15: }
16: return -(low + 1); // key not found.
17: }
The bug is in this line:
6: int mid =(low + high) / 2;
In Programming Pearls Bentley says that the analogous line "sets m to the average of l and u, truncated down to the nearest integer." On the face of it, this assertion might appear correct, but it fails for large values of the
int variables low and high. Specifically, it fails if the sum of low and high is greater than the maximum positive int value (231 - 1). The sum overflows to a negative value, and the value stays negative when divided by two. In C this causes an array index out of bounds with unpredictable results. In Java, it throws ArrayIndexOutOfBoundsException.This bug can manifest itself for arrays whose length (in elements) is 230 or greater (roughly a billion elements). This was inconceivable back in the '80s, when Programming Pearls was written, but it is common these days at Google and other places. In Programming Pearls, Bentley says "While the first binary search was published in 1946, the first binary search that works correctly for all values of n did not appear until 1962." The truth is, very few correct versions have ever been published, at least in mainstream programming languages.
So what's the best way to fix the bug? Here's one way:
6: int mid = low + ((high - low) / 2);
Probably faster, and arguably as clear is:
6: int mid = (low + high) >>> 1;
In C and C++ (where you don't have the
>>> operator), you can do this:6: mid = ((unsigned) (low + high)) >> 1;
And now we know the binary search is bug-free, right? Well, we strongly suspect so, but we don't know. It is not sufficient merely to prove a program correct; you have to test it too. Moreover, to be really certain that a program is correct, you have to test it for all possible input values, but this is seldom feasible. With concurrent programs, it's even worse: You have to test for all internal states, which is, for all practical purposes, impossible.
The binary-search bug applies equally to mergesort, and to other divide-and-conquer algorithms. If you have any code that implements one of these algorithms, fix it now before it blows up. The general lesson that I take away from this bug is humility: It is hard to write even the smallest piece of code correctly, and our whole world runs on big, complex pieces of code.
We programmers need all the help we can get, and we should never assume otherwise. Careful design is great. Testing is great. Formal methods are great. Code reviews are great. Static analysis is great. But none of these things alone are sufficient to eliminate bugs: They will always be with us. A bug can exist for half a century despite our best efforts to exterminate it. We must program carefully, defensively, and remain ever vigilant.
Monday, March 05, 2007
Saturday, March 03, 2007
Tuesday, February 13, 2007
Stop Spamming Me!
Without further adieu, here is the full text: (http://jerrytalton.blogspot.com/2006/03/prof-nagib-callaos-translation.html):
Dear colleagues [Dear marks]:
As a response to the many requests we have received, the Organizing Committee of WMSCI 2006 (The 10th World Multi-Conference on Systemics, Cybernetics and Informatics) has decided to extend the deadline for papers and abstracts submission to April 4, 2006. If you have not already done so, please submit your abstract or your paper through the Conference web site. [No one has been stupid enough to fall for our scam this year, so we're taking another shot at soliciting submissions to our fake conference with this formal-looking email.]
The best 10%-20% of the papers will be published in Volume 4 of JSCI Journal. 12 issues of volumes 1 and 2 of the Journal have been sent to approximately 200 universities and research libraries, and 6 issues of Volume 3 (2005) will be sent to a larger number of libraries. Promotional, free subscriptions, for 2 years, are being considered for the organizations of the Journal's authors. [We assume that if we write the word "journal" enough times and throw some numbers in there, it'll look like we have a shred of credibility.]
Submitted papers will go through a two-tier reviewing process: a double-blinded and an open one. Submitted papers or extended abstracts will be sent to at least three reviewers, selected by the Organizing Committee, for their respective double-blinded review. Submitted papers or extended abstracts will also be sent to 1-3 reviewers suggested by the author(s) for their open, non-blinded, review. [Your submission will not be reviewed in any way. In fact, you can write a program to generate a completely nonsensical paper and we will still accept it, because we are the diploma mill of scholarly conferences.] Both kinds of reviewing will support the acceptance process for the selection of the papers to be presented at the conference, as well as the selection of the best 10%-20% of the papers that will be included in the JSCI journal. [Even we don't pretend to know what this sentence means, but it sounded good when we were stoned so we went with it.]
Submissions from both academia and industry are encouraged. Research papers, case studies, lessons learned, status reports, and discussions of practical problems faced by industry and user domains are all welcome. [We'll take anything. Really. Write us a story about your pet parakeet, and we'll publish it.]
If the deadlines are tight and you need more time, let us know about a suitable time for you and we will inform you if it is feasible for us. [You don't even have to spell parakeet correctly.]
Best Regards [Suckers!],
WMSCI 2006 General Chair
If you wish to be removed from this mailing list, please send an email to wmsci.remove@iiis-sci.org with REMOVE MLWMSCI in the subject line. [Once we have your email address we will NEVER remove it from our database, and you will go on receiving our spam until the day you DIE.]

















