|
mr_jim posted:This is paraphrased from a bit-array library that I'm working on. I thought it was going to be 0 instead of -1, since I recently found out it rounds towards to 0, not simply rounding down. So it just interprets -1 as an unsigned int -1= 2^(4*8)-1. (sizeof(unsigned int) * 8)=4*8. 2^(4*8-)-1/(2^5 +1)~2^27. Took me a bit of time to work out all the bits and pieces. So the does the sizeof operator always return unsigned ints? I guess I should add a (int)cast infront of it when I use it.
|
# ? Jun 2, 2009 21:07 |
|
|
# ? Jun 6, 2024 05:37 |
|
It returns size_t.
|
# ? Jun 2, 2009 21:15 |
|
Unless you're planning on using the result of sizeof() in expression with a signed type, you don't need a cast. And you shouldn't cast it to a signed type unless you're sure it won't overflow, as in this case. sizeof(unsigned int) isn't likely to be out of range for an int. gcc is following the standard by converting both operands to an unsigned type here, but it caught me by surprise. By the way, -Wconversion will make gcc warn you when it performs a conversion that can change signs. I wasn't using that and couldn't figure out why I was getting a sudden jump in memory usage during some unit tests. Edit: My solution didn't involve a cast either. I just explicitly check for negative or 0 values. This prevents the overflow problem and makes sure array_size(0) return 0 instead of 1. code:
mr_jim fucked around with this message at 21:58 on Jun 2, 2009 |
# ? Jun 2, 2009 21:46 |
|
C++: Exhibit 1 code:
code:
code:
code:
Lexical Unit fucked around with this message at 21:57 on Jun 2, 2009 |
# ? Jun 2, 2009 21:54 |
|
Lexical Unit posted:Exhibit 3 I do not understand how even the most novice day 1 programmer could look at this and think it is okay.
|
# ? Jun 3, 2009 02:32 |
|
In the real code there's more like 20 lines in each branch... they are exactly the same. For a good long second I didn't realize what I was looking at because I couldn't believe what I saw.
|
# ? Jun 3, 2009 03:59 |
|
"handle_pants_event" is the greatest function name ever and I am going to use it all the time now.
|
# ? Jun 3, 2009 04:44 |
|
Ryouga Inverse posted:"handle_pants_event" is the greatest function name ever and I am going to use it all the time now. pants event raised, handling it, brb
|
# ? Jun 3, 2009 04:57 |
|
In all fairness though, one person who wrote some of that code will freely admit that he is not a programmer, and that he doesn't particularly want to program or know why he is occasionally tasked to do so when it's not really part of his job. The real horror is that we hire so many non-programmers to do programming. BigRedDot fucked around with this message at 05:51 on Jun 3, 2009 |
# ? Jun 3, 2009 05:48 |
|
Mill Town posted:pants event raised, handling it, brb throw new PantsHandlingException(pantsType); BigRedDot posted:The real horror is that we hire so many non-programmers to do programming. I've heard a lot of this from people who don't work for high-tech companies. A lot of non-CS and non-Match majors end up coding, and that scares the hell out of me. Thankfully my job's not like that.
|
# ? Jun 3, 2009 06:13 |
|
Inverse Icarus posted:I've heard a lot of this from people who don't work for high-tech companies. A lot of non-CS and non-Math majors end up coding, and that scares the hell out of me. BigRedDot fucked around with this message at 06:28 on Jun 3, 2009 |
# ? Jun 3, 2009 06:26 |
|
Inverse Icarus posted:throw new PantsHandlingException(pantsType); Political Science major programmer checking in
|
# ? Jun 3, 2009 07:51 |
|
Lexical Unit posted:C++: code:
quote:Exhibit 2
|
# ? Jun 3, 2009 10:43 |
|
Oh IMAP, how do I hate thee, let me count the ways:
|
# ? Jun 3, 2009 11:18 |
|
Zombywuf posted:Well, that code will order the incoming events by uid... I didn't show it but later he takes that same vector, takes the reference of it to get a pointer to it, and passes around that pointer to other functions. If you look in the revision history you can see that in the past he was just passing around the vector by value until finally the program ground to a halt and he changed to passing around pointers to the vector to speed the program up.
|
# ? Jun 3, 2009 14:46 |
|
Mill Town posted:pants event raised, handling it, brb Warning: FIFO full, pants dropped
|
# ? Jun 3, 2009 16:48 |
|
Fecotourist posted:Warning: FIFO full, pants dropped I believe you're looking for FIPO; First In, Pants Off.
|
# ? Jun 4, 2009 02:38 |
|
Working on something containing this earlier today...code:
|
# ? Jun 4, 2009 03:24 |
|
idgi (USER WAS PUT ON PROBATION FOR THIS POST)
|
# ? Jun 4, 2009 06:26 |
|
Unhandled exception? I'm dealing with something that's even worse A C# website assumes the user is logged in, and then checking each and every time the member's properties are referenced for a NullReferenceException. Then it redirects them to the login page gaahhhh
|
# ? Jun 4, 2009 07:05 |
|
pthread_cond_broadcast, and the pthreads library in general, is a C API; its calls should never throw exceptions. Moreover, even if pthreads calls did throw exceptions in general, pthread_cond_broadcast never fails on valid input: the spec lists only one failure mode, when you give it an uninitialized condition variable. Moreover, the call is surrounded by a generic exception-silencer, which raises the question of why: either (a) an exception from that spot once caused some bug that some fool can't be bothered to properly fix (impossible here) or rjmccall fucked around with this message at 17:40 on Jun 4, 2009 |
# ? Jun 4, 2009 07:37 |
|
rjmccall posted:(b) the program and someone can't happen again or
|
# ? Jun 4, 2009 13:35 |
|
Mustach posted:What was this supposed to say? Editing mistake. Edited for justice.
|
# ? Jun 4, 2009 17:41 |
|
web2py. The English language doesn't contain the appropriate verbiage to describe this, but I'll give it a shot. 1) Web based code editing tool. That is you edit your code in a web browser, and it just runs. The security risks... I can't even describe. 2) It automatically imports stuff, in many languages this may be the norm, but in Python it's the antichrist, this is advertised as a feature. 3) It automatically does migrations for you, as in it detects a change in your models, and it just changes the DB accordingly. 4) It encourages a disk based session store and in memory caching. 5) It has various DOM helper classes, basically so you can write html in python with stuff like HTML(HEAD(TITLE("my title")), BODY(DIV(A))) etc.... Also, the creator, Massimo di Pierro, just about trolls the internet (reddit in particular) advertising it. Plus he thinks the only difference between Python and Java is "exec".
|
# ? Jun 4, 2009 18:53 |
|
web2py is the TimeCube of Python web libraries. Here's a quote from the creator, from a reddit thread:quote:It looks like you have not even read the slides that started this thread: Obviously the best way to replace PHP sites is to use a deformed, half-PHP half-Python language written by somebody who doesn't know what an interpreter is, or why allowing web-accessible execution of arbitrary code is a bad idea. oh and quote:I tech computer science and security classes at the master and PhD level. I teach programmers and architects from major software development companies. Some of my software development research (not web2py) is funded by the Department of Energy. I think I know a thing or two about software development. I am not saying I know more than you do. I do not pretend to know you. I am just saying you do not look professional when you talk this way.
|
# ? Jun 4, 2009 19:12 |
|
king_kilr posted:5) It has various DOM helper classes, basically so you can write html in python with stuff like HTML(HEAD(TITLE("my title")), BODY(DIV(A))) etc.... I hate this poo poo in any language that does it. When I started writing my first Rails app, I'm just writing the usual <% %> templates, and everyone in all the Rails forums/blogs that I read to learn was like "You've gotta use haml, haml haml haml, I love to stick my dick in haml and then when I'm done I flip over so haml can top me too, oh godddddd haml". Do we really need a completely different markup language that obfuscates the HTML that most people doing web development would already know? It gets translated into HTML anyway, so what's the point of introducing yet another tier of crap for a user to have to learn when regular ol' template substitution suffices? Anyone who tells me that the box on the left is better or more legible than the box on the right can suck it. I like Rails from the couple projects I've been involved with that use it, but it's the reinvent-the-wheel-for-no-reason mentality of these edge projects (and the flamingly pretentious copy on their websites) that ruin it for the rest of us. Janin posted:The fact that that guy uses "I te[a]ch computer science at the Ph.D. level" as an indicator that he knows a thing or two about software development makes me wonder if he's ever interacted with any other computer science professors, ever. Out of my entire department, I can name about two or three who can actually write kick-rear end code. The others either just manage to get by, or avoid it altogether. Flobbster fucked around with this message at 19:17 on Jun 4, 2009 |
# ? Jun 4, 2009 19:13 |
|
Flobbster posted:I hate this poo poo in any language that does it. When I started writing my first Rails app, I'm just writing the usual <% %> templates, and everyone in all the Rails forums/blogs that I read to learn was like "You've gotta use haml, haml haml haml, I love to stick my dick in haml and then when I'm done I flip over so haml can top me too, oh godddddd haml". It's a bad idea for page templates though, and web2py's implementation is *especially* bad because it just throws the template into `exec()`.
|
# ? Jun 4, 2009 19:28 |
|
code:
|
# ? Jun 5, 2009 22:21 |
|
code:
|
# ? Jun 8, 2009 14:43 |
|
Bizarro Buddha posted:
Stop looking at my code.
|
# ? Jun 8, 2009 15:07 |
|
Bizarro Buddha posted:
I wrote comments in haiku one semester, after finding out that my Data Structures and Algorithms professor had a haiku page on his school website. I figured he'd get a kick out of it, but he never said anything about it. He probably just had his TAs grade everything code:
|
# ? Jun 8, 2009 20:04 |
|
Inverse Icarus posted:
This is so beautiful.
|
# ? Jun 8, 2009 22:01 |
|
Inverse Icarus posted:
this for new cobol title
|
# ? Jun 8, 2009 22:12 |
|
Inverse Icarus posted:
This is the exact opposite of a coding horror.
|
# ? Jun 8, 2009 22:53 |
|
tef posted:this for new cobol title
|
# ? Jun 8, 2009 23:38 |
|
code:
|
# ? Jun 9, 2009 00:20 |
|
CanSpice posted:
At least they're being honest.
|
# ? Jun 9, 2009 01:21 |
|
tef posted:this for new cobol title
|
# ? Jun 9, 2009 10:00 |
|
tef posted:this for new cobol title toot toot all aboard
|
# ? Jun 9, 2009 11:11 |
|
|
# ? Jun 6, 2024 05:37 |
|
php:<? // Load templates $templates_ok = true; ?> I guess it's reassuring to know that they're ok, in any case
|
# ? Jun 9, 2009 11:50 |