« first day (2041 days earlier)      last day (2926 days later) » 

3:00 PM
@bigcodeszzer which we've done...
 
I open the device handle, I setup some initialization stuff, I write some data to it, I ask it how much data is available to be read, I read the data, etc
 
Well. I'm not entirely convinced about that.
@whatsisname sounds similar to handing files.
 
dozens and dozens of calls in a big loop that reads and writes data to it
 
handling
Yes.
Do you have the code by any chance
 
now, the overwhelming majority of the time, those calls are going to complete successfully without issue
 
3:01 PM
@DeliriousSyntax Why? are you deleting your accounts?
 
With the try/catch block, just the top level
 
Why not?
 
now, someone could pull the plug on the device while it is operating
and one of those calls is going to fail
 
Yah.
 
@DeliriousSyntax that would seem to be counter-productive.
 
3:02 PM
now that's not an error
so I have two choices in dealing with that
 
Hmmmm.
 
@AaronHall Explain.
 
I can check return codes at every single call and have a huge arrowhead of ifs
 
@AaronHall ragequitting due to having been question banned on Android.SE
 
Exceptions are great because they can't be accidentally ignored. In C, most functions return some error code. Unfortunately, few (beginners) remember to check for those, and are then surprised when things go wrong. If there is an unhandled exception, it will kill the program.
If you think exceptions are worthless, use a language that doesn't have them, e.g. C or Go. It's terrible.
 
3:02 PM
Wait a sec
 
or, I can use exceptions, which is basically a glorified goto which will jump to an error handler situation, and unlike the error codes
 
wait wait
Why is there a huge arrowhead of ifs
 
the compiler provides me another path to shuttle data up to that error handler, inside the exception I throw
 
Because of all the exceptions?
 
at least Go has the defer/panic/recover thing, which is more than C does
 
3:03 PM
no, because of all the ifs
 
or because of one exception (the usb pulled)
Right. But is one exception causing all of the ifs?
 
because I can't run the read command unless the command to see how much data is to be written was called succesfully
 
incidentally this is basically what I was trying to demonstrate with chat.stackexchange.com/transcript/message/28768899#28768899 earlier
 
so heres the thing, the exception can replace all the ifs
 
Fair enough.
 
3:04 PM
@DeliriousSyntax well, up to you, but I expect my participation on these sites to create long-term value for society and myself.
 
@bigcodeszzer no, doing it your way is causing all of the ifs, as demonstrated like an hour ago
 
But why can't there just be one check
 
and whats spiffy about it, is that the compiler basically puts all those ifs back in, and does it much better than you or I could (massive oversimplification)
 
if(plugged in){
}
 
silly repartee with Barry notwithstanding
 
3:04 PM
@BarryTheHatchet I've been banned other times as well
 
@DeliriousSyntax instead of deleting your account, you could try behaving
 
what exceptions basically are
 
I'm not seeing 'all of the ifs'
I understand what you are suggesting, yes.
 
is that people got tired of checking status codes all the time, and making provisions to transmit that error information back up to something that can deal with it
 
@bigcodeszzer hence the code example I just relinked that has extra ifs in it
 
3:05 PM
@BarryTheHatchet I'm just saying that's not it
 
When you come to a fork in the road, take it. Then you just need a knife and spoon, and you'll have a complete dinner set.
 
@Ixrec looking at it
Let me ask one question
If you were enforcing a more functional-type paradigm, do you think there would still be as many errorcodes/ifs?
 
let me guess
"what's the point in exceptions?"
 
I don't use this site anymore...
 
I think imperative vs functional is largely orthogonal to this
 
3:07 PM
yes of course, functional programming just moves ifs and errorcodes to different places
 
The future ain't what it used to be.
 
at the end of the day it all gets compiled to machine code, the jumps have to be in there somewhere
 
but Clojure has a try/catch construct, and some Haskell monads like Maybe and Either arguably have the same effect has a throw and a catch that happens much later
 
