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

 



Forgot your password?
typodupeerror
×

Comment Re: Poor Alan Kay (Score 1) 200

Essentially, they should never be used at all. If you're going to have an unrecoverable error, it's trivial to design the system to exit without using exceptions anyway.

Probably the most useful side effect of exceptions is printing the stack trace, and that's not something where the overhead (both performance wise, and logical complexity wise) of exceptions is needed. And you should really be doing logging rather than relying on cryptic exception traces.

The one theoretical case where exceptions are sometimes argued to be superior is if you don't know what to do locally about an error, and you're hoping that a higher level part of the program might know how to recover. Classic example is a read error, and then asking the user to put a usb stick in.

But guess what? That's not how nontrivial programs work. The higher level simply can't know fully the effect of handling an exception that bubbled up, because the low level details that matter can and often do have unpredictable consequences in terms of program correctness, especially when you're reasoning at a higher level. When an exception is thrown, your program state is wonky. Only trivial programs are like the usb stick example. Real programs become subtly wrong if you try to recover a partially completed, partially incomplete, multi statge operation, especially if you're not the guy who wrote the code, but feel you're doing the right thing at a higher level.

Your greatest chance of correctly handling errors is a few lines above or below where the error actually occurs. Anything else sounds good but is worse.

Comment Re:Poor Alan Kay (Score -1) 200

Exceptions are absolutely the right way to do error handling.

Really? You have no clue.

Exceptions are utterly wrong, they are Gotos Considered Harmful: An exception is basically a nonlocal jump and that's exactly the wrong way to do error handling, because it cause spaghetti logic, where pieces end up all over the place without any simple way to check what the code does besides unravelling the whole mess. And when multiple people maintain the code, it guarantees failures of logic.

The correct way to do error handling is _locally_, right where the failure occurs. It's the _nonlocal_ nature of exceptions which is evil because it causes brittle code and broken logic. Robust code requires that you handle all contingencies correctly. And you simply can't do that correctly way up the callchain except in trivial cases. But you can always do so at the site of the error. It's just very tedious and longwinded. But that's the difference between well written professional code and amateur hour anyway.

Comment Re:What's this? (Score 1) 8

Amazon was an experiment. I read the library's copy of Andy Wier's The Martian, really liked it, and googled to see if he had any more titles. Wikipedia said that he couldn't get a publisher so he introduced it as an Amazon ebook, it went to their best seller list, and a publisher bought the hardcover rights for a six figure sum.

So I thought, what the hell, why not give it a try? I thought it might give me extra exposure, but I was wrong.

User Journal

Journal Journal: Well, crap... 8

Patty emailed me and solved the "why isn't anybody buying the Amazon ebook" question -- according to her, it's nearly impossible. She says they won't take a credit or debit card, you have to either have an Amazon gift card or that Amazon Prime crap.

So I don't know what to do. I'd just pull it and put it on the site for free like the other two books, but that would hardly be fair to the two people who jumped through Amazon's hoops.

Suggestions are very welcome.

Comment Re:Probably sold out to CIA a long ago (Score 1) 184

Neat story, but I wonder if it was simply a case of your mind recovery from ad blindness. Perhaps those ads were there all along and you just didn't see them until yours broke and you had keyboards on the mind.

Sort of like when you learn a new word and then hear it 4 times that day.

Comment Re:Why would you ever need more than the kernel? (Score 1) 43

In this case your lawnmower shouldn't have anything more electrically complicated than a magnet and a coil for the spark plug. Maybe if you want to get really fancy, an EFI computer or brushless DC motor controller. But once your lawnmower is doing laps of your back yard automatically, and you want to connect to it from work via your house WiFi to check whether you left the pool cover on or not, it's gonna have an operating system.

Slashdot Top Deals

UNIX is hot. It's more than hot. It's steaming. It's quicksilver lightning with a laserbeam kicker. -- Michael Jay Tucker

Working...