| « Prev | Page 1 | Next » |
|
Whoa! This is some neat code. :)
|
|
Isn't it ironic that an article, beginning with a statement about "typing", has this typographical error?
... change about how we write ode: |
You may just write code. When some of us do it, it's even an ode ;-) |
|
The Real WTF is that this site crashed for a couple of minutes just before this new article appeared. Could this be the repeated hammering of F5 by the fisters?
captcha = dreadlocks |
Re: It's Like Calling Assert
2007-06-11 09:18
•
by
Thomas
(unregistered)
|
"to their ay of doing things" Making an ode or an ay? ;-) |
Or this one: try to make the language adapt to their ay of doing things. |
Re: It's Like Calling Assert
2007-06-11 09:32
•
by
Anonymous Coward
(unregistered)
|
|
Well, the biggest WTF is that the code is in Java for sure... And, he clearly uses the exception to get a stack trace... however, IIRC stack trace is initialized upon construction, not when the throwable is thrown.
|
|
Since when did .net have the final keyword?
craaazy indeed! |
Re: It's Like Calling Assert
2007-06-11 09:33
•
by
T$
(unregistered)
|
|
Yeah, as the author says, it's just his "ay" of doing it.
CAPTCHA: burned, haha |
|
An Ode!
Aye Captain! Arrrr |
Re: It's Like Calling Assert
2007-06-11 09:40
•
by
Anonymous Coward
(unregistered)
|
If the error was truly fatal and there was no point in continuing the execution, he should have thrown an Error. To get the stack trace in logs, he could have used
|
|
For what the code is supposed to do (in the eyes of the original coder) it is fairly concise. That's what a WTF is all about - well written code to do the exactly wrong thing!
|
|
Let us not overlook that he creates a completely empty Exception ---- and then logs it, as if it had some useful information......
|
|
An Ode to the Ay of Certain Developers:
Forsooth! And how doth the keyboard clack As when, among twin perils of unnecessary loops and strange Inner Platforms, Bestride the angry waters of unfamiliar syntax and new paradigms Doth the Certain Developer lament: alas and alack! My brain hurteth so: ay ay ay This mountain, this Learning Curve, I durst not climb. But wherein his refuge? Of what dost thou speak? I speak of the inevitable temptation, to wit: As Alexander crossed the Hellespont, As Odysseus braved maelstrom, Verily as Hercules confronted the Hydra, So our hero confronts the Language Beast, And vanquishes the angry unknown, be it syntax or context, With an onslaught, truly a fusillade: the Wrapper of our Discontent, That the Language may, to his will be bent. |
Re: It's Like Calling Assert
2007-06-11 10:21
•
by
Lothar
(unregistered)
|
|
> however, IIRC stack trace is initialized upon construction, not when the throwable is thrown.
AFAIR exceptions on Java 1.0 and 1.1 have to be thrown to get the stacktrace filled in. If the code is older, this might be a correct attempt to get the assert-function working. Regards, Lothar |
|
If you want a stack trace in .NET, call Environment.StackTrace.
|
|
I once wrote:
/** * Does what it says on the tin */ public static void crash(){ System.exit(1); } ... it worked every time... |
Re: It's Like Calling Assert
2007-06-11 10:38
•
by
AbbydonKrafts
|
Beautiful *wipes tear from his eye* |
Re: It's Like Calling Assert
2007-06-11 10:51
•
by
anne
(unregistered)
|
Oh boy it's a computer geek AND a classics geek! What an awesome combination. Kudos to you! |
Re: It's Like Calling Assert
2007-06-11 11:02
•
by
AbbydonKrafts
|
Re: It's Like Calling Assert
2007-06-11 11:08
•
by
rycamor
(unregistered)
|
|
I am duly honored.
BTW, I made a small typo: there should be a "the" in front of "maelstrom". |
|
I fail to see the wtf, here. I used to write code exactly like this a few years ago, as it was the only know way to get a stack frame in Java.
The real wtf seem to be the speed by which this site is going down the tube (even renaming from "what the fuck" to "worse than failure" made me thin WTF...) |
Your true talents are wasted on mere "code-banging"! Excellent work. |
Re: It's Like Calling Assert
2007-06-11 12:39
•
by
ThingGuy McGuyThing
(unregistered)
|
Worst. Haiku. Ever. |
Re: It's Like Calling Assert
2007-06-11 13:19
•
by
Calvin Spealman
(unregistered)
|
|
This is exactly the thing I try to guard against when teaching people to be "pythonic" when writing Python code, and what I am trying to get across in my last blog post Dynamic Hell in Python Names. Moving between languages inevitably drags along both bad and good ideas that all become bad in the new environment.
|
You, sir, have earned the title of Poet Laureate for WorseThanFailure.com. I bow to your poetry skillz. |
|
That's almost the same as the error handling at a previous job:
|
Re: It's Like Calling Assert
2007-06-11 14:33
•
by
Frost
(unregistered)
|
The REAL WTF is that you think the function name is an accurate description of what happens. |
|
I wouldn't really call this a WTF, it's just an example of someone who doesn't understand Exceptions.
|
Re: It's Like Calling Assert
2007-06-11 15:16
•
by
woohoo
(unregistered)
|
Which game might it have been that ruined the "c" and "w" keys on Alex' keyboard? ;o) BTW, it's Java, not C#, and another minor WTF lurks in the disregard of proper Java naming conventions, i.e. the notation of the function name (all caps...). Said developer is either an AOL user or a Csharpie all right... ;o)) |
Little, yes... fundamental. You must remember this: A catch is just a catch; a try is just a try. The fundamental things apply As platforms go by. |
|
WTF does Assert do anyway? Really.
Does it stop program execution if true? Does it Assert that the value is indeed the value or does it just write the value to a debug window. VB programmers everywhere need to know. I mean it's not like debuggers are usefully anyway.... I mean really I could manually evaulate all the code in my head in context and find the problem.. right? |
Re: It's Like Calling Assert
2007-06-11 17:06
•
by
Christopher Clark
(unregistered)
|
Technically, since C doesn't have booleans, assert(false) makes monkeys fly out of your butt. Sideways. assert(0), on the other hand, prints a message to stderr (which this function doesn't do), and calls abort() to terminate without standard cleanup (which this code also doesn't do). Unless NDEBUG is defined at the moment <assert.h> is included, in which case nothing happens. |
|
what good is assert? It's bloody usefull to have when working with non-programming staff, like say, artists.
Telling an artist that "no, 36 is NOT a power of two, but 32 is" is just pointless, because they'll STILL make those textures in incorrect sizes. Put an assert on the build they use for testing thier art, or even on the conversion tools and they'll soon get the message. Making apps or tool-apps handle incorrect things like that by chopping of bits to the nearest ^2 just makes them lazy and they'll bitch and moan how the code screws thier work up. A controlled crash landing using a custom assert macro however, will make them fix it straight away, or atleast after they've run crying to your desk. The same thing goes for live game code...screw handling incorrect bone names gracefully. If the game has used a bone called "focus_point" for the last six months, I'm not bloody changing the code because of a typo or making the test build just focuson on the origin. Assert straight away, so they can fix thier own error...after coming to your desk demanding to know why you've broken thier art. |
|
Whats even more of a WTF is that in C# there is:
Debug.Assert(expression); and in Java: assert expression; Or is it somehow different? Am I missing something? |
Re: It's Like Calling Assert
2007-06-11 17:38
•
by
Adrien "Krunch" Kunysz
(unregistered)
|
|
The real WTF is that assert is used in that project too. TIMTOWTDI I guess.
|
|
Is the WTF supposed to be that he was so stubborn he refused to give up the assert method of dealing with errors? Because if so, he isn't the only one so stubborn. Java (as of 1.4 I believe) now supports asserts. Granted it doesn't perform a System.exit but instead throws an AssertionError, though than can be problematic when certain people write:
And no, I didn't forget the ellipses in the catch block. I have seen that without anything in there (ok, maybe there was a comment or two). |
|
ROFL...
One of the best WTFs ever! |
Re: It's Like Calling Assert
2007-06-12 05:38
•
by
Bellinghman
|
Technically, C has booleans - they're called _Bool (also bool if you #include <stdbool.h>). And that same header includes macros for true and false. Section 7.16 of the current C standard. |
Re: It's Like Calling Assert
2007-06-12 06:27
•
by
DOA
(unregistered)
|
I wish I has as much free time as you |
Re: It's Like Calling Assert
2007-06-12 08:39
•
by
Greg
(unregistered)
|
Saw a great t-shirt this weekend: Haikus can be fun. Sometimes they do not make sense. Refridgerator. |
int false = 1; assert(false); I see no problem.
actually, something happens - the token sequence ((void)0) is inserted into the code. Exactly that token sequence - it can't be ((void)(0)), ((void)1), or anything else that would be equivalent, it has to be exactly ((void)0). |
|
I gues I am lucky or unfortunate because I never really got to do any real C programming or Java for that matter. So for just laughs we can say Assert is the flip side of On Error Resume Next even though it isn't actually in principal it something like that...
typedef int BOOL; #define FALSE 0 #define TRUE 1 #define NULL 0 //OMG WTF 0 as in 0x0000 |
|
#define MAYBE -1
yes it's now TriState lmao |
Aw, what'dja correct it for? Now first-time readers are going to be going "WTF?" all the way down through the pun fun. |
Re: It's Like Calling Assert
2007-06-14 20:19
•
by
Scott
(unregistered)
|
Umm. I suspect you don't quite get the distinction between an assertion and an exception (as traditionally defined). An exception is used to detect and handle dynamic error conditions arising from the data or the environment - e.g. an over-length string, or running out of file space. An assertion is not supposed to be used for this: it's used to detect and abort if a condition occurs which can never happen if the logic of the program is correct - e.g. an array is passed as a parameter and its length appears to be negative. You can turn off assertions in a correctly written program, and the behaviour of the program will be completely unchanged - which is obviously not the case for exceptions. C exceptions are great: scatter them liberally to test the invariants and preconditions in your code, and a lot of bugs surface with very little effort. I generally try to make some sort of equivalent in languages which don't directly support assertions, and often bodging something up with an exception is the nearest you can get. |
Re: It's Like Calling Assert
2007-06-18 13:35
•
by
Christopher Clark
(unregistered)
|
D'oh. My bad, been forced to use an out-of-date compiler for a while now, and apparently it's killing off sections of my brain. |
Re: It's Like Calling Assert
2007-06-18 13:59
•
by
Christopher Clark
(unregistered)
|
I was glossing. Yes, it sticks in something to make sure the compilation doesn't issue spurious warnings. At runtime, nothing happens. |
Re: It's Like Calling Assert
2007-08-23 08:56
•
by
Sharp
(unregistered)
|
|
My eyes... the goggles do nothing!!!
|
| « Prev | Page 1 | Next » |