Conversation started Apr 18, 2011 at 3:08.
Apr 18, 2011 03:08
I've never bought the "exceptions should only be used for exceptional circumstances" argument.
you'd throw an exception?
:-S
Maybe. I don't know enough about the problem. I just think an exception might be worth considering.
i imagine wearing a helmet, putting on ear plugs, and wearing a protective vest before calling a function "because it might throw at me in fury everything it's got"
if i use exceptions then i need to try. which is not much different than checking for null. what does it give me over a null ... ?
i'd really use a null object if it wasn't for the undo stack. so essentially i need to treat a null object different from all other commands.
Do you want to report the error to the user?
mm. maybe. didn't think about that. i was just about to swallow it.
but i might.
Apr 18, 2011 03:14
Eeeewwwwww
yeah i suppose, give a warning.
oh yeah that's an error. definitely.
you know what, i think you just triggerred the answer for me.
:)
with the "are you going to report it to the user"
I'm glad I was able to do something useful today. :-)
i have to. i have to report it as an error. if the user gives me a sequence of commands and somewhere among them is an erroneous command then i shouldn't proceed, i should abort. so in fact i shouldn't execute anything before i know all command names are valid. so if i do two passes then i can guarantee that create_command() gets a valid command name!
i'll still have to eliminate the compiler warning though, so i'll return a null as a last resort and i can assert on that. it should never return null in production.
Apr 18, 2011 03:43
is this wrong question..?
hey need
a help in c++
can anyone help
Apr 18, 2011 04:16
Does anyone know what font(s) is used in the C++0x FDIS?
 