Well if the goal is to make clean, simple code
Do you think the try{catch} is going to be prettier than the functional 'moving of ifs' ?
 
exceptions have nothing to do with OOP. However, some functional languages place an emphasis on strong type systems, and prefer alternatives like monads for error handling. Most functional languages still have exceptions (Haskell) or even stronger control flow mechanisms (Scheme, CommonLisp)
 
3:09 PM
whether functional code is prettier than imperative code is largely about which style you're used to
and has nothing to do with exceptions vs error codes
 
@AaronHall finally
 
the motivation for using exceptions or Maybe/Either monads instead of a return code is going to be basically the same in functional languages as it is in imperative ones
 
a lot of times when you are dealing with error codes, it is impossible to make things simple
real world problems are always messy
2
 
i.e. the same motivation I spelled out in my answer and this convo has been rephrasing in a half-dozen ways for the past hour or so
 
Well I used the file example
You can use a try block, surely
or just if(file.open()){
 
3:10 PM
exceptions give you a mechanism for separating your code so while it is still complex, related functions are all grouped together rather than haphazardly mixed with other stuff
 
file handling is something where both return codes and exceptions are potentially the better choice depending on what the client code looks like
 
not just file.open, you also have to handle the scenario that your file is deleted while you're writing to it
 
which is why we haven't been emphasizing it so much
 
(locking the file won't always save you)
or if the disk runs out of space while you're writing to it
or the hard disk fails while writing to it
or the write operation is too slow
 
Don't those issues make the isopen() fail?
 
3:12 PM
why would they?
 
those all happen after you've called file.open
they can happen anytime you are doing anything with a file
 
while (file.isopen()){
 
and no they don't
 
part of the reason error handling is hard is that errors can happen virtually anywhere in perfectly correct code
 
I just wrote a webpage
 
3:12 PM
@DeliriousSyntax Can you delete that please? It's massive and pointless.
 
while() won't save you
 
@BarryTheHatchet It's not that big
 
@DeliriousSyntax It was hundreds of lines.
 
So what would you do with the try?
 
if the disk runs out of space, you might want to alert the user, but if the disk fails, that's a different scenario that needs to be reported
 
3:13 PM
only 1028 lines
 
What does a good file reader throw?
 
technically every single function call that contains a single local variable could potentially throw an out of memory or stack overflow exception
@bigcodeszzer FileException? I'm not sure what you mean
 
a good file reader will throw exceptions reporting those scenarios
 
What does the block look like?
 
but your main code path can proceed along assuming everything is hunky-dory
 
3:14 PM
Well, I mean, there must be a correct way to write the loop then, with a try block?
If I can see that, then I might be able to understand what the while is missing
 
it's the same as the correct way with error codes, but with lots of ifs removed
 
theres no 'correct' or 'incorrect' other than does what it is supposed to do, and in there there are endless ways to structure a function to do that
with exceptions or not
 
Well I mean, one that accounts for all of the exceptions
Surely, anyone who ever wants to read a file is going to encounter the same set of exceptions.
 
@bigcodeszzer the pseudocode I showed you earlier is basically exactly the sort of thing we're all talking about, but small enough it'd actually fit in here
 
I don't understand that snippet.
It's not specific enough.
 
3:16 PM
what's not to understand about it?
I can replace all the dummy function names with filesystem-themed dummy names if that's what you want
 
16
Q: Exception Handling and Opening a File?

MosheIs it possible to use exceptions with file opening as an alternative to using .is_open()? For example: ifstream input; try{ input.open("somefile.txt"); }catch(someException){ //Catch exception here } If so, what type is someException?

 
Stealing that pic
 
c'mon, hide that toon
 
@BarryTheHatchet be nice. (in your case: be nice, or else.)
 
to elaborate on the arrowhead
 
3:18 PM
@amon It's "or else" just for me?
Not for the guy who's been trolling the room for past two hours. Mmmkay...
 
@BarryTheHatchet yes. stop trolling. this is ridiculous
 
?!?!?!
 
say I try opening my usb device, and the error code says it failed, ok, I quit the function
but say it fails when I'm reading, I might need to release the resources I've used in the meantime
 
scroll
the
troll
off
the
screen
 
and you people wonder why I get so pissed off at you sometimes
 
3:20 PM
not only do I have to check the error codes, but I also have to tear down whatever stuff I've been using in the meantime
 
yay
 
which might change as things go along and change depending on where I fail
 
writeToFileWithExceptions() {
	try {
		actuallyWriteToFileWithExceptions();
	} catch(WorkException e) {
		std::cout << "Failed to write to file: " << e.what() << std::endl;
	}
}

actuallyWriteToFileWithExceptions() {
	ifstream file;
	file.open("filepath");
	writeText(file, "hello, ");
	writeText(file, "world!");
	file.close();
}

writeToFileWithErrorCodes() {
	int rc = actuallyWriteToFileWithErrorCodes();
	if(rc != 0) {
		std::cout << "Failed to do work: rc=" << rc << std::endl;
	}
}

actuallyWriteToFileWithErrorCodes() {
 
@BarryTheHatchet Your the one with the troll
 
@bigcodeszzer another attempt
 
3:20 PM
exceptions can provide a means to automatically tear that stuff down
 
Oh good grief
 
@BarryTheHatchet the point of this chat is discussing Programmers.SE. Our dear visitor is using the room for its intended purpose.
 
Okay.
But why is the exception tearing down cleaner/simpler than just the error codes?
 
That's what she said.
 
it should be fairly clear how in this example the exception version is much simpler, much easier to read, and much easier to get right
 
3:21 PM
@BarryTheHatchet Here's his evidence
 
Open your eyes, amon, seriously. Before you start flinging accusations about like that. I am not happy with your response here at all.
 
dangit!
hide it
 
if it's not I really have no idea what to say other than maybe you need to work on some real-world code before this sort of argument will make any sense
 
now DS is hidden until I refresh my page
 
3:22 PM
took you long enough
 
clicks Aaron Hall, clicks "ignore everywhere"
 
I did that with you, but it's too dangerous to let it go for too long.
:D
 
@bigcodeszzer: "But why is the exception tearing down cleaner/simpler than just the error codes?", I already described it to you
 
more Barry bashing
and I'm the troll being threatened
fscking barmy
 
That's what she said.
 
3:23 PM
you can have the tear down in one spot in one code path, instead of interspersed and repeated in an arrowhead of ifs
 
be nice for god's sake
 
yes, be nice
 
you're attracting attention from half the network
 
Flags everywhere
 
What flags?
I see no flags...
 
3:23 PM
I think @bigcodeszzer is waiting for everyone else to calm down before we get back to the exceptions thing
 
someone flagged the troll picture
 
I'm showing zero flags, literally
 
This room was placed in timeout for 1 minute; the topic of this room is "General Discussion for programmers.stackexchange.com Pants optional when telecommuting." - conversation should be limited to that topic.
 
@whatsisname Twice.
 
3:24 PM
I saw a few flags go by but I didn't get a chance to see what they were on
 
Be nice to each other, don't flag things that aren't offensive, and we'll all have a good time.
asking gets you much further than flagging a lot of the time.
 
TIL: "timeout" doesn't work when half the folks are moderators and room owners >.>
 
"hey, I don't like that, would you mind not posting that kind of thing in the future"
 
TIL one minute is 90 seconds
 
LMFAO I got time out
 
3:25 PM
yeah, but a fast 90 seconds
 
iirc someone did ask for the picture's removal here in chat both times it was posted
 
I thought that timeout was personal for a second ;-;
 
@whatsisname I manually put 90 seconds :P #roundingprobs
 
a second is a second no matter how fast it is
@Quill same
 
o.O
imma go find somewhere with grownups
ciao!
 
3:26 PM
I thought it was because I was the ref throwing flags
 
@bigcodeszzer: it sounds like you're just dead set on thinking error codes are the end all be all, you'll have to come around to realizing the value of exceptions on your own I guess
 
Error codes are for people who make mistakes... That's not me
 
?
So to get things back on topic for the room, since I'm not telecommuting, I'm being forced to wear pants. They're jeans. Black jeans, so they look kinda businessy with my suit coat.
 
I'm wearing cargo shorts. I hate pants. I wear shorts when it is 20F outside
 
anyone got a good horror story?
 
3:31 PM
There was a scary bug. It ate all users in The Whiteboard. The end
"I am not a 50 cent fan or follower or anything like that, but I came across this quote not too long ago and it spoke volumes to me, so I thought I would pass it on to all of you. The rapper 50 cent was on the set of his movie and at the same time, was recording the soundtrack for the movie. As a reporter boldly asked the rapper when he sleeps, 50 responded promptly “Sleep, sleep is for those people who are broke. I don’t sleep, I might miss the opportunity to make a dream become a reality."
@AaronHall What is your favorite mobile browser?
 
@AaronHall Sweet.
What should I have for lunch?
Also, when are you going to fix your thumbnail, @Aaron? I keep expecting it to grow out.
 
You should go here. I went for valentines day
The floor spins slowly and walls are made of glass.
 
It's a bit far. I was thinking more like pizza, panini, or gamble on the special.
 
we apparently are having a tailgating themed lunch with brats today @KitZ.Fox
 
Or maybe just yogurt with granola.
@enderland First rule of Fight Club is don't talk about Fight Club.
 
3:37 PM
@KitZ.Fox If you want something bad enough you will do what ever it takes to get it
 
I don't want a spinning restaurant bad enough.
Also, my ears are delicate so I get vertigo.
 
It's only like $80 a plate though
 
If the plates are that expensive, the food better be free.
 
Plate of food -_-
 
initiates failover routine for room humor
Well, I'm going to go get some lunch while this place reboots.
 
3:40 PM
Can I join?
You gotta pick me up though
 
Where the hell is @JimmyHoffa anyway? Pretty sure this is all his fault.
@DeliriousSyntax No.
I don't eat with people. It's gross.
bbl
 
I think jimmy stopped coming to this chat room for some reason
 
@Ixrec good point.
 
Wow, I just found an app titled punch the trump
 
3:55 PM
@Ixrec Was it me? I left for a day or so because he felt like there were too many new people.
 
It was MichaelT leaving
 
Oh. That makes sense.
I mean, that makes more sense.
 
I don't think that was the only reason but that was definitely the biggest one, and the reason it happened at that particular time
 
@Ashley Dinosaurs and cupcakes will be one of the short stories I write for my short story collection in November.
 
Yeah, agreed, but that was the straw that broke the camels back so to speak.
 
user15026
3:57 PM
@KitZ.Fox excellent!
 
And here I believed you when you said you never had any drama.
@AshleyNunn I know I said I would do it sooner, but I've been thinking about it a lot.
 
we didn't have any drama until...well just today tbh
that's literally the only time I've ever seen a mod swarm in this chat room
 
we were pretty low key for ~4 years
 
drama?
That was the most non-drama drama I've ever seen.
 
There was a mod swarm? And not for April Fools' not that I'm admitting anything?
 
3:58 PM
Eh, it's happened a couple times, but nothing like one of the corners of this chatroom leaving has affected it so much.
 
I read that as 'coroners'.
 
I recall someone coming in and asking a question or two in broken english before becoming incredibly racist in one message.
that got quite a swarm.
 
@KitZ.Fox a half dozen or so non-PSE mods came in here during today's flagging
@Ampt ah, I wasn't around for that one
 
While I was at lunch?
No...hmm.
 
@Ixrec that was a whiiiile back
 
3:59 PM
I'm sockist against white socks.
 
I don't even know if I was room owner at that point.
 

« first day (2041 days earlier)      last day (2926 days later) »