Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-4041-

c++ Is assert evil?

Name: Anonymous 2011-02-07 23:41

The Go language creators write*:

Go doesn't provide assertions. They are undeniably convenient, but our experience has been that programmers use them as a crutch to avoid thinking about proper error handling and reporting. Proper error handling means that servers continue operation after non-fatal errors instead of crashing. Proper error reporting means that errors are direct and to the point, saving the programmer from interpreting a large crash trace. Precise errors are particularly important when the programmer seeing the errors is not familiar with the code.

Surely they're being faggots, right?

______________________________
* http://golang.org/doc/go_faq.html

Name: Anonymous 2011-02-07 23:43

yes.

Name: Anonymous 2011-02-07 23:45

Cool logic. It's like socialism - good programmers are too good with proper use of asserts, ban them and we will be all equal!

Name: Anonymous 2011-02-07 23:49

Yes, they're retarded. GoLang was made by autists for autists anyway.

No, there's nothing wrong with assert as long as you use it as intended.

That is, it's supposed to be for catching cases that "can't happen", during debugging, as opposed to normal error handling.

- Assert: A failure in the program's logic itself.
- Error Handling: An erroneous input or system state not due to a bug in the program.

Name: Anonymous 2011-02-07 23:53

assert
Sepples


Two problems.

Name: Anonymous 2011-02-08 0:09

>>4
GoLange was made ... for autists .

As regular visitor of /prog/ autism/general, I strongly disagree.

Name: Anonymous 2011-02-08 0:09

An assert will do the same thing as an unchecked exception would, the only exception is that the assert (normally) should not be kept for the final product.

If you build a safety net for yourself while debugging and building the system why would you deny this safety net for the actual enduser of the code. Use exceptions exclusively for both asserts and exceptional situations. By creating an appropriate exception hierarchy you will be able to discern very quickly one from the other. Except this time the assert remains in place and can provide valuable information in case of failure that would otherwise be lost.

So I fully understand the creators of Go by removing asserts altogether and forcing programmers to use exceptions to handle the situation. There is a simple explanation for this, exception are just a better mechanism for the job why stick with the archaic asserts?

Name: Anonymous 2011-02-08 0:18

the only exception is that the assert (normally) should not be kept for the final product.

c2.com/cgi/wiki?ShipWithAssertionsOn  IN YOUR FACE

Name: Anonymous 2011-02-08 0:59

Log the error, crash, and let the supervisor process restart you.

Name: Anonymous 2011-02-08 1:00

>>8
There's a c2.com wiki pattern for everything.

Name: Anonymous 2011-02-08 2:36

But asserts are a macro so they can show line numbers etc.

Name: Anonymous 2011-02-08 5:25

>>11
So is your mum. But what's your point?

Name: Anonymous 2011-02-08 5:32

>>8
WhatsWrongWithTheseAnnoyingCamelCasePeople?

Name: nigger 2011-02-08 15:21

>>7
why would you want to throw an exception for a bug in your program? The whole point of assert is that after you see one, something already went wrong, and a method for continuing from that state has either not been thought of or at least has not been implemented. If you have code with asserts in other situations, then yes, it could make sense to throw instead. But it's pretty common to use assert to check something about function params, and easier to debug with a c++ debugger, than to throw an InvalidArgException or something.

Name: Anonymous 2011-02-08 16:51

assert(true)

if !(true){
    panic("Assert failed in module herp on line derp.");
}

Might as well be the same thing.

Name: Anonymous 2011-02-08 16:56