1 hour later…
Apr 18, 2011 05:17
The latin modern variant of the computer modern familly by Knuth.
(Acrobat reader has a properties entry in the file menu which opens a form with a font pane.)
Ah; so it does. Latin Modern Regular and Typewriter. For shame; I was hoping it was something preinstalled on Windows so I could use it as my e-mail font.
Thanks for the tip on having the PDF reader tell me.
It's a nice font.
@JamesMcNellis pretty sure there are free .ott version of Latin Modern available online
and who cares if it doesn't look as nice on the other end, your emails will look good when you send them! ;)
@jalf I found a bunch of OTFs. I tried the Typewriter variant as an editor font but I don't like it as much as my current font, Anonymous; it's too wide.
Apr 18, 2011 05:35
oh yeah, and by .ott I obviously meant .otf :)
Apr 18, 2011 06:12
Hello all
hi
hello @GMan
Apr 18, 2011 06:35
@jalf Look on ctan
Apr 18, 2011 07:10
@JamesMcNellis Ive never bought the exceptions should be used, even in exceptional circumstances argument.
I feel they are more akin to raw arrays in c++. Something thats necessary under the covers, but should never be part of a user interface.
@ChrisBecke that can't come as a surprise. You've never bought that any part of C++ should be used
@jalf Thats a fib. Ive bought into a lot of C++.
@ChrisBecke What's an equivalent that's just as powerful?
@ChrisBecke What kind of user are your speaking about? Obviously I don't mention exception to my end users...
handling the error where it happens (if needed). Its called cohesion and they teach it in comp sci 101. Not apparently to c++ students howevr
Apr 18, 2011 07:13
@ChrisBecke What's "handling the error"? This is hand-waving.
@AProgrammer I refer to the user of the specific c++ framework that abstracts the concept.
What mechanism do you use to report errors that's as powerful as excpetions?
@GMan handling the error means ensuring the state of the software is logically consistent, such that further calls can be made and expected to work.
@ChrisBecke that's a strawman argument
@ChrisBecke Right...but this doesn't specify anything about a mechanism.
Apr 18, 2011 07:15
@ChrisBecke that sounds like what the rest of us calls "exception safety"
You can "handle the error" with exceptions.
@ChrisBecke Assuming that exceptions should be used only for errors (I don't agree, but that can be another discussion), all libraries that I know of are able to report errors at time. So they aren't handled when they are detected...
whether or not you handle errors is completely orthogonal to whether you express errors as exceptions or return codes
nope. but using error codes to handle errors is just as capable of ensuring consistent state.
@ChrisBecke Nope.
Apr 18, 2011 07:16
um, yep.
If my class fails to construct, how should I report that?
Even if constructors could return values, the return value can simply be ignored.
Exceptions must be handled.
I like the way that neither of us failed to provide any actual facts for those assertions.
Exceptions is just another mean of reporting the error. And it is more adequate when the direct caller isn't the one which will handle it.
(I've sometimes even provided 2 interfaces for the same functionnality, one with another error report mecanism and one with exception as the choice wasn't clearcut)
When classes cannot construct, then the software has in fact entered an invalid state where the state of things cannot be constructed.
Note that I did mention that exceptions are like raw arrays. Things that should not be used in application domain problems.
@ChrisBecke You end up with far more repetitive, boring and error prone code which distract of the true issue.
Apr 18, 2011 07:18
@AProgrammer You might.
@ChrisBecke Yes, and it's better that the program forcibly handle that, than ignore it to do much damage down the line.
But you dont actually need to test error codes to ensure that the software's state doesn't become inconsistent.
@ChrisBecke Bullocks. If I don't test something, I can't know.
@ChrisBecke huh? Then how do you propose to handle errors?
@GMan You can't know what?
Apr 18, 2011 07:20
you try to open a file, the operation fails, and you can't be bothered to test the error code. How then do you avoid your software's state becoming inconsistent?
@ChrisBecke See jalf's response, above this one.
with an exception it's trivial, because the app terminates unless you write code to recover from the error.
@jalf If the file fails to load, then the object that represents the file will report that there is no data.
@ChrisBecke how does the object that represents the file do that, if it didn't check the error code?
and how does it report anything, if you don't check the error code you get from that object?
depending on how severe that is, the program can decide wether to proceed regardless, or not.
Apr 18, 2011 07:21
@ChrisBecke Decide with what? You said we don't need to test anything. Branching depends on testing.
Or do your programs operate by magic?
are you sure you want an answer to that?
I do recall saying you do need to test - just not always
:3
3 mins ago, by Chris Becke
But you dont actually need to test error codes to ensure that the software's state doesn't become inconsistent.
@ChrisBecke but if you ignore just one single error code, how can you ensure a consistent state?
This says, in English, you don't need to test anything to ensure consistent state. Now you're saying some checks can be omitted. Moving the goal post?
Apr 18, 2011 07:23
Hmm...
@jalf There are lots of potential errors that have nothing to do with the persistent state of the software.
I disagree, if you do not use exceptions, then you should check all return codes/error codes all the time.
@ChrisBecke name one
If you do not do that then you will either end up breaking your data/application or you will be reporting different errors than those that actually happened.
E.g., missing file versus error reading a file.
If I read a file in, its not necessary to check if (a) the file handle was created, (b) the contents were read, (c) the file closed, (d) the file was parsed.
Apr 18, 2011 07:25
It is not?
if an error occurs, it, by definition, means that something has happened which you didn't anticipate. If you don't detect this, then it practically sounds like the definition of "inconsistent state" to me
The only thing the rest of the system depends on is, was the config data (in this case) loaded or not? And if there are sensible defaults, even the lack of loaded config data can be ingored.
@ChrisBecke how do you fall back to the default, if you don't test whether the data was loaded correctly from the file?
Beat me by 2 seconds.
@jalf Oh ffs. are you seriously so unimaginative that thats hard? Get out of programming if thats the case.
Apr 18, 2011 07:26
@ChrisBecke Haha, wow. Answer the question.
"Chris: XYZ. jalf: Why XYZ?. Chris: YOU CAN'T THINK OF IT SO I'M RIGHT."
Just preload the defaults. Any failure to load and parse settings won't effect the defaults.
@ChrisBecke how do you I am so unimaginative that I want you to defend your own argument, yes
I have no interest in discussing with you, if it means I have to present both sides of teh argument
@ChrisBecke Sure it will. If I cannot read the first value (to overwrite the preloaded default), an error occurs and the stream needs to be reset (i.e., skip the read). Therefore, I cannot read the second without handling the error.
@ChrisBecke what if you read half the file, and then it fails (harddrive failure, perhaps)? How do you detect this and fall back to the default, rather than relying on half-corrupted data?
@ChrisBecke And nobody said that exception should be the only error reporting method.
Apr 18, 2011 07:29
remind me not to let you write any error-handling codefor me
by the way, getting back to exceptions, they're a really lousy mechanism for error handling, no doubt about that. it's just that I'm not really aware of any significantly better alternative, and error codes certainly aren't it
@jalf hardware failures, by definition, are exceptional. 2. transactional processing means that even a half processed file can either be unwound, or applied in a way that does not have to result in inconsistent stata (and thats assuming the convoluted case where the settings being discussed do depend on each other to be consistent)
@ChrisBecke how do you propose to implement transactional processing without detecting errors?
@ChrisBecke Exceptional or not, it's still an error that you need to correctly identify if you want your program to function correctly. You think Google just says "Oh, well, shit happens?"; hell no.
and I wasn't aware that you didn't care about "exceptional" errors. So they're allowed to bring you into an inconsistent state then?
@jalf Again, we are detecting errors, just, only the necessary errors.
Apr 18, 2011 07:32
@ChrisBecke but then explain to me how file I/O errors aren't necessary
My claim is that the set of errors that need to be handled is smaller than the set of errors thats technically possible
and yes, I am unimaginative. My imagination is every bit as bad as your debating skills
@ChrisBecke yes, and then you fail to provide a single example of an error that doesn't need to be handled
I am not debating. I'm saying that I prefer to handle errors with explicit error handling
Chris's argument basically boils down to arguing obscure and vapid definitions for "error", "handling", and "consistent", until he's right.
because the code is not much larger than code with exceptions
and easier to audit
and understand.
Apr 18, 2011 07:34
No, you didn't state a preference to begin with, you stated a "fact".
Exceptions are easy to understand.
@ChrisBecke no, you were saying that you prefer not to handle errors with explicit error handling
But don't change the topic.
because it's not necessary
I was responding to an earlier erroneous statement of "fact"
I'm also not sure why exception handling does not qualify as "explicit error handling"
it looks fairly explicit when I do it. I have to write code and stuff, doesn't get much more explicit than that
Apr 18, 2011 07:35
lol
in fact, if I fail to explicitly handle an exception, my app dies.
@ChrisBecke I remember a war story where someone forgot to test the result of close. It end up in a emergency visit to a very angry customer...
In my experience, implicit error handling occurs when I deal with return codes, because I forget to check them, implicitly relying on them to "probably be ok"
In my experience, implicit error handling occours when I see code that was written with exceptions, because programmers always put the throws in, and decide to puth the catches in later.
With the error handling decoupled from the error sites, no code audit can detect that.
But, perhaps code reviews are an artifact of the dark ages of software development
so you're saying you prefer correct error handling over incorrect error handling now?
that seems like a different argument than the one you started out with
Apr 18, 2011 07:38
Better to say "this error needs to be handled" forcibly, have it not so my program closes, than say "this error needs to be handled...but it's up to you" and have my program corrupt randomly?
because you clearly don't adhere to them as a means of maintaining software quality.
@ChrisBecke Clearly? Do go on.
@ChrisBecke says Mr. "I don't need to check error codes"
Given that my position is that exceptions are incompatible with code reviews.
How so?
Apr 18, 2011 07:39
@ChrisBecke your position is also that actually checking errors is unnecessary, which also seems incompatible with code reviews, if you ask me
My code reviews handle them quite well.
@GMan so you claim.
lul
@ChrisBecke Yes...
Chris, please explain why code reviews and exceptions are incompatible.
exceptions, decouple the site where errors are handled, from the site where errors are generated.
Apr 18, 2011 07:41
So, basically, what you are saying, Chris, is that you do not do error handling or exceptions because it would be undue burdeon on reviewers?
meaning that code reviewers now need to cross reference multiple files to audit a piece offunctionality.
@ChrisBecke So does error handling! You cannot always handle all error codes and you have to propagate the error to different site.
Exceptions are nothing but such error propagation but implicit. IMHO
When you call fopen() it returns an error code to the caller, rather than handling the error where it is generated. How is that better?
@wilx Error handling is far more unit testable - each layer can be tested to respond correctly to correct input, and return an error code when things fail.
So, when functionality is changed, its easy to see wether the correct new cases have been handled at the current abstraction level or not.
Far more? Last time I checked CPPUnit's test cases had the capability to test for exceptions, too.
Apr 18, 2011 07:44
@ChrisBecke why couldn't the same tests be written to check for exceptions?
Changing the topic again...
----^
btw, now we've changed from "exceptions can't be code reviewed" over "detecting errors isn't necessary", over "get out of programming, you n00b", to "exceptions can't be unit tested"
Acknowledge the points that were just made. Exceptions and error codes both necessarily have to propagate in many cases.
could you make up your mind about what it is you're trying to teach us?
Apr 18, 2011 07:45
Of course unit tests can check for exceptions. The problem is that exceptions, by design, violate abstraction by bubbling out of objects to be handled at some other level.
@ChrisBecke just like an error code does
As soon as your design does that, it means that testing the software units does not represent the overall state of the software.
it is something you return from a function. It bubbles out from the function that generated the error
With error codes, if A calls B, calls C, which fails and returns an error code to B, B can in turn fail (or gracefully handle the error) - and return a code to A.
With exceptions, someone can add a new error to C, causing it to bypass B's catch clauses, and get handled at A.
Which is far harder to verify by code review as perhaps there are errors that are designed to bypass B.
@ChrisBecke Right, which is perfect, because B cannot possibly correctly handle the error.
With exceptions, the flow jumps exactly to whoever can handle the error first.
Apr 18, 2011 07:49
And when C communicates errors directly with A, without going via the B abstraction, thats abstraction leakage.
With error codes, B is forced to handle A's errors, which makes for a more cohesive design, that preserves abstraction
thats my opinion of course.
Actually, that's just nonsense. You've thrown in the word "abstraction" into your conclusion, which is a word not present in your premises. Syllogism fail.
Let's try it this way: exceptions are just error codes with explicit checks at every single expression, that automatically propogate to the error code check that would return true. Do you agree with this isomorphism?
Its way to early in the morning to be throwing words like isomorphism about.
Do you agree exceptions can be said to be automated error codes?
and "automatically propogate to the error code check that would return true" is true, when the error code is a bool, true for success, false for error. but ok.
Well no, the error code could be any integer.
Apr 18, 2011 07:56
or complex type, or combination of success and error codes.
Right.
but yes, error codes and exceptions are isomorphic.
So then, if you agree with error codes, and exceptions are automated error codes, then how can you disagree with exceptions? It seems to be an objection to automation.
(And on top of that, you can't forget to check an error code if it's being automated.)
@GMan I think I have been quite clear, it IS the automation aspect that forms the basis of my objection.
Because theyre automated they can happen when they don't need to, and theyre invisible to code reviews.
What can happen when they don't need to?
Apr 18, 2011 07:59
@ChrisBecke the error handling can happen when it doesn't need to?
are you objecting to the fact that it prevents you from ignoring errors?
@jalf Ignoring errors? no. I'm objecting to the fact that exceptions move the burden of deciding the severity of an error is from the consumer of an interface to the designer of an interface.
@ChrisBecke Please answer my question, what is happening that doesn't need to?
"...exceptions are just error codes with explicit checks at every single expression..."
@ChrisBecke Okay, and...?
So you mean to say you fail to check all error codes? Then your program is, by definition, incorrect.
so your problem is that you're not allowed to ignore errors?
Apr 18, 2011 08:04
You very rarely, actually need to check the result of every single expression.
@ChrisBecke On what grounds? If I don't know that every expression executed without error, I don't know if my program is correct, by definition.
(admitting there are specialist software niches where such rigorousness might be an actual requirement)
@ChrisBecke If by special you mean general, sure.
Here's your problem: you seem to think correctness is an optional feature. Every had a program crash? That's the mentality behind it.
is it me, or have you done a complete U-turn over the last 20 minutes? From "Impossible to perform code reviews on" to "I don't actually want to handle all my errors"
which sounds like something that'd be impossible to get through a code review
@ChrisBecke Are you a game programmer?
Apr 18, 2011 08:06
on occasion.
And on not occasion?
how many game saves have you lost because the developer didn't bother to handle errors?
I've had a few
I work on the asset loading, background updating and server sides of the product
@jalf True that. :(
@ChrisBecke And if an asset fails to load, or updating fails, you just ignore errors?
how many games have you had to reinstall because the updater (background or otherwise) failed to handle errors?
I've had a few
Apr 18, 2011 08:08
Out of billions of game-plays... I think close to zero lost.
you've played billions of games?
I'm amazed you have time to develop them too
no. our players have.
Oh, and you've asked every one of them if they've lost a save game due to your sloppyness?
@ChrisBecke Does that code handle errors?
Or do you just assume that they'd write you a letter when it happened?
Apr 18, 2011 08:09
Anyway, perhaps it's crass of me, but I asked that because game developers are the worse programmers in terms of correctness that I know of.
they can get quite tense if the game doesnt work.
theres money involved
My job, as a programmer, is to ensure that the end users get the best expreience of the software.
Which probably involves making sure the code works.
and and unhanded is thus a far worse problem than a single asset not loading.
both of them are bugs, there in the users face.
(Could you say your first message again? I cannot parse it.)
damnit. can't edit.
sbi
sbi
Apr 18, 2011 08:16
There's one argument that usually stops all discussions about which error handling is to be preferred once and for all.
(morning, btw.)
Which code you'd rather work with:
int blrgl1(const frgl& wrgl, frgl& result)
{
  frgl result1;
  if( error_success != xrgl(wrgl, result1) )
    return error42;
  prxl result2;
  if( error_success != yrgl(result1, result2) )
    return error4711;
  if( error_success != zrgl(result1, result) )
    return error768;
  return error_success;
}

frgl blrgl2(const frgl& wrgl)
{
  return zrgl( yrgl( xrgl(wrgl) ) );
}
and an unhandled exception is just as much of a problem as an asset not drawing.
@sbi morning
sbi
sbi
And if you're saying the first example is exaggerated, because your code never looks like this, then you're just skipping error handling. Your code should look like this.
@sbi just left a comment on the meetup page :)
@ChrisBecke Okay, but I don't see how that relates to anything.
Apr 18, 2011 08:17
@sbi these variable names look like chinese or something :P
sbi
sbi
@TonyTheTiger Then replace them by foo, bar, foobar etc. :)
@sbi The second peice of code isn't correct as you have omitted the error handling.
@ChrisBecke The implication of the examples is that the second uses exceptions...
sbi
sbi
@ChrisBecke No, I haven't. Error handling is done by the outermost function which just reports the error to the user.
Apr 18, 2011 08:19
@GMan The error generation is only half of how error handling is done.
sbi
sbi
My point is, in the second example you immediately see what the function does, in the first the algorithm the algorithm is buried under error handling.
there DOES need to be a catch clause elsewhere
@ChrisBecke Yes, as there needs to be checks for certain error codes elsewhere...
sbi
sbi
@ChrisBecke Yeah. One catch clause, in one place.
without a catch clause, the first piece of code could be written as the 2nd piece.
sbi
sbi
Apr 18, 2011 08:20
With error code, you have to check everywhere.
@ChrisBecke but most of the error handling code doesn't need to be inside that catch clause. It just has to be in the objects that go out of scope when an exception is thrown
in other words, the error is handled in and by the object that generated it
sbi
sbi
@ChrisBecke Do that. Show us. Now.
@ChrisBecke But since it uses error codes, the error goes unhandled and your program is broken, by definition.
@jalf; @sbi I don't know why you bother having this discussion, some people are unable to change their mind about something, no matter what you say
@TonyTheTiger oh, Chris has changed his mind more than a few times during this discussion
2
Apr 18, 2011 08:21
@jalf but not in the right direction
sbi
sbi
@TonyTheTiger One of the many directions might have been the right one.
It's like a compass. No matter what we say, he assumes the position that points in the opposite direction
@sbi oh, too many directions in one go create confusion
He started out saying exceptions weren't good enough for robust error handling, and ended up saying they forced him to do more error handling than he wanted
@jalf that's exactly why there's no point in even trying to have a discussion cause he only seems out to make wrong
Apr 18, 2011 08:23
with a few detours along the way
sbi
sbi
@TonyTheTiger Hey, I only threw in this one argument. If he comes up with a convincing argument as to why the first is better than the last, I might even learn something. Otherwise I'll just bow out.
forks
I don't think what we're having can be termed a discussion anyway
i'm sorry for ranting in the comments
Apr 18, 2011 08:23
@sbi heheh smart :p
sbi
sbi
@JohannesSchaublitb ohhhhhhh!
@sbi I see you have fun!
@JohannesSchaublitb Your rants are like sweet, sweet nectar.
@jalf what would you term it then? a one ended rant?
lol @GMan
little bee
Apr 18, 2011 08:24
@JohannesSchaublitb what ranting comments?
sbi
sbi
@GMan ...provided by poisonous, stinging bees.
:D
I planned on staying up all night, drank three Red Bulls, but all they made me do is wanna roll over and pass out.
@GMan so much for the wings then....
Yeah :/ In other news, PacMan (<...............
sbi
sbi
Apr 18, 2011 08:26
@TonyTheTiger What's wrong with them wings? You can roll over in the air just fine, and albatrosses sleep during fight.
@JohannesSchaublitb, on the comment on saturday about the class and value initialization, I guess that my wording was not precise, I had spelled a class with no destructors, and then wrote what the implicitly defined (that was missing from the text) default constructor would look like, and how it differed from value initialization. In the presence of a user defined constructor, value initialization and default construction are the same.
@sbi hahah but redbull wings are supposed to keep you awake.... @GMan was dozing off with his...
I think my wording was all wrong if anything.
sbi
sbi
@ChrisBecke We're still waiting for you to provide a way that blrgl1() could be written the way blrgl2() is and pass on all the errors reported without using exceptions. If you can't do that, this might be a perfect moment to admit that you just have learned something. (Well, you should have, at least.)
@DavidRodríguezdribeas this can lead to surprises
 
Conversation ended Apr 18, 2011 at 8:30.