if !(true){
Tsk.

Name: Anonymous 2011-02-08 16:58

>>16
Valid Go code. What's your point?

Name: Anonymous 2011-02-08 17:34

There's nothing wrong with using assert.

If you're writing a complete software application and don't have any facilities for third party plugins, or aren't writing a plugin/component for another system, then you have no reason to recover from application errors--any errors you didn't foresee are your own fault, and the program is already fucked, you might as well just abort and have the user restart it.

Exception handling is quite useful, but it shouldn't be used to recover from your own fucking errors. It should be used to recover from exceptional system conditions, like maybe your application doesn't have correct security permission to access a particular file. Or it should be used to notify other components of exceptional conditions if you're writing a driver/component/etc. for some other system. Keep in mind that exception handling has a fair amount of overhead as it increases code bloat and thus instruction cache misses. In C++, turning exception handling off at the compiler level (-fno-except in GCC), can cut your binary size down by as much as 15%-20%.

Most game developers don't use exception handling, at least not on consoles, instead they use a lot of asserts as they're developing something they have full control over.

Read this: http://gamesfromwithin.com/asserting-oneself

Name: Anonymous 2011-02-08 17:36

>>16
Tsk.
Tcl/Tk.

>>17
Go
Tsk.

Name: Anonymous 2011-02-08 17:37

>>17
No [code] tags.
Also the fact that

if !(true)
{

is invalid Go code.

Name: Anonymous 2011-02-08 17:39

Yes, Go developers are faggots. Asserting is fine. Forcing exception handling for everything is the autist mindset.

Name: Anonymous 2011-02-08 17:59

>>21
What Python forced so far:
Indentation of code.
One-linerization of lambdas
Statementification of assignments.

What Go forced so far:
Capitalization of exported symbols
Stringization of imported modules
Handling of exceptions.
K&Rification of code (>>20)

Now I understand why they said it's ``based on Python''.

Name: Anonymous 2011-02-08 18:30

>>18
Go doesn't have exceptions, either.

>>20
People that use that code style deserve to die anyway,

Name: Anonymous 2011-02-08 18:38

>>23
So it forces the use of error return codes for error propagation from all functions?

Name: Anonymous 2011-02-08 18:49

No, neither goto nor assert are evil. But both can be misused.

Assert is for sanity checks. Things that should kill the program if they are not correct. Not for validation or as a replacement for error handling.

Name: Anonymous 2011-02-08 18:50

>>24
Go has panic("reason") and recover() for times when control flow should stop (similar to assert, but doesn't automatically kill everything).
In place of exceptions, there's a convention where functions that can error should return a second value indicating if there was an error, so:
func readFile(fileName string) (result string, err os.Error){
    blah
}
// Then, you do the following
result, err = readFile("blah")
if err != nil{
    // That didn't execute properly
}

Name: Anonymous 2011-02-08 18:55

>>25
It doesn't have anything that's considered harmful:
no gotos, no asserts, NO EXCEPTIONS, no templates, no generics, no macros, no Lisp macros (yes, they really think they are harmful), no metaprogramming support, no continuations, ....

Name: Anonymous 2011-02-08 18:56

>>27
And yet it's still nice to program in and it runs quickly.
Different strokes for different folks.

Name: Anonymous 2011-02-08 18:58

>>28
And yet it's still nice to program in and it runs quickly.
IHBT                                

Name: Anonymous 2011-02-08 19:04

>>29
IHBT by that spoiler.

Name: Anonymous 2011-02-08 19:05

>>29
>gives up when he loses

Name: Anonymous 2011-02-08 19:06

>>25
I beg to differ on goto. assert offers something useful, something that can't be easily replaced. I've yet to see a problem where a goto was actually the best solution.

Name: Anonymous 2011-02-08 19:07

>>31
quotes like the imageboards.
quotes something that isn't here
mfw

Name: Anonymous 2011-02-08 19:49

>>27
if considered harmful, please send http://www.antiifcampaign.com/ to them.

Name: Anonymous 2011-02-08 20:23

>>34
http://www.antiifcampaign.com/
I thought, I'm the only who is that smart, because in my Lisp DSL I dont use `if`s at all.

{symbol? -> handleSymbol; else -> error "go fuck your mom"}

Name: Anonymous 2011-02-08 20:55

>>35
Neither do I:
(cond ((symbol? => handle-symbol) (else (error "go fuck you´re mom")))

I don't see any `if's here! amikewlnawguise‽

Name: Anonymous 2011-02-08 20:56

>>36
Wait, I fucked it up a little:
(cond (symbol? => handle-symbol) (else (error "go fuck you are mom")))

Name: Anonymous 2011-02-08 21:13

>>35
THINK YOU'RE THE ONLY WHO IS MY ANUS!

Name: Anonymous 2011-02-08 21:33

CAR CAR CAR CAR CDR CDR CDR CDR CAR CDR EVAL APPLY CAR CDR EVAL APPLY CAR CDR EVAL APPLY CAR CDR EVAL APPLY CAR CDR EVAL APPLY CAR CDR EVAL APPLY
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPUTER WITH OUR SPELLS
WE CONJURE THE SPIRITS OF THE COMPU

Name: Anonymous 2011-02-08 21:39

>>36
``cond" is your ``if"

Name: Anonymous 2011-02-08 21:41

>>36
and, btw, these guys talking about replacing `if`s with dispatchers, that is just a form of limited pattern matching. The same stuff parsers, like bison, do.

Name: Anonymous 2011-02-08 21:53

>>40
``->'' is his/your ``if''.

>>41
It doesn't always work, but it's an obvious thing to do.

Name: Anonymous 2011-02-08 22:05

>>42
`->` could be a table lookup. Like in {0->'a; 1->'b; 3->'c}. Or it could be a method, like in

class C a=1 b=2 m:{-> a+b}

Name: Anonymous 2011-02-08 22:09

>>43
Enjoy having your parser dealing with the halting problem when parsing (http://www.perlmonks.org/?node_id=663393) your DSL when it will grow even more.

Name: Anonymous 2011-02-08 22:12

>>44
implying he has a parser
Oh, /prog/, you are so funny

Name: Anonymous 2011-02-08 22:20

>>45
implying
Enjoy your new home: http://boards.4chan.org/g/.

implying he has a parser
Even a recursive descent parser is a parser. Even a stupid code walker must do some parsing. Infix notation needs a parser aware of the operators' precedence.

Name: Anonymous 2011-02-09 3:49

>>46
Yes, RDP is a parser. But that's irrelevant since
wannabe-lisper-12yo-autistic-boy has no parser at all.

Now.
I have a question.
How do you say wannabe-lisper-12yo-autistic-boy in official /prog/ langauge?

risuperu naritai jyuu ni sai autismo no otoko no ko kun? Damn, that's long.

Name: Anonymous 2011-02-09 6:16


PARSE MONADS EVERYDAY

For that refreshing dead dog

Name: Anonymous 2011-02-09 7:32

>>47
auchisumu
FTFY

Don't change these.
Name: Email:
Entire Thread Thread List